@molecule/app-time-slot-picker-react 1.0.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,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T00:41:23.981Z
7
+ -->
8
+
9
+ # @molecule/app-time-slot-picker-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ Time-slot picker for delivery / appointment / reservation flows.
16
+
17
+ Exports `<TimeSlotPicker>` and the `TimeSlot` type.
18
+
19
+ ## Quick Start
20
+
21
+ ```tsx
22
+ import { useState } from 'react'
23
+
24
+ import { TimeSlotPicker } from '@molecule/app-time-slot-picker-react'
25
+
26
+ function DeliveryStep() {
27
+ const [selectedSlot, setSelectedSlot] = useState<string | undefined>()
28
+ const slots = [
29
+ { id: 'am', label: '9:00–12:00', meta: '3 spots left' },
30
+ { id: 'pm', label: '14:00–17:00', meta: 'Available' },
31
+ { id: 'eve', label: '18:00–20:00', disabled: true, meta: 'Full' },
32
+ ]
33
+ return (
34
+ <TimeSlotPicker
35
+ slots={slots}
36
+ selectedId={selectedSlot}
37
+ onSelect={(slot) => setSelectedSlot(slot.id)}
38
+ layout="grid"
39
+ columns={3}
40
+ title="Pick a delivery window"
41
+ />
42
+ )
43
+ }
44
+ ```
45
+
46
+ ## Type
47
+
48
+ `feature`
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @molecule/app-time-slot-picker-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
54
+ npm install -D @types/react
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### Interfaces
60
+
61
+ #### `TimeSlot`
62
+
63
+ Represents a single selectable time slot with an optional meta line and disabled state.
64
+
65
+ ```typescript
66
+ interface TimeSlot {
67
+ id: string
68
+ /** Display label — `'14:00–16:00'`, `'Morning (9–12)'`, etc. */
69
+ label: ReactNode
70
+ /** Optional secondary line — date, fee, capacity. */
71
+ meta?: ReactNode
72
+ /** When true, slot is disabled (full / past / unavailable). */
73
+ disabled?: boolean
74
+ }
75
+ ```
76
+
77
+ #### `TimeSlotPickerProps`
78
+
79
+ Props for the {@link TimeSlotPicker} component.
80
+
81
+ ```typescript
82
+ interface TimeSlotPickerProps {
83
+ slots: TimeSlot[]
84
+ /** Currently selected slot id. */
85
+ selectedId?: string
86
+ /** Called when an enabled slot is picked. */
87
+ onSelect: (slot: TimeSlot) => void
88
+ /** Layout — `'list'` stacks vertically (mobile), `'grid'` lays out in columns. */
89
+ layout?: 'list' | 'grid'
90
+ /** Grid column count (only for `layout='grid'`). */
91
+ columns?: 2 | 3 | 4
92
+ /** Optional title above the slots. */
93
+ title?: ReactNode
94
+ /** Extra classes. */
95
+ className?: string
96
+ }
97
+ ```
98
+
99
+ ### Functions
100
+
101
+ #### `TimeSlotPicker(props)`
102
+
103
+ Picker for delivery / appointment / reservation time slots. Each slot
104
+ shows a label + optional secondary meta (date, fee, remaining
105
+ capacity). Disabled slots are dimmed and not clickable.
106
+
107
+ ```typescript
108
+ function TimeSlotPicker({
109
+ slots,
110
+ selectedId,
111
+ onSelect,
112
+ layout = 'list',
113
+ columns = 2,
114
+ title,
115
+ className,
116
+ }: TimeSlotPickerProps): JSX.Element
117
+ ```
118
+
119
+ - `props` — Component props (see {@link TimeSlotPickerProps}).
120
+
121
+ ## Injection Notes
122
+
123
+ ### Requirements
124
+
125
+ Peer dependencies:
126
+
127
+ - `@molecule/app-react` ^1.0.0
128
+ - `@molecule/app-ui` ^1.0.0
129
+ - `@molecule/app-ui-react` ^1.0.0
130
+ - `react` ^18.0.0 || ^19.0.0
131
+
132
+ ### Runtime Dependencies
133
+
134
+ - `@molecule/app-react`
135
+ - `@molecule/app-ui`
136
+ - `@molecule/app-ui-react`
137
+ - `react`
138
+
139
+ - Must render inside the app's i18n provider and with a ClassMap bond
140
+ wired (`useTranslation()` / `getClassMap()` throw otherwise).
141
+ - The picker has NO date/timezone logic — `label`/`meta` are opaque
142
+ strings. Format times in the user's locale AND timezone yourself
143
+ before passing them; the component will happily display UTC labels
144
+ to a local-time user.
145
+ - `layout="grid"` uses a FIXED column count (no breakpoint collapse) —
146
+ choose `columns` for your narrowest supported viewport or switch to
147
+ `layout="list"` on mobile.
148
+ - Selection is conveyed by `aria-checked` + bolder font only — add a
149
+ selected surface via `className` logic in your wrapper if the state
150
+ reads too subtle.
151
+ - Disabled slots are dimmed and non-clickable (`onSelect` never fires
152
+ for them).
153
+
154
+ ## Translations
155
+
156
+ Translation strings are provided by `@molecule/app-locales-time-slot-picker`.
@@ -0,0 +1,35 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ /** Represents a single selectable time slot with an optional meta line and disabled state. */
3
+ export interface TimeSlot {
4
+ id: string;
5
+ /** Display label — `'14:00–16:00'`, `'Morning (9–12)'`, etc. */
6
+ label: ReactNode;
7
+ /** Optional secondary line — date, fee, capacity. */
8
+ meta?: ReactNode;
9
+ /** When true, slot is disabled (full / past / unavailable). */
10
+ disabled?: boolean;
11
+ }
12
+ /** Props for the {@link TimeSlotPicker} component. */
13
+ export interface TimeSlotPickerProps {
14
+ slots: TimeSlot[];
15
+ /** Currently selected slot id. */
16
+ selectedId?: string;
17
+ /** Called when an enabled slot is picked. */
18
+ onSelect: (slot: TimeSlot) => void;
19
+ /** Layout — `'list'` stacks vertically (mobile), `'grid'` lays out in columns. */
20
+ layout?: 'list' | 'grid';
21
+ /** Grid column count (only for `layout='grid'`). */
22
+ columns?: 2 | 3 | 4;
23
+ /** Optional title above the slots. */
24
+ title?: ReactNode;
25
+ /** Extra classes. */
26
+ className?: string;
27
+ }
28
+ /**
29
+ * Picker for delivery / appointment / reservation time slots. Each slot
30
+ * shows a label + optional secondary meta (date, fee, remaining
31
+ * capacity). Disabled slots are dimmed and not clickable.
32
+ * @param props - Component props (see {@link TimeSlotPickerProps}).
33
+ */
34
+ export declare function TimeSlotPicker({ slots, selectedId, onSelect, layout, columns, title, className, }: TimeSlotPickerProps): JSX.Element;
35
+ //# sourceMappingURL=TimeSlotPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeSlotPicker.d.ts","sourceRoot":"","sources":["../src/TimeSlotPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAK3C,8FAA8F;AAC9F,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,gEAAgE;IAChE,KAAK,EAAE,SAAS,CAAA;IAChB,qDAAqD;IACrD,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;IAClC,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,oDAAoD;IACpD,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACnB,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,UAAU,EACV,QAAQ,EACR,MAAe,EACf,OAAW,EACX,KAAK,EACL,SAAS,GACV,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAuCnC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from '@molecule/app-react';
3
+ import { getClassMap } from '@molecule/app-ui';
4
+ /**
5
+ * Picker for delivery / appointment / reservation time slots. Each slot
6
+ * shows a label + optional secondary meta (date, fee, remaining
7
+ * capacity). Disabled slots are dimmed and not clickable.
8
+ * @param props - Component props (see {@link TimeSlotPickerProps}).
9
+ */
10
+ export function TimeSlotPicker({ slots, selectedId, onSelect, layout = 'list', columns = 2, title, className, }) {
11
+ const cm = getClassMap();
12
+ const { t } = useTranslation();
13
+ return (_jsxs("div", { className: cm.cn(cm.stack(2), className), children: [title && _jsx("h3", { className: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')), children: title }), _jsx("div", { role: "radiogroup", "aria-label": typeof title === 'string' ? title : t('timeSlot.aria', {}, { defaultValue: 'Time slots' }), className: layout === 'grid' ? cm.grid({ cols: columns, gap: 'sm' }) : cm.stack(2), children: slots.map((s) => {
14
+ const selected = s.id === selectedId;
15
+ return (_jsxs("button", { type: "button", role: "radio", "aria-checked": selected, disabled: s.disabled, onClick: () => !s.disabled && onSelect(s), className: cm.cn(cm.flex({ direction: 'col', align: 'start' }), cm.sp('p', 3), cm.textSize('sm'), selected ? cm.fontWeight('semibold') : cm.fontWeight('medium')), style: s.disabled ? { opacity: 0.4 } : undefined, children: [_jsx("span", { children: s.label }), s.meta && _jsx("span", { className: cm.textSize('xs'), children: s.meta })] }, s.id));
16
+ }) })] }));
17
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Time-slot picker for delivery / appointment / reservation flows.
3
+ *
4
+ * Exports `<TimeSlotPicker>` and the `TimeSlot` type.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import { useState } from 'react'
9
+ *
10
+ * import { TimeSlotPicker } from '@molecule/app-time-slot-picker-react'
11
+ *
12
+ * function DeliveryStep() {
13
+ * const [selectedSlot, setSelectedSlot] = useState<string | undefined>()
14
+ * const slots = [
15
+ * { id: 'am', label: '9:00–12:00', meta: '3 spots left' },
16
+ * { id: 'pm', label: '14:00–17:00', meta: 'Available' },
17
+ * { id: 'eve', label: '18:00–20:00', disabled: true, meta: 'Full' },
18
+ * ]
19
+ * return (
20
+ * <TimeSlotPicker
21
+ * slots={slots}
22
+ * selectedId={selectedSlot}
23
+ * onSelect={(slot) => setSelectedSlot(slot.id)}
24
+ * layout="grid"
25
+ * columns={3}
26
+ * title="Pick a delivery window"
27
+ * />
28
+ * )
29
+ * }
30
+ * ```
31
+ *
32
+ * @remarks
33
+ * - Must render inside the app's i18n provider and with a ClassMap bond
34
+ * wired (`useTranslation()` / `getClassMap()` throw otherwise).
35
+ * - The picker has NO date/timezone logic — `label`/`meta` are opaque
36
+ * strings. Format times in the user's locale AND timezone yourself
37
+ * before passing them; the component will happily display UTC labels
38
+ * to a local-time user.
39
+ * - `layout="grid"` uses a FIXED column count (no breakpoint collapse) —
40
+ * choose `columns` for your narrowest supported viewport or switch to
41
+ * `layout="list"` on mobile.
42
+ * - Selection is conveyed by `aria-checked` + bolder font only — add a
43
+ * selected surface via `className` logic in your wrapper if the state
44
+ * reads too subtle.
45
+ * - Disabled slots are dimmed and non-clickable (`onSelect` never fires
46
+ * for them).
47
+ *
48
+ * @module
49
+ */
50
+ export * from './TimeSlotPicker.js';
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,cAAc,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Time-slot picker for delivery / appointment / reservation flows.
3
+ *
4
+ * Exports `<TimeSlotPicker>` and the `TimeSlot` type.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * import { useState } from 'react'
9
+ *
10
+ * import { TimeSlotPicker } from '@molecule/app-time-slot-picker-react'
11
+ *
12
+ * function DeliveryStep() {
13
+ * const [selectedSlot, setSelectedSlot] = useState<string | undefined>()
14
+ * const slots = [
15
+ * { id: 'am', label: '9:00–12:00', meta: '3 spots left' },
16
+ * { id: 'pm', label: '14:00–17:00', meta: 'Available' },
17
+ * { id: 'eve', label: '18:00–20:00', disabled: true, meta: 'Full' },
18
+ * ]
19
+ * return (
20
+ * <TimeSlotPicker
21
+ * slots={slots}
22
+ * selectedId={selectedSlot}
23
+ * onSelect={(slot) => setSelectedSlot(slot.id)}
24
+ * layout="grid"
25
+ * columns={3}
26
+ * title="Pick a delivery window"
27
+ * />
28
+ * )
29
+ * }
30
+ * ```
31
+ *
32
+ * @remarks
33
+ * - Must render inside the app's i18n provider and with a ClassMap bond
34
+ * wired (`useTranslation()` / `getClassMap()` throw otherwise).
35
+ * - The picker has NO date/timezone logic — `label`/`meta` are opaque
36
+ * strings. Format times in the user's locale AND timezone yourself
37
+ * before passing them; the component will happily display UTC labels
38
+ * to a local-time user.
39
+ * - `layout="grid"` uses a FIXED column count (no breakpoint collapse) —
40
+ * choose `columns` for your narrowest supported viewport or switch to
41
+ * `layout="list"` on mobile.
42
+ * - Selection is conveyed by `aria-checked` + bolder font only — add a
43
+ * selected surface via `className` logic in your wrapper if the state
44
+ * reads too subtle.
45
+ * - Disabled slots are dimmed and non-clickable (`onSelect` never fires
46
+ * for them).
47
+ *
48
+ * @module
49
+ */
50
+ export * from './TimeSlotPicker.js';
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@molecule/app-time-slot-picker-react",
3
+ "version": "1.0.0",
4
+ "description": "Pick a delivery / appointment slot from a list of available time windows",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "keywords": [
24
+ "molecule",
25
+ "time-slot-picker",
26
+ "react"
27
+ ],
28
+ "license": "Apache-2.0",
29
+ "peerDependencies": {
30
+ "@molecule/app-react": "^1.0.0",
31
+ "@molecule/app-ui": "^1.0.0",
32
+ "@molecule/app-ui-react": "^1.0.0",
33
+ "react": "^18.0.0 || ^19.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@molecule/app-react": "1.0.0",
37
+ "@molecule/app-ui": "1.0.0",
38
+ "@molecule/app-ui-react": "1.0.0",
39
+ "@types/node": "26.1.2",
40
+ "@types/react": "19.2.17",
41
+ "@types/react-dom": "19.2.3",
42
+ "react": "19.2.8",
43
+ "react-dom": "19.2.8",
44
+ "typescript": "6.0.3",
45
+ "vitest": "4.1.10"
46
+ }
47
+ }