svelte-time-input 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018–2026 Wojciech Maj
4
+ Copyright (c) 2026 Adhi Ravishankar
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,37 @@
1
- # Temporary Holding Version
1
+ # svelte-time-input
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Segmented time input fields for your Svelte 5 app. Svelte port of the input part of [React-Time-Picker](https://github.com/wojtekmaj/react-time-picker), built on [svelte-date-input](../svelte-date-input).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install svelte-time-input
9
+ ```
10
+
11
+ Requires Svelte 5 or later. It installs `svelte-date-input` as a dependency.
12
+
13
+ ## Usage
14
+
15
+ ```svelte
16
+ <script lang="ts">
17
+ import TimeInput from 'svelte-time-input';
18
+
19
+ let value = $state<string | null>('22:15');
20
+ </script>
21
+
22
+ <TimeInput name="time" onChange={(nextValue) => (value = nextValue)} {value} />
23
+ ```
24
+
25
+ `value` is an `HH:mm[:ss]` string (a `Date` is accepted too) and `onChange` receives such a string, or `null`.
26
+
27
+ ## Props
28
+
29
+ `maxDetail` (`"hour"`, `"minute"` by default, or `"second"`), `format`, `locale`, `disabled`, `required`, `autoFocus`, `className`, `customInputsForm`, `name`, `nativeInputAriaLabel`, `showLeadingZeros`, `onChange`, `onInvalidChange`, and the `hour`/`minute`/`second`/`amPm` `*AriaLabel` and `*Placeholder` props. See [svelte-date-input](../svelte-date-input) for details.
30
+
31
+ ## Part of a monorepo
32
+
33
+ `svelte-time-input` is part of the [svelte-datetime-pickers monorepo](https://github.com/adhiravishankar/svelte-datetime-pickers). See the [live demo and Storybook](https://adhiravishankar.github.io/svelte-datetime-pickers/).
34
+
35
+ ## License
36
+
37
+ The MIT License.
@@ -0,0 +1,45 @@
1
+ <script lang="ts">
2
+ import { SegmentedInput } from 'svelte-date-input';
3
+
4
+ import type { ComponentProps } from 'svelte';
5
+ import type { LooseValuePiece, TimeDetail } from 'svelte-date-input';
6
+
7
+ type TimeInputProps = Omit<
8
+ ComponentProps<typeof SegmentedInput>,
9
+ | 'dayAriaLabel'
10
+ | 'dayPlaceholder'
11
+ | 'kind'
12
+ | 'maxDate'
13
+ | 'maxDetail'
14
+ | 'minDate'
15
+ | 'monthAriaLabel'
16
+ | 'monthPlaceholder'
17
+ | 'onChange'
18
+ | 'value'
19
+ | 'yearAriaLabel'
20
+ | 'yearPlaceholder'
21
+ > & {
22
+ /**
23
+ * The most detailed field the user shall see.
24
+ *
25
+ * @default 'minute'
26
+ */
27
+ maxDetail?: TimeDetail;
28
+ /**
29
+ * Function called when the user picks a valid time, as an `HH:mm` (or `HH:mm:ss`) string.
30
+ */
31
+ onChange?: (value: string | null, shouldCloseWidgets: boolean) => void;
32
+ /**
33
+ * Time as an `HH:mm[:ss]` string or a Date.
34
+ */
35
+ value?: LooseValuePiece;
36
+ };
37
+
38
+ let { onChange, ...props }: TimeInputProps = $props();
39
+ </script>
40
+
41
+ <SegmentedInput
42
+ {...props}
43
+ kind="time"
44
+ onChange={(value, shouldCloseWidgets) => onChange?.(value as string | null, shouldCloseWidgets)}
45
+ />
@@ -0,0 +1,22 @@
1
+ import { SegmentedInput } from 'svelte-date-input';
2
+ import type { ComponentProps } from 'svelte';
3
+ import type { LooseValuePiece, TimeDetail } from 'svelte-date-input';
4
+ type TimeInputProps = Omit<ComponentProps<typeof SegmentedInput>, 'dayAriaLabel' | 'dayPlaceholder' | 'kind' | 'maxDate' | 'maxDetail' | 'minDate' | 'monthAriaLabel' | 'monthPlaceholder' | 'onChange' | 'value' | 'yearAriaLabel' | 'yearPlaceholder'> & {
5
+ /**
6
+ * The most detailed field the user shall see.
7
+ *
8
+ * @default 'minute'
9
+ */
10
+ maxDetail?: TimeDetail;
11
+ /**
12
+ * Function called when the user picks a valid time, as an `HH:mm` (or `HH:mm:ss`) string.
13
+ */
14
+ onChange?: (value: string | null, shouldCloseWidgets: boolean) => void;
15
+ /**
16
+ * Time as an `HH:mm[:ss]` string or a Date.
17
+ */
18
+ value?: LooseValuePiece;
19
+ };
20
+ declare const TimeInput: import("svelte").Component<TimeInputProps, {}, "">;
21
+ type TimeInput = ReturnType<typeof TimeInput>;
22
+ export default TimeInput;
@@ -0,0 +1,5 @@
1
+ import TimeInput from './TimeInput.svelte';
2
+ import type { ComponentProps } from 'svelte';
3
+ export type TimeInputProps = ComponentProps<typeof TimeInput>;
4
+ export { TimeInput };
5
+ export default TimeInput;
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import TimeInput from './TimeInput.svelte';
2
+ export { TimeInput };
3
+ export default TimeInput;
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "svelte-time-input",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Segmented time input fields for your Svelte app.",
5
+ "keywords": [
6
+ "input",
7
+ "svelte",
8
+ "time",
9
+ "time-input"
10
+ ],
11
+ "license": "MIT",
12
+ "author": {
13
+ "name": "Adhi Ravishankar",
14
+ "email": "adhiravishankar@gmail.com"
15
+ },
16
+ "files": [
17
+ "dist/**/*",
18
+ "src/**/*",
19
+ "!**/*.spec.*"
20
+ ],
21
+ "type": "module",
22
+ "sideEffects": [
23
+ "*.css",
24
+ "*.svelte"
25
+ ],
26
+ "types": "./dist/index.d.ts",
27
+ "svelte": "./dist/index.js",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "svelte": "./dist/index.js",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./dist/*.css": "./dist/*.css"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "provenance": true
39
+ },
40
+ "scripts": {
41
+ "build": "svelte-package --input src --output dist",
42
+ "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true })\"",
43
+ "format": "vp fmt --check",
44
+ "lint": "vp lint",
45
+ "prepack": "npm run clean && npm run build",
46
+ "test": "npm run lint && npm run tsc && npm run format && npm run unit",
47
+ "tsc": "svelte-check --tsconfig ./tsconfig.json",
48
+ "unit": "vp test",
49
+ "watch": "svelte-package --input src --output dist --watch"
50
+ },
51
+ "dependencies": {
52
+ "svelte-date-input": "^0.1.0"
53
+ },
54
+ "devDependencies": {
55
+ "@sveltejs/package": "^3.0.1",
56
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
57
+ "@vitest/browser-playwright": "5.0.5",
58
+ "playwright": "^1.64.1",
59
+ "svelte": "^5.57.2",
60
+ "svelte-check": "^4.7.7",
61
+ "typescript": "^6.0.3",
62
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
63
+ "vite-plus": "1.4.0",
64
+ "vitest": "5.0.5",
65
+ "vitest-browser-svelte": "^3.1.0"
66
+ },
67
+ "peerDependencies": {
68
+ "svelte": "^5.0.0"
69
+ }
70
+ }
@@ -0,0 +1,45 @@
1
+ <script lang="ts">
2
+ import { SegmentedInput } from 'svelte-date-input';
3
+
4
+ import type { ComponentProps } from 'svelte';
5
+ import type { LooseValuePiece, TimeDetail } from 'svelte-date-input';
6
+
7
+ type TimeInputProps = Omit<
8
+ ComponentProps<typeof SegmentedInput>,
9
+ | 'dayAriaLabel'
10
+ | 'dayPlaceholder'
11
+ | 'kind'
12
+ | 'maxDate'
13
+ | 'maxDetail'
14
+ | 'minDate'
15
+ | 'monthAriaLabel'
16
+ | 'monthPlaceholder'
17
+ | 'onChange'
18
+ | 'value'
19
+ | 'yearAriaLabel'
20
+ | 'yearPlaceholder'
21
+ > & {
22
+ /**
23
+ * The most detailed field the user shall see.
24
+ *
25
+ * @default 'minute'
26
+ */
27
+ maxDetail?: TimeDetail;
28
+ /**
29
+ * Function called when the user picks a valid time, as an `HH:mm` (or `HH:mm:ss`) string.
30
+ */
31
+ onChange?: (value: string | null, shouldCloseWidgets: boolean) => void;
32
+ /**
33
+ * Time as an `HH:mm[:ss]` string or a Date.
34
+ */
35
+ value?: LooseValuePiece;
36
+ };
37
+
38
+ let { onChange, ...props }: TimeInputProps = $props();
39
+ </script>
40
+
41
+ <SegmentedInput
42
+ {...props}
43
+ kind="time"
44
+ onChange={(value, shouldCloseWidgets) => onChange?.(value as string | null, shouldCloseWidgets)}
45
+ />
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ import TimeInput from './TimeInput.svelte';
2
+
3
+ import type { ComponentProps } from 'svelte';
4
+
5
+ export type TimeInputProps = ComponentProps<typeof TimeInput>;
6
+ export { TimeInput };
7
+
8
+ export default TimeInput;