imperijal-components 0.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.
Files changed (26) hide show
  1. package/INSTALL_AND_USAGE.md +288 -0
  2. package/PUBLISHING.md +306 -0
  3. package/README.md +35 -0
  4. package/package.json +22 -0
  5. package/packages/date-time-picker/README.md +78 -0
  6. package/packages/date-time-picker/package.json +82 -0
  7. package/packages/date-time-picker/src/components/date-calendar-panel.tsx +63 -0
  8. package/packages/date-time-picker/src/components/date-quick-chips.tsx +45 -0
  9. package/packages/date-time-picker/src/components/date-time-picker-content.tsx +121 -0
  10. package/packages/date-time-picker/src/components/date-time-picker.tsx +92 -0
  11. package/packages/date-time-picker/src/components/time-slot-grid.tsx +122 -0
  12. package/packages/date-time-picker/src/components/use-date-time-selection.ts +83 -0
  13. package/packages/date-time-picker/src/index.ts +19 -0
  14. package/packages/date-time-picker/src/lib/local-input-value.ts +45 -0
  15. package/packages/date-time-picker/src/lib/quick-dates.ts +59 -0
  16. package/packages/date-time-picker/src/lib/time-slots.ts +46 -0
  17. package/packages/date-time-picker/src/lib/utils.ts +6 -0
  18. package/packages/date-time-picker/src/styles.css +19 -0
  19. package/packages/date-time-picker/src/ui/button.tsx +51 -0
  20. package/packages/date-time-picker/src/ui/calendar.tsx +159 -0
  21. package/packages/date-time-picker/src/ui/collapsible.tsx +23 -0
  22. package/packages/date-time-picker/src/ui/popover.tsx +41 -0
  23. package/packages/date-time-picker/tsconfig.json +8 -0
  24. package/packages/date-time-picker/tsup.config.ts +23 -0
  25. package/pnpm-workspace.yaml +2 -0
  26. package/tsconfig.base.json +17 -0
