{"id":20728786,"url":"https://github.com/codeclown/native-datepicker","last_synced_at":"2025-04-23T19:41:58.939Z","repository":{"id":56417302,"uuid":"309085812","full_name":"codeclown/native-datepicker","owner":"codeclown","description":"Styleable datepicker utilizing the native \u003cinput type=\"date\"\u003e","archived":false,"fork":false,"pushed_at":"2020-11-09T10:52:51.000Z","size":32,"stargazers_count":37,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T07:59:01.971Z","etag":null,"topics":["datepicker","input","javascript","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeclown.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-01T11:58:43.000Z","updated_at":"2025-04-08T15:24:18.000Z","dependencies_parsed_at":"2022-08-15T18:20:26.577Z","dependency_job_id":null,"html_url":"https://github.com/codeclown/native-datepicker","commit_stats":null,"previous_names":["codeclown/boring-datepicker"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclown%2Fnative-datepicker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclown%2Fnative-datepicker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclown%2Fnative-datepicker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeclown%2Fnative-datepicker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeclown","download_url":"https://codeload.github.com/codeclown/native-datepicker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250501242,"owners_count":21440981,"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":["datepicker","input","javascript","react"],"created_at":"2024-11-17T04:40:01.424Z","updated_at":"2025-04-23T19:41:58.913Z","avatar_url":"https://github.com/codeclown.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-datepicker\n\n\u003e Styleable datepicker utilizing the native `\u003cinput type=\"date\"\u003e`\n\n[![native-datepicker on npm](https://img.shields.io/badge/npm-native--datepicker-blue)](https://www.npmjs.com/package/native-datepicker)\n[![codeclown/native-datepicker on GitHub](https://img.shields.io/badge/github-codeclown%2Fnative--datepicker-lightgrey)](https://github.com/codeclown/native-datepicker)\n\nFeatures:\n\n- Light-weight, no dependencies\n- Includes optional React-component\n- Supports datetime strings (only replaces date-portion upon change)\n- Simple styling, with BEM classes\n\nExample/demo:\n\n- [https://codeclown.github.io/native-datepicker/example.html](https://codeclown.github.io/native-datepicker/example.html)\n\n## Browser support\n\nSupported:\n\n- Chrome\n- Firefox\n- Edge\n- Safari iOS\n\nNot supported (datepicker is hidden):\n\n- Safari MacOS\n- IE\n\n## Usage\n\n### Vanilla JS\n\n```js\nconst NativeDatepicker = require('native-datepicker');\nconst picker = new NativeDatepicker({\n  onChange: (newValue) =\u003e {\n    console.log(newValue);\n  },\n});\nsomeElement.appendChild(picker.element);\n```\n\nSee [API](#api).\n\nSee also [`example.html` (source)](./example.html).\n\n### React\n\n```jsx\nconst NativeDatepicker = require('native-datepicker/src/react');\nconst SomeComponent = () =\u003e {\n  const [date, setDate] = useState('2020-11-01');\n  return (\n    \u003cNativeDatepicker value={date} onChange={(newValue) =\u003e setDate(newValue)} /\u003e\n  );\n};\n```\n\nSee [React API](#react-api).\n\n## API\n\n### `class NativeDatepicker`\n\n#### `constructor(options)`\n\n`options` is an object with the following properties:\n\n##### `options.onChange`\n\ntype: `function` default: `(value) =\u003e {}`\n\nCallback function which is called when the user selects a new date.\n\nReceives the new value as string (e.g. `\"2020-11-01\"` or `\"2020-11-01 13:15:00\"`; just the date-portion of the original value is replaced).\n\n##### `options.initialValue`\n\ntype: `string` default: `\"\"`\n\nSet the initial date input value.\n\nThese are equivalent:\n\n```js\nconst datepicker = new NativeDatepicker({\n  initialValue: '2020-11-09 12:43:00',\n});\n// or\nconst datepicker = new NativeDatepicker();\ndatepicker.setValue('2020-11-09 12:43:00');\n```\n\n##### `options.existingElement`\n\ntype: `DOMElement` default: `null`\n\nIf set, existing element will be used instead of creating a new `span` element.\n\n##### `options.win`\n\ntype: `Window` default: `window`\n\nFor the rare use case (e.g. using inside a child iframe) when setting `window` is necessary.\n\n#### `setValue(dateString)`\n\nSet the value of the datepicker.\n\n`dateString` should be a string containing a date in `YYYY-MM-DD` format. For example, all of these are valid:\n\n- `\"2020-11-01\"`\n- `\"2020-11-01 13:15:00\"`\n- `\"2020-11-01T13:15:00\"`\n\nUpon changes, NativeDatepicker will replace the date-portion of the string and return the result.\n\n#### `element`\n\nContains a reference to the datepicker element.\n\n## React API\n\n### `NativeDatepicker` component\n\nProps:\n\n```jsx\n\u003cNativeDatepicker\n  value={date}\n  onChange={(newValue) =\u003e {}}\n  className=\"customClassName\"\n\u003e\n  {optionalChildren}\n\u003c/NativeDatepicker\u003e\n```\n\n#### `props.value`\n\ntype: `string` default: `\"\"`\n\nInitial value. Examples:\n\n- `value=\"2020-11-01\"`\n- `value=\"2020-11-01 13:15:00\"`\n- `value=\"2020-11-01T13:15:00\"`\n\n#### `props.onChange`\n\ntype: `function` default: `(value) =\u003e {}`\n\nCallback function which is called when the user selects a new date.\n\nReceives the new value as string (e.g. `\"2020-11-01\"` or `\"2020-11-01 13:15:00\"`; just the date-portion of the original value is replaced).\n\n#### `props.className`\n\ntype: `string` default: `\"\"`\n\nCustom className for the created element.\n\nExample with `className=\"CustomClass\"`:\n\n```html\n\u003cspan class=\"NativeDatepicker CustomClass\"\u003e\n  \u003cinput class=\"NativeDatepicker__input\" type=\"date\" /\u003e\n\u003c/span\u003e\n```\n\n#### `optionalChildren`\n\nIf `children` are given, they are inserted into the resulting DOM. This can be used for any styling needs.\n\nExample:\n\n```html\n\u003cspan class=\"NativeDatepicker\"\u003e\n  \u003c!-- Children will be inserted here --\u003e\n  \u003cinput class=\"NativeDatepicker__input\" type=\"date\" /\u003e\n\u003c/span\u003e\n```\n\n## Styling / DOM structure\n\nThe following DOM is created for each datepicker:\n\n```html\n\u003cspan class=\"NativeDatepicker\"\u003e\n  \u003cinput class=\"NativeDatepicker__input\" type=\"date\" /\u003e\n\u003c/span\u003e\n```\n\nThe recommended way to style the datepicker is to apply styles (e.g. width/height and a background-image) to the topmost element. Example:\n\n```css\n.NativeDatepicker {\n  width: 16px;\n  height: 16px;\n  background: transparent url(...) no-repeat center center;\n}\n```\n\nNote: under normal circumstances you should not add any styles to `.NativeDatepicker__input`!\n\n## Development\n\nSource files reside in `src/`. Note that `src/index.js` is not precompiled in any way; it should remain valid ES5 (no worries, though; this is checked by eslint).\n\n## Release process (for maintainers)\n\nKeep [`CHANGELOG.md`](./CHANGELOG.md) up-to-date. Run:\n\n```bash\nyarn test\n# will ask for updated version number\nyarn publish\n# remember to push commits and tags to remote\ngit push --follow-tags\n```\n\n## License\n\n[ISC](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeclown%2Fnative-datepicker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeclown%2Fnative-datepicker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeclown%2Fnative-datepicker/lists"}