{"id":13656591,"url":"https://github.com/lamplightdev/aeon","last_synced_at":"2025-04-05T22:03:58.880Z","repository":{"id":40727237,"uuid":"243270689","full_name":"lamplightdev/aeon","owner":"lamplightdev","description":"A lightweight date picker built with web components that can be used anywhere","archived":false,"fork":false,"pushed_at":"2023-01-06T02:36:56.000Z","size":6839,"stargazers_count":315,"open_issues_count":20,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-11T13:39:40.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamplightdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-26T13:35:47.000Z","updated_at":"2024-10-08T04:41:38.000Z","dependencies_parsed_at":"2023-02-05T03:31:22.869Z","dependency_job_id":null,"html_url":"https://github.com/lamplightdev/aeon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamplightdev%2Faeon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamplightdev%2Faeon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamplightdev%2Faeon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamplightdev%2Faeon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamplightdev","download_url":"https://codeload.github.com/lamplightdev/aeon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406085,"owners_count":20933803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:00:24.555Z","updated_at":"2025-04-05T22:03:58.857Z","avatar_url":"https://github.com/lamplightdev.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Form Elements","Helper Components"],"sub_categories":[],"readme":"# Aeon\n\n\u003e A lightweight date time picker built with web components that can be used anywhere\n\n- **No dependencies 🌞** - a standalone vanilla JS web component\n- **Lightweight 🌱** - 5kb gzipped\n- **Use anywhere 🌍** - use standalone or directly in your framework of choice with no wrappers\n- **Progressive enhancement 🥞** - if the code fails to load, fallbacks to a native picker or a simple text box\n- **Accessible 👨‍👩‍👧‍👦‍** - works with mouse/touch/keyboard/screen readers and behaves as a native form element\n- **Locale aware 🇺🇳** - uses the browser locale language and date format by default\n- **Themeable 🎨** - pass in custom colour schemes\n- **Browser support 🖥** - works in all modern browsers on all devices (and IE11 - with polyfills)\n\n## Table of Contents\n\n- [Examples](#examples)\n- [Motivation](#motivation)\n- [Install](#install)\n- [Usage](#usage)\n- [Options](#options)\n- [API](#api)\n- [Theming](#theming)\n- [Contributions](#contributions)\n- [Author](#author)\n- [License](#license)\n\n## Examples\n\n- [A basic example](https://lamplightdev.github.io/aeon/)\n- [Same example with IE11 support](https://lamplightdev.github.io/aeon/es5)\n- [Storybook](https://lamplightdev.github.io/aeon/storybook/static/?path=/story/*) - experiment with all the options\n\n## Motivation\n\nI needed a progressively enhanced, lightweight date and time picker that functioned and looked consistent across all browsers, and that worked with or without a framework. The difference in support (no native picker on desktop Safari 👀) style and behaviour of native pickers rule them out, so web components seemed an obvious choice. The existing web component solutions tended to be too heavyweight, so Aeon was born.\n\n## Install\n\nInstall using [npm](https://npmjs.com):\n\n```sh\nnpm install --save @lamplightdev/aeon\n```\n\nor reference directly:\n\n```html\n\u003cscript src=\"https://unpkg.com/@lamplightdev/aeon\"\u003e\n```\n\n## Usage\n\nIf you're using ESM modules - just import Aeon directly into your code:\n\n```js\n// if you're using a bundler that resolves node_modules\nimport '@lamplightdev/aeon';\n\n// if you're using a bundler that doesn't resove node_modules\nimport 'path/to/node_modules/@lamplightdev/aeon/src/aeon.js';\n```\n\nAlternatively include Aeon in a script tag:\n\n```html\n\u003cscript type=\"module\" src=\"https://unpkg.com/@lamplightdev/aeon\"\u003e\u003c/script\u003e\n\n\u003c!-- or for the ES5 version --\u003e\n\n\u003cscript src=\"https://unpkg.com/@lamplightdev/aeon/dist/aeon-es5.js\"\u003e\u003c/script\u003e\n```\n\nThen use the `\u003caeon-datepicker\u003e` tag in your HTML wrapping a date input and optionally a time input to include a time picker too:\n\n```html\n\u003clabel for=\"date\"\u003eStart date\u003c/label\u003e\n\n\u003caeon-datepicker\u003e\n  \u003cinput type=\"date\" id=\"date\" name=\"date\" value=\"2020-03-20\" /\u003e\n\u003c/aeon-datepicker\u003e\n\n\u003caeon-datepicker\u003e\n  \u003cinput type=\"date\" id=\"date\" name=\"date\" value=\"2020-03-20\" /\u003e\n  \u003cinput type=\"time\" id=\"time\" name=\"time\" value=\"05:19\" /\u003e\n\u003c/aeon-datepicker\u003e\n```\n\n- Initial values can be set directly on the wrapped date and time inputs.\n- On selecting a date with the picker the component will update the wrapped date and time inputs with the selected values (`YYYY-MM-DD` and `HH:mm` respectively), so you can add Aeon to an existing form with no glue code necessary.\n- Alternatively retrieve the values directly from the `\u003caeon-datepicker\u003e` element or listen for changes (see [API](#api)).\n- If the web component fails to load for whatever reason, the page will still display the native date and time elements if available, or a standard text input if not. Progressive enhancement FTW.\n\n### IE11\n\nIf you need to support IE11, you'll need to use the es5 version of the script and a few polyfills. [See the ES5 example](https://lamplightdev.github.io/aeon/es5) for a working implementation, but at a minimum you'll need the following in the document `\u003chead\u003e`:\n\n```html\n\u003c!-- include the general polyfills needed --\u003e\n\u003cscript\n  crossorigin=\"anonymous\"\n  src=\"https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.find%2CArray.prototype.includes%2CString.prototype.padStart\"\n\u003e\u003c/script\u003e\n\n\u003c!-- include the web component polyfills needed --\u003e\n\u003cscript src=\"https://unpkg.com/@webcomponents/webcomponentsjs@%5E2/webcomponents-loader.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n  window.WebComponents = window.WebComponents || {\n    waitFor: function(cb) {\n      addEventListener('WebComponentsReady', cb);\n    }\n  };\n\n  WebComponents.waitFor(function() {\n    // when the web component polyfill is loaded\n    // load the script\n    var head = document.getElementsByTagName('head')[0];\n    var script = document.createElement('script');\n    script.src = './dist/aeon-es5.js';\n    head.appendChild(script);\n\n    // if you want to theme the components, add the custom property here\n    window.ShadyCSS \u0026\u0026\n      window.ShadyCSS.styleDocument({ '--aeon-rgb': '170, 10, 10' });\n  });\n\u003c/script\u003e\n```\n\n## Options\n\nAll Aeon options can be set declaratively as attributes on the `\u003caeon-datepicker\u003e` tag, or set imperatively in code:\n\n```html\n\u003clabel for=\"date-start\"\u003eStart Date\u003c/label\u003e\n\n\u003caeon-datepicker\n  id=\"datepicker\"\n  locale=\"en-us\"\n  default-date=\"2020-01-01\"\n  default-time=\"09:30\"\n\u003e\n  \u003cinput\n    id=\"date-start\"\n    name=\"date-start\"\n    type=\"date\"\n    value=\"2020-04-06\"\n    placeholder=\"Start date\"\n  /\u003e\n  \u003cinput id=\"time-start\" name=\"time-start\" type=\"time\" value=\"12:00\" /\u003e\n\u003c/aeon-datepicker\u003e\n\n\u003cscript\u003e\n  document.querySelector('#datepicker').locale = 'es';\n\u003c/script\u003e\n```\n\nExperiment with all options in the [Storybook](https://lamplightdev.github.io/aeon/storybook/static/?path=/story/*)\n\n| Attribute       | Property      | Property type | Default            | Description                                                                                                                                                             |\n| :-------------- | :------------ | :------------ | :----------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| default-date    | defaultDate   | String        | [now]              | If no value is set on the date input, the date shown in the date picker when opened, format `YYYY-MM-DD`                                                                |\n| default-time    | defaultTime   | String        | [now]              | If no value is set on the time input, the time shown in the date picker when opened,format `HH:mm`                                                                      |\n| start-day       | startDay      | Number        | `1` (Monday)       | Which day to start the week with in the calendar (0 - Sunday, 1 - Monday, etc.)                                                                                         |\n| start-year      | startYear     | Number        | current year - 100 | The earliest year to show in the year dropdown                                                                                                                          |\n| end-year        | endYear       | Number        | current year + 5   | The latest year to show in the year dropdown                                                                                                                            |\n| locale          | locale        | String        | browser default    | The locale - this affects the language of the months and days as well as the format of the date and time shown - the format can be further configured using `dateStyle` |\n| confirm-on-date | confirmOnDate | Boolean       | `false`            | If `true` and this is a date input only (no time input) then when a date is selected in the picker will close and the date will be updated                              |\n| use-native      | useNative     | Boolean       | `false`            | If `true`, use the browser native inputs for date and time where available                                                                                              |\n| date-style      | dateStyle     | Object        | locale default     | An object that controls how the date and time are shown - see note below                                                                                                |\n\n### dateStyle\n\nThe date style object is passed as the `options` parameter to the [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/DateTimeFormat) constructor to control the formatting of the displayed date and time.\n\nWhen setting as an attribute (`date-style`) this must be a JSON stringified value:\n\n```html\n\u003caeon-datepicker date-style='{\"month\":\"long\"}'\u003e\n  \u003cinput type=\"date\" /\u003e\n\u003c/aeon-datepicker\u003e\n```\n\n## API\n\nThe `value` property is an object containing two fields, `date` (YYYY-MM-DD) and `time` (HH:mm) of the currently selected date and time:\n\n```js\nconsole.log(document.querySelector('aeon-datepicker').value);\n/*\n  logs:\n  {\n    date: '2020-03-20',\n    time: '13:56\n  }\n*/\n});\n```\n\nA `change` event is dispatched when a new date has been selected:\n\n```js\ndocument.querySelector('aeon-datepicker').addEventListener('change', event =\u003e {\n  console.log(event.target.value);\n\n  /*\n  logs:\n  {\n    date: '2020-03-20',\n    time: '13:56\n  }\n  */\n});\n```\n\n## Theming\n\nThe foreground and background colours of the date picker can be configured using CSS custom properties. `--aeon-rgb` can be set to the RGB values of the foreground colour, while `--aeon-bgRgb` is used for the background colour.\n\nThese can be set for all components on the page by setting these properties on the `:root` element:\n\n```css\n:root {\n  --aeon-rgb: 255, 255, 255;\n  --aeon-bgRgb: 0, 0, 0;\n}\n```\n\nor individually on each component either in a CSS rule or inline:\n\n```html\n\u003caeon-datepicker style=\"--aeon-rgb: 255, 255, 255; --aeon-bgRgb: 0, 0, 0;\"\u003e\n  \u003cinput type=\"date\" id=\"date\" name=\"date\" value=\"2020-03-20\" /\u003e\n\u003c/aeon-datepicker\u003e\n```\n\n## Contributions\n\nAny contributions welcome!\n\n## Author\n\nMade by [@lamplightdev](https://twitter.com/lamplightdev), [lamplightdev.com](https://lamplightdev.com)\n\n## License\n\n[MIT License](https://oss.ninja/mit/lamplightdev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamplightdev%2Faeon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamplightdev%2Faeon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamplightdev%2Faeon/lists"}