@@ -0,0 +1,288 @@
1
+ # Install & usage — `@imperijal/date-time-picker`
2
+
3
+ Guide for **installing** the package in an app (e.g. restoranico) and **using** the DateTimePicker component.
4
+
5
+ For **publishing** to npm, see [PUBLISHING.md](./PUBLISHING.md).
6
+
7
+ ---
8
+
9
+ ## What this package is
10
+
11
+ `@imperijal/date-time-picker` is a React date & time picker with:
12
+
13
+ - Quick date chips (Today, Tomorrow, Sat, Sun)
14
+ - Expandable calendar
15
+ - Scrollable time grid (default **05:00–23:30**, every 30 min)
16
+ - Confirm button before applying
17
+
18
+ **Value format** (same as HTML `datetime-local`):
19
+
20
+ ```
21
+ YYYY-MM-DDTHH:mm
22
+ ```
23
+
24
+ Example: `2026-06-21T14:30`
25
+
26
+ ---
27
+
28
+ ## Install
29
+
30
+ ### From npm (after you publish)
31
+
32
+ ```bash
33
+ pnpm add @imperijal/date-time-picker
34
+ ```
35
+
36
+ ### Peer dependencies
37
+
38
+ Your app must already have (or install):
39
+
40
+ ```bash
41
+ pnpm add react react-dom date-fns lucide-react react-day-picker \
42
+ @radix-ui/react-popover @radix-ui/react-collapsible @radix-ui/react-slot \
43
+ class-variance-authority clsx tailwind-merge
44
+ ```
45
+
46
+ Most of these are already in **restoranico**.
47
+
48
+ ### Local development (before npm publish)
49
+
50
+ Link from the monorepo:
51
+
52
+ ```bash
53
+ # Terminal 1 — build the package
54
+ cd /home/marko-og/Documents/wappa/imperijal-components
55
+ pnpm build
56
+
57
+ # Terminal 2 — link globally
58
+ cd packages/date-time-picker
59
+ pnpm link --global
60
+
61
+ # Terminal 3 — link in your app
62
+ cd /home/marko-og/Documents/wappa/restoranico
63
+ pnpm link --global @imperijal/date-time-picker
64
+ ```
65
+
66
+ Or use a workspace/file dependency in `restoranico/package.json`:
67
+
68
+ ```json
69
+ "@imperijal/date-time-picker": "file:../imperijal-components/packages/date-time-picker"
70
+ ```
71
+
72
+ Then run `pnpm install` in restoranico.
73
+
74
+ ---
75
+
76
+ ## Tailwind setup
77
+
78
+ The picker uses Tailwind classes (`bg-primary`, `border-border`, etc.). Your app must:
79
+
80
+ ### 1. Scan the package in Tailwind content
81
+
82
+ **Tailwind v3** (`tailwind.config.ts`):
83
+
84
+ ```ts
85
+ content: [
86
+ './src/**/*.{js,ts,jsx,tsx}',
87
+ './node_modules/@imperijal/date-time-picker/dist/**/*.js',
88
+ ],
89
+ ```
90
+
91
+ **Tailwind v4** (`globals.css`):
92
+
93
+ ```css
94
+ @source "../node_modules/@imperijal/date-time-picker/dist/**/*.js";
95
+ ```
96
+
97
+ ### 2. CSS variables (shadcn-style)
98
+
99
+ If your app already uses shadcn/ui theme variables (`--primary`, `--border`, …), nothing else is needed.
100
+
101
+ Otherwise import optional tokens:
102
+
103
+ ```css
104
+ @import '@imperijal/date-time-picker/styles.css';
105
+ ```
106
+
107
+ ### 3. react-day-picker styles
108
+
109
+ If the calendar looks unstyled, add in your global CSS:
110
+
111
+ ```css
112
+ @import 'react-day-picker/style.css';
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Basic usage
118
+
119
+ ```tsx
120
+ 'use client';
121
+
122
+ import { useState } from 'react';
123
+ import {
124
+ DateTimePicker,
125
+ toLocalInputValue,
126
+ } from '@imperijal/date-time-picker';
127
+
128
+ export function Example() {
129
+ const [value, setValue] = useState(() => toLocalInputValue(new Date()));
130
+
131
+ return (
132
+ <DateTimePicker
133
+ value={value}
134
+ onChange={setValue}
135
+ />
136
+ );
137
+ }
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Usage in restoranico (traffic page)
143
+
144
+ Replace local imports:
145
+
146
+ ```tsx
147
+ // Before
148
+ import { DateTimePicker } from '@/components/ui/date-time-picker';
149
+ import { toLocalInputValue } from '@/lib/datetime/local-input-value';
150
+
151
+ // After
152
+ import {
153
+ DateTimePicker,
154
+ toLocalInputValue,
155
+ } from '@imperijal/date-time-picker';
156
+ ```
157
+
158
+ Example fields:
159
+
160
+ ```tsx
161
+ <DateTimePicker
162
+ value={defaultDeadline}
163
+ onChange={handleDefaultDeadlineChange}
164
+ className="mt-0.5 border-slate-200 focus-visible:ring-indigo-400"
165
+ />
166
+
167
+ <DateTimePicker
168
+ value={departureTime}
169
+ onChange={setDepartureTime}
170
+ className="mt-0.5 border-slate-200 focus-visible:ring-indigo-400"
171
+ />
172
+
173
+ <DateTimePicker
174
+ value={d.deadline}
175
+ onChange={(deadline) => updateDelivery(d.id, { deadline })}
176
+ size="sm"
177
+ className="mt-0.5 border-slate-200 focus-visible:ring-indigo-400"
178
+ />
179
+ ```
180
+
181
+ Convert to ISO when sending to API (unchanged):
182
+
183
+ ```tsx
184
+ deadline: new Date(d.deadline).toISOString()
185
+ departureTime: new Date(departureTime).toISOString()
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Props
191
+
192
+ | Prop | Type | Default | Description |
193
+ |------|------|---------|-------------|
194
+ | `value` | `string` | required | `YYYY-MM-DDTHH:mm` |
195
+ | `onChange` | `(value: string) => void` | required | Called on Confirm |
196
+ | `placeholder` | `string` | `'Select date & time'` | Empty state label |
197
+ | `size` | `'default' \| 'sm'` | `'default'` | Trigger size |
198
+ | `disabled` | `boolean` | `false` | Disable trigger |
199
+ | `className` | `string` | — | Extra classes on trigger |
200
+ | `id` | `string` | — | HTML id on trigger |
201
+ | `align` | `'start' \| 'center' \| 'end'` | `'start'` | Popover alignment |
202
+ | `timeSlots` | `TimeSlotConfig` | see below | Time range config |
203
+
204
+ ### `timeSlots` config
205
+
206
+ ```tsx
207
+ <DateTimePicker
208
+ value={value}
209
+ onChange={setValue}
210
+ timeSlots={{
211
+ startHour: 5, // first slot hour (24h)
212
+ endHour: 24, // exclusive end (24 = include 23:30)
213
+ intervalMinutes: 30,
214
+ }}
215
+ />
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Exported helpers
221
+
222
+ ```tsx
223
+ import {
224
+ toLocalInputValue, // Date → "2026-06-21T14:30"
225
+ parseLocalInputValue, // string → Date | null
226
+ formatLocalInputDisplay, // string → "Jun 21, 2026, 14:30"
227
+ combineLocalDateTime, // date + hours + minutes → string
228
+ generateTimeSlots,
229
+ getQuickDateOptions,
230
+ useDateTimeSelection, // headless hook
231
+ DateTimePickerContent, // panel without popover
232
+ } from '@imperijal/date-time-picker';
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Monorepo layout
238
+
239
+ ```
240
+ imperijal-components/ ← NOT published (private root)
241
+ ├── packages/
242
+ │ └── date-time-picker/ ← @imperijal/date-time-picker (published)
243
+ └── INSTALL_AND_USAGE.md ← this file
244
+ ```
245
+
246
+ **Never run `npm publish` from the repo root.** Only publish packages inside `packages/`.
247
+
248
+ ---
249
+
250
+ ## Common errors
251
+
252
+ ### `E403` — Two-factor authentication required
253
+
254
+ npm blocks publish until 2FA is enabled. See [PUBLISHING.md — Fix E403](./PUBLISHING.md#fix-e403-two-factor-authentication-required).
255
+
256
+ ### Published wrong package name `imperijal-components`
257
+
258
+ You ran publish from the **monorepo root**. Root must stay `"private": true`. Publish only:
259
+
260
+ ```bash
261
+ cd packages/date-time-picker
262
+ pnpm publish --access public
263
+ ```
264
+
265
+ Or from root:
266
+
267
+ ```bash
268
+ pnpm publish:date-time-picker
269
+ ```
270
+
271
+ ### Styles look broken
272
+
273
+ - Add Tailwind content path for `node_modules/@imperijal/date-time-picker/dist/**/*.js`
274
+ - Ensure CSS variables (`--primary`, etc.) exist in your app
275
+
276
+ ### `Module not found: @imperijal/date-time-picker`
277
+
278
+ Package not installed or not built. Run `pnpm build` in monorepo, then `pnpm install` in app.
279
+
280
+ ---
281
+
282
+ ## Uninstall / unlink local package
283
+
284
+ ```bash
285
+ cd restoranico
286
+ pnpm unlink --global @imperijal/date-time-picker
287
+ pnpm remove @imperijal/date-time-picker
288
+ ```
package/PUBLISHING.md ADDED
@@ -0,0 +1,306 @@
1
+ # Publishing `@imperijal/*` packages to npm
2
+
3
+ Follow these steps in order. You only need to do **Step 1–3 once**; repeat **Step 4–8** for each release.
4
+
5
+ ---
6
+
7
+ ## Step 1 — Create the GitHub repo
8
+
9
+ 1. Go to [github.com/new](https://github.com/new)
10
+ 2. Name: `imperijal-components`
11
+ 3. Visibility: Public (required for free scoped public packages) or Private
12
+ 4. **Do not** initialize with README (you already have files locally)
13
+
14
+ Then link your local folder:
15
+
16
+ ```bash
17
+ cd /home/marko-og/Documents/wappa/imperijal-components
18
+ git init
19
+ git add .
20
+ git commit -m "chore: initial monorepo with date-time-picker"
21
+ git branch -M main
22
+ git remote add origin git@github.com:YOUR_USERNAME/imperijal-components.git
23
+ git push -u origin main
24
+ ```
25
+
26
+ Replace `YOUR_USERNAME` with your GitHub username or org.
27
+
28
+ ---
29
+
30
+ ## Step 2 — Create an npm account & org (optional)
31
+
32
+ 1. Sign up at [npmjs.com](https://www.npmjs.com/signup)
33
+ 2. Verify your email
34
+ 3. **Optional but recommended:** create org `imperijal` at [npmjs.com/org/create](https://www.npmjs.com/org/create)
35
+ - Lets you publish `@imperijal/date-time-picker` under a team name
36
+ - If you skip this, use `@YOUR_NPM_USERNAME/date-time-picker` instead and update `name` in `packages/date-time-picker/package.json`
37
+
38
+ ---
39
+
40
+ ## Step 3 — Log in to npm locally
41
+
42
+ ```bash
43
+ npm login
44
+ ```
45
+
46
+ Enter username, password, and OTP if 2FA is enabled.
47
+
48
+ Verify:
49
+
50
+ ```bash
51
+ npm whoami
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Step 4 — Install dependencies & build
57
+
58
+ From the monorepo root:
59
+
60
+ ```bash
61
+ cd /home/marko-og/Documents/wappa/imperijal-components
62
+ pnpm install
63
+ pnpm build
64
+ ```
65
+
66
+ You should see `packages/date-time-picker/dist/` with `index.js`, `index.cjs`, and `index.d.ts`.
67
+
68
+ Dry-run typecheck:
69
+
70
+ ```bash
71
+ pnpm --filter @imperijal/date-time-picker typecheck
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Step 5 — Test locally in restoranico (before publishing)
77
+
78
+ Link the package without publishing:
79
+
80
+ ```bash
81
+ cd /home/marko-og/Documents/wappa/imperijal-components/packages/date-time-picker
82
+ pnpm link --global
83
+
84
+ cd /home/marko-og/Documents/wappa/restoranico
85
+ pnpm link --global @imperijal/date-time-picker
86
+ ```
87
+
88
+ In `restoranico`, change imports:
89
+
90
+ ```tsx
91
+ import { DateTimePicker, toLocalInputValue } from '@imperijal/date-time-picker';
92
+ ```
93
+
94
+ Install peer deps in restoranico if missing (most are already there).
95
+
96
+ When done testing, unlink:
97
+
98
+ ```bash
99
+ cd /home/marko-og/Documents/wappa/restoranico
100
+ pnpm unlink --global @imperijal/date-time-picker
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Step 6 — Publish to npm
106
+
107
+ **Important:** Do **not** run `npm publish` from the monorepo root (`imperijal-components/`).
108
+ The root is private and not a publishable package. You must publish **`@imperijal/date-time-picker`** only.
109
+
110
+ ### Option A — from package folder (recommended)
111
+
112
+ ```bash
113
+ cd /home/marko-og/Documents/wappa/imperijal-components/packages/date-time-picker
114
+ pnpm publish --access public
115
+ ```
116
+
117
+ ### Option B — from monorepo root
118
+
119
+ ```bash
120
+ cd /home/marko-og/Documents/wappa/imperijal-components
121
+ pnpm publish:date-time-picker
122
+ ```
123
+
124
+ When prompted for **OTP**, enter the 6-digit code from your authenticator app (required if 2FA is enabled).
125
+
126
+ > Scoped packages default to private. `--access public` is required for free public scoped packages.
127
+
128
+ First publish creates `@imperijal/date-time-picker@0.1.0` on npm.
129
+
130
+ ---
131
+
132
+ ## Fix E403 — Two-factor authentication required
133
+
134
+ If you see:
135
+
136
+ ```text
137
+ error code E403
138
+ error 403 Forbidden - PUT https://registry.npmjs.org/...
139
+ Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages.
140
+ ```
141
+
142
+ ### What it means
143
+
144
+ npm **requires 2FA on your account** before you can publish any package. This is a security policy — not a bug in your code.
145
+
146
+ Your log also showed:
147
+
148
+ ```text
149
+ verbose pkgid imperijal-components@0.0.0
150
+ ```
151
+
152
+ That means publish was attempted for the **wrong package** (monorepo root name). Fix both issues below.
153
+
154
+ ### Fix 1 — Enable 2FA on npm
155
+
156
+ 1. Log in at [npmjs.com](https://www.npmjs.com/)
157
+ 2. Click your avatar → **Account**
158
+ 3. Open **Enable 2FA** (or **Authentication**)
159
+ 4. Choose mode: **Authorization and publishing** (required for `npm publish`)
160
+ - "Authorization only" is **not** enough to publish
161
+ 5. Scan QR code with Google Authenticator / Authy / 1Password
162
+ 6. Save recovery codes
163
+
164
+ Then log in again locally:
165
+
166
+ ```bash
167
+ npm logout
168
+ npm login
169
+ # Enter username, password, then OTP when asked
170
+ npm whoami
171
+ ```
172
+
173
+ When you run `pnpm publish`, npm will ask for a **one-time password (OTP)** — enter the 6-digit code from your app.
174
+
175
+ ### Fix 2 — Publish the correct package
176
+
177
+ Root `package.json` must have `"private": true` (already fixed). Never publish:
178
+
179
+ | Wrong | Right |
180
+ |-------|-------|
181
+ | `imperijal-components@0.0.0` | `@imperijal/date-time-picker@0.1.0` |
182
+ | from repo root | from `packages/date-time-picker/` |
183
+
184
+ Verify before publish:
185
+
186
+ ```bash
187
+ cd packages/date-time-picker
188
+ node -p "require('./package.json').name"
189
+ # must print: @imperijal/date-time-picker
190
+ ```
191
+
192
+ ### Fix 3 — Own the `@imperijal` scope (if 403 persists)
193
+
194
+ If error says you don't have access to scope `@imperijal`:
195
+
196
+ 1. Create org at [npmjs.com/org/create](https://www.npmjs.com/org/create) named `imperijal`, **or**
197
+ 2. Rename package in `packages/date-time-picker/package.json`:
198
+
199
+ ```json
200
+ "name": "@YOUR_NPM_USERNAME/date-time-picker"
201
+ ```
202
+
203
+ ### Alternative — Granular access token (CI / automation)
204
+
205
+ For GitHub Actions instead of interactive OTP:
206
+
207
+ 1. [npmjs.com/settings/tokens](https://www.npmjs.com/settings/tokens) → **Generate New Token** → **Granular Access Token**
208
+ 2. Permissions: **Read and write** for packages
209
+ 3. Enable **Bypass 2FA** (only if your org policy allows)
210
+ 4. Use token:
211
+
212
+ ```bash
213
+ npm config set //registry.npmjs.org/:_authToken YOUR_TOKEN
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Step 7 — Install in restoranico from npm
219
+
220
+ After publishing:
221
+
222
+ ```bash
223
+ cd /home/marko-og/Documents/wappa/restoranico
224
+ pnpm add @imperijal/date-time-picker
225
+ ```
226
+
227
+ Usage:
228
+
229
+ ```tsx
230
+ import { DateTimePicker, toLocalInputValue } from '@imperijal/date-time-picker';
231
+ import '@imperijal/date-time-picker/styles.css'; // optional theme tokens
232
+ ```
233
+
234
+ ### Tailwind setup (required)
235
+
236
+ Add the package to Tailwind content scanning in your app:
237
+
238
+ ```js
239
+ // tailwind.config or @source in globals.css (Tailwind v4)
240
+ content: [
241
+ './src/**/*.{js,ts,jsx,tsx}',
242
+ './node_modules/@imperijal/date-time-picker/dist/**/*.js',
243
+ ]
244
+ ```
245
+
246
+ ---
247
+
248
+ ## Step 8 — Release updates
249
+
250
+ 1. Make changes in `packages/date-time-picker`
251
+ 2. Bump version:
252
+
253
+ ```bash
254
+ cd packages/date-time-picker
255
+ npm version patch # 0.1.0 → 0.1.1
256
+ # or: minor / major
257
+ ```
258
+
259
+ 3. Rebuild & publish:
260
+
261
+ ```bash
262
+ pnpm build
263
+ pnpm publish --access public
264
+ ```
265
+
266
+ 4. Update in restoranico:
267
+
268
+ ```bash
269
+ pnpm update @imperijal/date-time-picker
270
+ ```
271
+
272
+ ---
273
+
274
+ ## Checklist before first publish
275
+
276
+ - [ ] `repository.url` in `package.json` points to your real GitHub repo
277
+ - [ ] `pnpm build` succeeds
278
+ - [ ] `files` in package.json includes `dist` (already set)
279
+ - [ ] README describes peer dependencies
280
+ - [ ] npm login works (`npm whoami`)
281
+ - [ ] Package name `@imperijal/date-time-picker` is available (or rename)
282
+
283
+ ---
284
+
285
+ ## Troubleshooting
286
+
287
+ | Error | Fix |
288
+ |-------|-----|
289
+ | `E403` + 2FA message | Enable 2FA (Authorization **and publishing**) on npmjs.com — see [Fix E403](#fix-e403--two-factor-authentication-required) |
290
+ | `E403` wrong scope | Create `@imperijal` org or rename package to `@your-user/...` |
291
+ | Published `imperijal-components` by mistake | Root must be `"private": true`; publish from `packages/date-time-picker` |
292
+ | `402 Payment Required` on scoped package | Add `--access public` |
293
+ | Styles missing | Add Tailwind content path + shadcn CSS variables in app |
294
+ | `ERESOLVE` peer deps | Install listed peerDependencies in consumer app |
295
+
296
+ ---
297
+
298
+ ## Monorepo: adding package #2 later
299
+
300
+ ```bash
301
+ cp -r packages/date-time-picker packages/my-new-component
302
+ # edit package.json name → @imperijal/my-new-component
303
+ pnpm install
304
+ pnpm build
305
+ cd packages/my-new-component && pnpm publish --access public
306
+ ```
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # imperijal-components
2
+
3
+ Monorepo of reusable React UI packages published under the `@imperijal/*` scope.
4
+
5
+ ## Documentation
6
+
7
+ | Guide | Purpose |
8
+ |-------|---------|
9
+ | [**INSTALL_AND_USAGE.md**](./INSTALL_AND_USAGE.md) | Install in an app + component usage |
10
+ | [**PUBLISHING.md**](./PUBLISHING.md) | Publish to npm + fix E403 / 2FA errors |
11
+
12
+ ## Packages
13
+
14
+ | Package | Description |
15
+ |---------|-------------|
16
+ | [`@imperijal/date-time-picker`](./packages/date-time-picker) | Date & time picker (`YYYY-MM-DDTHH:mm`) |
17
+
18
+ ## Development
19
+
20
+ ```bash
21
+ pnpm install
22
+ pnpm build
23
+ ```
24
+
25
+ ## Adding a new component
26
+
27
+ ```bash
28
+ mkdir -p packages/my-component/src
29
+ # add package.json, tsconfig, tsup.config.ts
30
+ # register in pnpm-workspace.yaml (already uses packages/*)
31
+ ```
32
+
33
+ ## Publishing
34
+
35
+ See [PUBLISHING.md](./PUBLISHING.md). **Never** run `npm publish` from this root folder.
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "imperijal-components",
3
+ "private": false,
4
+ "version": "0.0.0",
5
+ "description": "Imperijal reusable React component packages (monorepo root — not published to npm)",
6
+ "keywords": [
7
+ "react",
8
+ "components",
9
+ "ui"
10
+ ],
11
+ "license": "MIT",
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "scripts": {
16
+ "build": "pnpm -r build",
17
+ "dev": "pnpm -r dev",
18
+ "lint": "pnpm -r lint",
19
+ "typecheck": "pnpm -r typecheck",
20
+ "publish:date-time-picker": "pnpm --filter @imperijal/date-time-picker publish --access public --no-git-checks"
21
+ }
22
+ }