@betterinternship/components 3.4.2 → 3.5.1

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 (87) hide show
  1. package/dist/components/autocomplete.d.ts +1 -2
  2. package/dist/components/autocomplete.js +75 -64
  3. package/dist/components/autocomplete.js.map +1 -1
  4. package/dist/components/checkbox-field.d.ts +18 -0
  5. package/dist/components/checkbox-field.js +25 -0
  6. package/dist/components/checkbox-field.js.map +1 -0
  7. package/dist/components/checkbox-group.d.ts +33 -0
  8. package/dist/components/checkbox-group.js +43 -0
  9. package/dist/components/checkbox-group.js.map +1 -0
  10. package/dist/components/checkbox.d.ts +1 -1
  11. package/dist/components/checkbox.js +6 -2
  12. package/dist/components/checkbox.js.map +1 -1
  13. package/dist/components/chip-select.d.ts +11 -2
  14. package/dist/components/chip-select.js +9 -4
  15. package/dist/components/chip-select.js.map +1 -1
  16. package/dist/components/{form-date-picker.d.ts → date-picker.d.ts} +11 -8
  17. package/dist/components/date-picker.js +57 -0
  18. package/dist/components/date-picker.js.map +1 -0
  19. package/dist/components/dropdown.js +7 -2
  20. package/dist/components/dropdown.js.map +1 -1
  21. package/dist/components/form-field.d.ts +60 -5
  22. package/dist/components/form-field.js +55 -5
  23. package/dist/components/form-field.js.map +1 -1
  24. package/dist/components/input.js +3 -1
  25. package/dist/components/input.js.map +1 -1
  26. package/dist/components/label.js +1 -1
  27. package/dist/components/label.js.map +1 -1
  28. package/dist/components/{form-month-picker.d.ts → month-picker.d.ts} +6 -6
  29. package/dist/components/month-picker.js +57 -0
  30. package/dist/components/month-picker.js.map +1 -0
  31. package/dist/components/radio-group.d.ts +11 -1
  32. package/dist/components/radio-group.js +17 -4
  33. package/dist/components/radio-group.js.map +1 -1
  34. package/dist/components/select.js +38 -2
  35. package/dist/components/select.js.map +1 -1
  36. package/dist/components/sheet.d.ts +1 -1
  37. package/dist/components/switch.d.ts +1 -1
  38. package/dist/components/switch.js +4 -1
  39. package/dist/components/switch.js.map +1 -1
  40. package/dist/components/table.js +5 -5
  41. package/dist/components/table.js.map +1 -1
  42. package/dist/components/textarea.d.ts +1 -1
  43. package/dist/components/textarea.js +3 -1
  44. package/dist/components/textarea.js.map +1 -1
  45. package/dist/components/time-input.d.ts +9 -0
  46. package/dist/components/time-input.js +65 -0
  47. package/dist/components/time-input.js.map +1 -0
  48. package/dist/design-tokens.d.ts +1 -1
  49. package/dist/hooks/use-field-focus.d.ts +1 -1
  50. package/dist/hooks/use-field-focus.js +1 -1
  51. package/dist/hooks/use-field-focus.js.map +1 -1
  52. package/dist/index.d.ts +5 -9
  53. package/dist/index.js +7 -11
  54. package/dist/index.js.map +1 -1
  55. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +54 -2
  56. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
  57. package/dist/utils.js +11 -1
  58. package/dist/utils.js.map +1 -1
  59. package/package.json +28 -40
  60. package/theme.css +3 -1
  61. package/dist/components/form-checkbox-group.d.ts +0 -31
  62. package/dist/components/form-checkbox-group.js +0 -30
  63. package/dist/components/form-checkbox-group.js.map +0 -1
  64. package/dist/components/form-checkbox.d.ts +0 -15
  65. package/dist/components/form-checkbox.js +0 -15
  66. package/dist/components/form-checkbox.js.map +0 -1
  67. package/dist/components/form-date-picker.js +0 -56
  68. package/dist/components/form-date-picker.js.map +0 -1
  69. package/dist/components/form-input.d.ts +0 -11
  70. package/dist/components/form-input.js +0 -13
  71. package/dist/components/form-input.js.map +0 -1
  72. package/dist/components/form-month-picker.js +0 -56
  73. package/dist/components/form-month-picker.js.map +0 -1
  74. package/dist/components/form-radio.d.ts +0 -15
  75. package/dist/components/form-radio.js +0 -20
  76. package/dist/components/form-radio.js.map +0 -1
  77. package/dist/components/form-textarea.d.ts +0 -11
  78. package/dist/components/form-textarea.js +0 -12
  79. package/dist/components/form-textarea.js.map +0 -1
  80. package/dist/components/form.d.ts +0 -24
  81. package/dist/components/form.js +0 -71
  82. package/dist/components/form.js.map +0 -1
  83. package/dist/components/time-input-native.d.ts +0 -14
  84. package/dist/components/time-input-native.js +0 -62
  85. package/dist/components/time-input-native.js.map +0 -1
  86. package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -706
  87. package/dist/node_modules/react-hook-form/dist/index.esm.js.map +0 -1
package/dist/utils.js CHANGED
@@ -1,6 +1,16 @@
1
1
  import { clsx } from './node_modules/clsx/dist/clsx.js';
2
- import { twMerge } from './node_modules/tailwind-merge/dist/bundle-mjs.js';
2
+ import { extendTailwindMerge } from './node_modules/tailwind-merge/dist/bundle-mjs.js';
3
3
 
4
+ // tailwind-merge only knows Tailwind's own font sizes. Without this it reads the
5
+ // theme's custom sizes (theme.css `--text-*`) as text colours and drops them when
6
+ // a colour class follows, e.g. field labels fell back to 16px instead of 14px.
7
+ const twMerge = extendTailwindMerge({
8
+ extend: {
9
+ classGroups: {
10
+ "font-size": [{ text: ["field-label", "page-heading"] }],
11
+ },
12
+ },
13
+ });
4
14
  function cn(...inputs) {
5
15
  return twMerge(clsx(inputs));
6
16
  }
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}"],"names":[],"mappings":";;;AAGM,SAAU,EAAE,CAAC,GAAG,MAAoB,EAAA;AACxC,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// tailwind-merge only knows Tailwind's own font sizes. Without this it reads the\n// theme's custom sizes (theme.css `--text-*`) as text colours and drops them when\n// a colour class follows, e.g. field labels fell back to 16px instead of 14px.\nconst twMerge = extendTailwindMerge({\n extend: {\n classGroups: {\n \"font-size\": [{ text: [\"field-label\", \"page-heading\"] }],\n },\n },\n});\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAClC,IAAA,MAAM,EAAE;AACN,QAAA,WAAW,EAAE;YACX,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC,EAAE,CAAC;AACzD,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEI,SAAU,EAAE,CAAC,GAAG,MAAoB,EAAA;AACxC,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterinternship/components",
3
- "version": "3.4.2",
3
+ "version": "3.5.1",
4
4
  "workspaces": [
5
5
  "playground"
6
6
  ],
@@ -13,8 +13,10 @@
13
13
  "theme.legacy.css"
14
14
  ],
15
15
  "scripts": {
16
- "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && npm run check:client && rollup -c rollup.config.mjs && tsc-alias",
16
+ "build": "npm run typecheck && npm run check:theme && node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && npm run check:client && rollup -c rollup.config.mjs && tsc-alias",
17
+ "typecheck": "tsc --noEmit -p tsconfig.json",
17
18
  "check:client": "node scripts/check-client-directives.mjs",
19
+ "check:theme": "node scripts/check-theme-tokens.mjs",
18
20
  "prepack": "npm run build",
19
21
  "dev:playground": "npm --prefix playground run dev"
20
22
  },
@@ -122,41 +124,25 @@
122
124
  "import": "./dist/components/form-field.js",
123
125
  "types": "./dist/components/form-field.d.ts"
124
126
  },
125
- "./form-input": {
126
- "import": "./dist/components/form-input.js",
127
- "types": "./dist/components/form-input.d.ts"
127
+ "./checkbox-group": {
128
+ "import": "./dist/components/checkbox-group.js",
129
+ "types": "./dist/components/checkbox-group.d.ts"
128
130
  },
129
- "./form-textarea": {
130
- "import": "./dist/components/form-textarea.js",
131
- "types": "./dist/components/form-textarea.d.ts"
131
+ "./checkbox-field": {
132
+ "import": "./dist/components/checkbox-field.js",
133
+ "types": "./dist/components/checkbox-field.d.ts"
132
134
  },
133
- "./form-checkbox": {
134
- "import": "./dist/components/form-checkbox.js",
135
- "types": "./dist/components/form-checkbox.d.ts"
135
+ "./date-picker": {
136
+ "import": "./dist/components/date-picker.js",
137
+ "types": "./dist/components/date-picker.d.ts"
136
138
  },
137
- "./form-checkbox-group": {
138
- "import": "./dist/components/form-checkbox-group.js",
139
- "types": "./dist/components/form-checkbox-group.d.ts"
139
+ "./month-picker": {
140
+ "import": "./dist/components/month-picker.js",
141
+ "types": "./dist/components/month-picker.d.ts"
140
142
  },
141
- "./form-radio": {
142
- "import": "./dist/components/form-radio.js",
143
- "types": "./dist/components/form-radio.d.ts"
144
- },
145
- "./form-date-picker": {
146
- "import": "./dist/components/form-date-picker.js",
147
- "types": "./dist/components/form-date-picker.d.ts"
148
- },
149
- "./form-month-picker": {
150
- "import": "./dist/components/form-month-picker.js",
151
- "types": "./dist/components/form-month-picker.d.ts"
152
- },
153
- "./time-input-native": {
154
- "import": "./dist/components/time-input-native.js",
155
- "types": "./dist/components/time-input-native.d.ts"
156
- },
157
- "./form": {
158
- "import": "./dist/components/form.js",
159
- "types": "./dist/components/form.d.ts"
143
+ "./time-input": {
144
+ "import": "./dist/components/time-input.js",
145
+ "types": "./dist/components/time-input.d.ts"
160
146
  },
161
147
  "./input-otp": {
162
148
  "import": "./dist/components/input-otp.js",
@@ -170,6 +156,10 @@
170
156
  "import": "./dist/components/chip-select.js",
171
157
  "types": "./dist/components/chip-select.d.ts"
172
158
  },
159
+ "./dropdown": {
160
+ "import": "./dist/components/dropdown.js",
161
+ "types": "./dist/components/dropdown.d.ts"
162
+ },
173
163
  "./sheet": {
174
164
  "import": "./dist/components/sheet.js",
175
165
  "types": "./dist/components/sheet.d.ts"
@@ -231,7 +221,7 @@
231
221
  "@radix-ui/react-tooltip": "^1.2.7",
232
222
  "@tanstack/react-query": "^5.0.0",
233
223
  "lucide-react": ">=0.454.0",
234
- "next": "^16.3.1",
224
+ "next": "^15.5.0 || ^16.3.1",
235
225
  "react": "^19",
236
226
  "react-dom": "^19",
237
227
  "sonner": "^2.0.7"
@@ -303,7 +293,6 @@
303
293
  "react-datepicker": "^9.1.0",
304
294
  "react-day-picker": "^10.0.2",
305
295
  "react-dom": "^19",
306
- "react-hook-form": "^7.91.0",
307
296
  "rollup": "^4.53.3",
308
297
  "rollup-plugin-postcss": "^4.0.2",
309
298
  "rollup-plugin-preserve-directives": "^0.4.0",
@@ -316,15 +305,14 @@
316
305
  "typescript-eslint": "^8.20.0"
317
306
  },
318
307
  "dependencies": {
319
- "framer-motion": "^13.1.1",
320
308
  "@daypicker/react": "^10.0.1",
321
309
  "@types/react-dom": "^19.2.4",
322
310
  "class-variance-authority": "^0.7.1",
323
311
  "clsx": "^2.1.1",
324
- "lucide-react": ">=0.454.0",
325
- "tailwind-merge": "^3.4.0",
326
- "react-hook-form": "^7.91.0",
312
+ "embla-carousel-react": "^8.6.0",
313
+ "framer-motion": "^13.1.1",
327
314
  "input-otp": "^1.5.0",
328
- "embla-carousel-react": "^8.6.0"
315
+ "lucide-react": ">=0.454.0",
316
+ "tailwind-merge": "^3.4.0"
329
317
  }
330
318
  }
package/theme.css CHANGED
@@ -140,7 +140,9 @@
140
140
  --text-field-label: var(--text-sm);
141
141
  --text-field-label--line-height: var(--text-sm--line-height);
142
142
  --font-weight-field-label: 500;
143
- --color-field-label: var(--muted-foreground);
143
+ /* Named -foreground, not field-label: a --color-field-label would make
144
+ `text-field-label` a colour class and hide the label size. */
145
+ --color-label-foreground: var(--muted-foreground);
144
146
 
145
147
  /* Shared radius scale. Keep component rounding on this scale. */
146
148
  --radius-control-sm: 0.375rem;
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- export interface FormCheckBoxGroupProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onToggle'> {
3
- options: {
4
- value: string | number;
5
- label: string;
6
- description?: string;
7
- }[];
8
- values: (string | number)[];
9
- setter: (values: (string | number)[]) => void;
10
- label?: string;
11
- required?: boolean;
12
- className?: string;
13
- tooltip?: string;
14
- tooltipId?: string;
15
- /** Multi-select hint shown above the options. Pass `null` to hide it. */
16
- hint?: React.ReactNode;
17
- /**
18
- * Whether the "N selected" count renders in its own row above the
19
- * options. Defaults to true. Set to false when the count is shown
20
- * elsewhere instead (e.g. via `labelAddon`) — otherwise selecting the
21
- * first option inserts this row and shifts the options below it.
22
- */
23
- showSelectedCount?: boolean;
24
- /** Rendered to the right of the label, on the label's own row. */
25
- labelAddon?: React.ReactNode;
26
- /** Columns on md+ screens. Defaults to 3. */
27
- columns?: 1 | 2 | 3;
28
- /** Fired when a single option is toggled, before the setter runs. */
29
- onToggle?: (value: string | number, checked: boolean) => void;
30
- }
31
- export declare const FormCheckBoxGroup: ({ options, values, setter, label, required, className, tooltip, tooltipId, hint, showSelectedCount, labelAddon, columns, onToggle, }: FormCheckBoxGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,30 +0,0 @@
1
- "use client";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { cn } from '../utils.js';
4
- import { AnimatedCount } from './animated-count.js';
5
- import { FormCheckbox } from './form-checkbox.js';
6
- import { FormField } from './form-field.js';
7
-
8
- const GRID_COLS = {
9
- 1: '',
10
- 2: 'md:grid-cols-2',
11
- 3: 'md:grid-cols-3',
12
- };
13
- const FormCheckBoxGroup = ({ options, values, setter, label, required = false, className, tooltip, tooltipId, hint = null, showSelectedCount = true, labelAddon, columns = 3, onToggle, }) => {
14
- const handleValueChange = (optionValue) => {
15
- const willBeChecked = !values.includes(optionValue);
16
- onToggle?.(optionValue, willBeChecked);
17
- setter(willBeChecked
18
- ? [...values, optionValue]
19
- : values.filter((v) => v !== optionValue));
20
- };
21
- return (jsxs(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, labelAddon: labelAddon, className: className, children: [(hint || (showSelectedCount && values.length > 0)) && (jsxs("div", { className: "flex items-center gap-2 text-xs", children: [hint && (jsx("span", { className: "text-muted-foreground text-xs", children: hint })), showSelectedCount && values.length > 0 && (jsxs("span", { className: "text-primary font-medium", children: [jsx(AnimatedCount, { value: values.length }), " selected"] }))] })), jsx("div", { className: cn('grid grid-cols-1 gap-4', GRID_COLS[columns]), children: options.map((option) => {
22
- const isChecked = values.includes(option.value);
23
- return (jsxs("div", { role: "checkbox", "aria-checked": isChecked, onClick: () => handleValueChange(option.value), className: cn('group flex h-fit cursor-pointer items-start gap-3 rounded-control-lg border p-3 transition-colors duration-state ease-out-strong focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-ring motion-reduce:transition-none [&>div]:pointer-events-none', isChecked
24
- ? 'border-primary bg-primary-selected'
25
- : 'border-border hover:border-input hover:bg-muted'), children: [jsx(FormCheckbox, { className: "pointer-events-none pt-0.5", checked: isChecked ?? false }), jsxs("div", { className: "min-w-0 flex-1 space-y-1 pt-0.5", children: [jsx("span", { className: "block text-field-label font-field-label text-[color:var(--color-field-label)]", children: option.label }), option.description && (jsx("p", { className: "text-sm text-muted-foreground", children: option.description }))] })] }, option.value));
26
- }) })] }));
27
- };
28
-
29
- export { FormCheckBoxGroup };
30
- //# sourceMappingURL=form-checkbox-group.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-checkbox-group.js","sources":["../../src/components/form-checkbox-group.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { AnimatedCount } from '@/components/animated-count';\r\nimport { FormCheckbox } from './form-checkbox';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormCheckBoxGroupProps extends Omit<\r\n React.InputHTMLAttributes<HTMLInputElement>,\r\n 'onToggle'\r\n> {\r\n options: { value: string | number; label: string; description?: string }[];\r\n values: (string | number)[];\r\n setter: (values: (string | number)[]) => void;\r\n label?: string;\r\n required?: boolean;\r\n className?: string;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n /** Multi-select hint shown above the options. Pass `null` to hide it. */\r\n hint?: React.ReactNode;\r\n /**\r\n * Whether the \"N selected\" count renders in its own row above the\r\n * options. Defaults to true. Set to false when the count is shown\r\n * elsewhere instead (e.g. via `labelAddon`) — otherwise selecting the\r\n * first option inserts this row and shifts the options below it.\r\n */\r\n showSelectedCount?: boolean;\r\n /** Rendered to the right of the label, on the label's own row. */\r\n labelAddon?: React.ReactNode;\r\n /** Columns on md+ screens. Defaults to 3. */\r\n columns?: 1 | 2 | 3;\r\n /** Fired when a single option is toggled, before the setter runs. */\r\n onToggle?: (value: string | number, checked: boolean) => void;\r\n}\r\n\r\nconst GRID_COLS: Record<1 | 2 | 3, string> = {\r\n 1: '',\r\n 2: 'md:grid-cols-2',\r\n 3: 'md:grid-cols-3',\r\n};\r\n\r\nexport const FormCheckBoxGroup = ({\r\n options,\r\n values,\r\n setter,\r\n label,\r\n required = false,\r\n className,\r\n tooltip,\r\n tooltipId,\r\n hint = null,\r\n showSelectedCount = true,\r\n labelAddon,\r\n columns = 3,\r\n onToggle,\r\n}: FormCheckBoxGroupProps) => {\r\n const handleValueChange = (optionValue: string | number) => {\r\n const willBeChecked = !values.includes(optionValue);\r\n onToggle?.(optionValue, willBeChecked);\r\n setter(\r\n willBeChecked\r\n ? [...values, optionValue]\r\n : values.filter((v) => v !== optionValue),\r\n );\r\n };\r\n\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n labelAddon={labelAddon}\r\n className={className}\r\n >\r\n {(hint || (showSelectedCount && values.length > 0)) && (\r\n <div className=\"flex items-center gap-2 text-xs\">\r\n {hint && (\r\n <span className=\"text-muted-foreground text-xs\">{hint}</span>\r\n )}\r\n {showSelectedCount && values.length > 0 && (\r\n <span className=\"text-primary font-medium\">\r\n <AnimatedCount value={values.length} /> selected\r\n </span>\r\n )}\r\n </div>\r\n )}\r\n\r\n <div className={cn('grid grid-cols-1 gap-4', GRID_COLS[columns])}>\r\n {options.map((option) => {\r\n const isChecked = values.includes(option.value);\r\n\r\n return (\r\n <div\r\n key={option.value}\r\n role=\"checkbox\"\r\n aria-checked={isChecked}\r\n onClick={() => handleValueChange(option.value)}\r\n className={cn(\r\n 'group flex h-fit cursor-pointer items-start gap-3 rounded-control-lg border p-3 transition-colors duration-state ease-out-strong focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-ring motion-reduce:transition-none [&>div]:pointer-events-none',\r\n isChecked\r\n ? 'border-primary bg-primary-selected'\r\n : 'border-border hover:border-input hover:bg-muted',\r\n )}\r\n >\r\n <FormCheckbox\r\n className=\"pointer-events-none pt-0.5\"\r\n checked={isChecked ?? false}\r\n />\r\n <div className=\"min-w-0 flex-1 space-y-1 pt-0.5\">\r\n <span className=\"block text-field-label font-field-label text-[color:var(--color-field-label)]\">\r\n {option.label}\r\n </span>\r\n {option.description && (\r\n <p className=\"text-sm text-muted-foreground\">{option.description}</p>\r\n )}\r\n </div>\r\n </div>\r\n );\r\n })}\r\n </div>\r\n </FormField>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;;AAsCA;AACE;AACA;AACA;;AAGK;AAeL;;AAEE;AACA;AAEI;AACA;AAEN;;;;AAqCgB;;AAkBV;AAIR;;"}
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- export interface FormCheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
- checked?: boolean;
4
- indeterminate?: boolean;
5
- label?: string;
6
- setter?: (value: boolean) => void;
7
- className?: string;
8
- sentence?: React.ReactNode;
9
- required?: boolean;
10
- tooltip?: string;
11
- tooltipId?: string;
12
- labelAddon?: React.ReactNode;
13
- }
14
- /** A labelled Checkbox; the box itself is styled by the Checkbox primitive. */
15
- export declare const FormCheckbox: ({ label, checked, indeterminate, setter, className, sentence, required, tooltip, tooltipId, labelAddon, id, disabled, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, }: FormCheckboxProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { cn } from '../utils.js';
4
- import { Checkbox } from './checkbox.js';
5
- import { FormField } from './form-field.js';
6
-
7
- /** A labelled Checkbox; the box itself is styled by the Checkbox primitive. */
8
- const FormCheckbox = ({ label, checked, indeterminate, setter, className, sentence, required, tooltip, tooltipId, labelAddon, id, disabled, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) => {
9
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, labelAddon: labelAddon, className: className, children: jsxs("div", { className: "flex gap-2 sm:items-center", children: [jsx(Checkbox, { id: id, disabled: disabled, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, name: label ?? '', checked: indeterminate ? 'indeterminate' : checked,
10
- // Larger tap target on mobile.
11
- className: cn('size-6 sm:size-5'), onCheckedChange: (next) => setter && setter(!!next) }), sentence && (jsx("div", { className: "text-muted-foreground cursor-pointer text-sm select-none", onClick: () => setter?.(!checked), role: "button", children: sentence }))] }) }));
12
- };
13
-
14
- export { FormCheckbox };
15
- //# sourceMappingURL=form-checkbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-checkbox.js","sources":["../../src/components/form-checkbox.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { Checkbox } from '@/components/checkbox';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormCheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {\r\n checked?: boolean;\r\n indeterminate?: boolean;\r\n label?: string;\r\n setter?: (value: boolean) => void;\r\n className?: string;\r\n sentence?: React.ReactNode;\r\n required?: boolean;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n labelAddon?: React.ReactNode;\r\n}\r\n\r\n/** A labelled Checkbox; the box itself is styled by the Checkbox primitive. */\r\nexport const FormCheckbox = ({\r\n label,\r\n checked,\r\n indeterminate,\r\n setter,\r\n className,\r\n sentence,\r\n required,\r\n tooltip,\r\n tooltipId,\r\n labelAddon,\r\n id,\r\n disabled,\r\n 'aria-label': ariaLabel,\r\n 'aria-describedby': ariaDescribedBy,\r\n}: FormCheckboxProps) => {\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n labelAddon={labelAddon}\r\n className={className}\r\n >\r\n <div className=\"flex gap-2 sm:items-center\">\r\n <Checkbox\r\n id={id}\r\n disabled={disabled}\r\n aria-label={ariaLabel}\r\n aria-describedby={ariaDescribedBy}\r\n name={label ?? ''}\r\n checked={indeterminate ? 'indeterminate' : checked}\r\n // Larger tap target on mobile.\r\n className={cn('size-6 sm:size-5')}\r\n onCheckedChange={(next) => setter && setter(!!next)}\r\n />\r\n {sentence && (\r\n <div\r\n className=\"text-muted-foreground cursor-pointer text-sm select-none\"\r\n onClick={() => setter?.(!checked)}\r\n role=\"button\"\r\n >\r\n {sentence}\r\n </div>\r\n )}\r\n </div>\r\n </FormField>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;AAqBA;AACO;AAgBL;;;AAiCF;;"}
@@ -1,56 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import * as React from 'react';
4
- import { CalendarDays, X } from 'lucide-react';
5
- import { cn } from '../utils.js';
6
- import { fieldTriggerClassName } from '../hooks/use-field-focus.js';
7
- import { Button } from './button.js';
8
- import { Calendar } from './calendar.js';
9
- import { Popover, PopoverTrigger, PopoverContent } from './popover.js';
10
- import { FormField } from './form-field.js';
11
-
12
- const FormDatePicker = ({ mode = 'single', dates, onDatesChange, range, onRangeChange, label, date, setter, className, side = 'bottom', align = 'start', sideOffset = 6, contentClassName, captionLayout = 'dropdown', disabledDays, allowedDates, autoClose = true, placeholder = 'Select date', format = (d) => d.toLocaleDateString(), required = false, tooltip, tooltipId, labelAddon, ...props }) => {
13
- const [open, setOpen] = React.useState(false);
14
- const selected = date != null && date > 86400000 ? new Date(date) : undefined;
15
- const selectedRange = range ? { from: range.from != null ? new Date(range.from) : undefined, to: range.to != null ? new Date(range.to) : undefined } : undefined;
16
- if (mode === 'multiple')
17
- return jsx(FormDateMultiPicker, { label: label, dates: dates, setter: onDatesChange, className: className, contentClassName: contentClassName, required: required, tooltip: tooltip, labelAddon: labelAddon, allowedDates: allowedDates, disabledDays: disabledDays });
18
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, labelAddon: labelAddon, className: cn('flex flex-col', className), children: jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { variant: "outline", id: props.id ?? 'date', className: cn("w-full justify-between px-field-padding-x py-0", fieldTriggerClassName), children: [mode === 'range' && selectedRange?.from ? `${format(selectedRange.from)}${selectedRange.to ? ` – ${format(selectedRange.to)}` : ' – …'}` : selected ? format(selected) : jsx("span", { className: "text-muted-foreground/40", children: placeholder }), jsx(CalendarDays, { className: "h-4 w-4 text-muted-foreground" })] }) }), jsx(PopoverContent, { align: align, side: side, sideOffset: sideOffset, className: cn('w-auto overflow-hidden p-0', contentClassName), children: mode === 'range' ? jsx(Calendar, { mode: "range", selected: selectedRange, captionLayout: captionLayout === 'buttons' ? 'label' : captionLayout, disabled: disabledDays, allowedDates: allowedDates, excludeDisabled: true, onSelect: (next) => {
19
- onRangeChange?.(next ? { from: next.from?.getTime(), to: next.to?.getTime() } : undefined);
20
- // Range selection stays open so the user can adjust both ends,
21
- // matching multiple-date selection behavior.
22
- } }) : jsx(Calendar, { mode: "single", selected: selected, captionLayout: captionLayout === 'buttons' ? 'label' : captionLayout, disabled: disabledDays, allowedDates: allowedDates, onSelect: (d) => {
23
- setter?.(d ? d.getTime() : undefined);
24
- if (autoClose)
25
- setOpen(false);
26
- } }) })] }) }));
27
- };
28
- const FormDateMultiPicker = ({ label, dates = [], setter, className, contentClassName, required = false, tooltip, labelAddon, allowedDates, disabledDays, }) => {
29
- const [open, setOpen] = React.useState(false);
30
- const selected = dates
31
- .filter((value) => Number.isFinite(value))
32
- .map((value) => {
33
- const parts = new Intl.DateTimeFormat('en-US', {
34
- timeZone: 'Asia/Manila',
35
- year: 'numeric',
36
- month: 'numeric',
37
- day: 'numeric',
38
- }).formatToParts(new Date(value));
39
- const get = (type) => Number(parts.find((part) => part.type === type)?.value);
40
- return new Date(get('year'), get('month') - 1, get('day'));
41
- });
42
- const toManilaTimestamp = (date) => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) -
43
- 8 * 60 * 60 * 1000;
44
- return (jsxs(FormField, { label: label, required: required, tooltip: tooltip, labelAddon: labelAddon, className: cn('flex flex-col', className), children: [jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { variant: "outline", className: cn("w-full justify-between px-field-padding-x py-0", fieldTriggerClassName), children: [selected.length
45
- ? `${selected.length} date${selected.length === 1 ? '' : 's'} selected`
46
- : 'Select dates', jsx(CalendarDays, { className: "h-4 w-4 text-muted-foreground" })] }) }), jsx(PopoverContent, { align: "start", sideOffset: 6, className: cn('w-auto overflow-hidden p-0', contentClassName), children: jsx(Calendar, { mode: "multiple", captionLayout: "label", allowedDates: allowedDates, disabled: disabledDays, selected: selected, onSelect: (next) => setter?.((next ?? []).map(toManilaTimestamp).sort((a, b) => a - b)) }) })] }), !!selected.length && (jsx("div", { className: "flex flex-wrap gap-1.5", children: selected.map((date) => (jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "h-7 gap-1 px-2 text-xs", onClick: () => setter?.(selected
47
- .filter((selectedDate) => selectedDate.getTime() !== date.getTime())
48
- .map(toManilaTimestamp)), children: [date.toLocaleDateString(undefined, {
49
- month: 'short',
50
- day: 'numeric',
51
- year: 'numeric',
52
- }), jsx(X, { className: "h-3 w-3" }), jsxs("span", { className: "sr-only", children: ["Remove ", date.toLocaleDateString()] })] }, date.getTime()))) }))] }));
53
- };
54
-
55
- export { FormDatePicker };
56
- //# sourceMappingURL=form-date-picker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-date-picker.js","sources":["../../src/components/form-date-picker.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport type { Matcher } from '@daypicker/react';\r\nimport { CalendarDays, X } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { fieldTriggerClassName } from '@/hooks/use-field-focus';\r\nimport { Button } from '@/components/button';\r\nimport { Calendar } from '@/components/calendar';\r\nimport {\r\n Popover,\r\n PopoverContent,\r\n PopoverTrigger,\r\n} from '@/components/popover';\r\nimport { FormField } from './form-field';\r\n\r\n/**\r\n * Accepts/returns a number timestamp (ms) via `date` / `setter`.\r\n */\r\nexport interface FormDatePickerProps extends React.InputHTMLAttributes<HTMLInputElement> {\r\n mode?: 'single' | 'multiple' | 'range';\r\n dates?: number[];\r\n onDatesChange?: (dates: number[]) => void;\r\n range?: { from?: number; to?: number };\r\n onRangeChange?: (range: { from?: number; to?: number } | undefined) => void;\r\n label?: string;\r\n date?: number;\r\n setter?: (value?: number) => void;\r\n className?: string;\r\n side?: 'top' | 'right' | 'bottom' | 'left';\r\n align?: 'start' | 'center' | 'end';\r\n sideOffset?: number;\r\n contentClassName?: string;\r\n /** 'buttons' is the old name for DayPicker's 'label' layout. */\r\n captionLayout?: 'buttons' | 'label' | 'dropdown';\r\n required?: boolean;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n labelAddon?: React.ReactNode;\r\n\r\n /** Optional: disable dates (react-day-picker style) */\r\n disabledDays?:\r\n | Date\r\n | { before?: Date; after?: Date; from?: Date; to?: Date }\r\n | Date[];\r\n /** Only these local calendar dates can be selected. */\r\n allowedDates?: Date[];\r\n\r\n /** Close popover automatically on select (default true) */\r\n autoClose?: boolean;\r\n\r\n /** Placeholder text when no date selected */\r\n placeholder?: string;\r\n\r\n /** Format the button text */\r\n format?: (d: Date) => string;\r\n}\r\n\r\nexport const FormDatePicker = ({\r\n mode = 'single',\r\n dates,\r\n onDatesChange,\r\n range,\r\n onRangeChange,\r\n label,\r\n date,\r\n setter,\r\n className,\r\n side = 'bottom',\r\n align = 'start',\r\n sideOffset = 6,\r\n contentClassName,\r\n captionLayout = 'dropdown',\r\n disabledDays,\r\n allowedDates,\r\n autoClose = true,\r\n placeholder = 'Select date',\r\n format = (d) => d.toLocaleDateString(),\r\n required = false,\r\n tooltip,\r\n tooltipId,\r\n labelAddon,\r\n ...props\r\n}: FormDatePickerProps) => {\r\n const [open, setOpen] = React.useState(false);\r\n const selected = date != null && date > 86400000 ? new Date(date) : undefined;\r\n const selectedRange = range ? { from: range.from != null ? new Date(range.from) : undefined, to: range.to != null ? new Date(range.to) : undefined } : undefined;\r\n\r\n if (mode === 'multiple') return <FormDateMultiPicker label={label} dates={dates} setter={onDatesChange} className={className} contentClassName={contentClassName} required={required} tooltip={tooltip} labelAddon={labelAddon} allowedDates={allowedDates} disabledDays={disabledDays as Matcher | Matcher[]} />;\r\n\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n labelAddon={labelAddon}\r\n className={cn('flex flex-col', className)}\r\n >\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"outline\"\r\n id={props.id ?? 'date'}\r\n className={cn(\"w-full justify-between px-field-padding-x py-0\", fieldTriggerClassName)}\r\n >\r\n {mode === 'range' && selectedRange?.from ? `${format(selectedRange.from)}${selectedRange.to ? ` – ${format(selectedRange.to)}` : ' – …'}` : selected ? format(selected) : <span className=\"text-muted-foreground/40\">{placeholder}</span>}\r\n <CalendarDays className=\"h-4 w-4 text-muted-foreground\" />\r\n </Button>\r\n </PopoverTrigger>\r\n\r\n <PopoverContent\r\n align={align}\r\n side={side}\r\n sideOffset={sideOffset}\r\n className={cn(\r\n 'w-auto overflow-hidden p-0',\r\n contentClassName,\r\n )}\r\n >\r\n {mode === 'range' ? <Calendar\r\n mode=\"range\"\r\n selected={selectedRange}\r\n captionLayout={captionLayout === 'buttons' ? 'label' : captionLayout}\r\n disabled={disabledDays as Matcher[]}\r\n allowedDates={allowedDates}\r\n excludeDisabled\r\n onSelect={(next) => {\r\n onRangeChange?.(next ? { from: next.from?.getTime(), to: next.to?.getTime() } : undefined);\r\n // Range selection stays open so the user can adjust both ends,\r\n // matching multiple-date selection behavior.\r\n }}\r\n /> : <Calendar\r\n mode=\"single\"\r\n selected={selected}\r\n captionLayout={\r\n captionLayout === 'buttons' ? 'label' : captionLayout\r\n }\r\n disabled={disabledDays as Matcher[]}\r\n allowedDates={allowedDates}\r\n onSelect={(d) => {\r\n setter?.(d ? d.getTime() : undefined);\r\n if (autoClose) setOpen(false);\r\n }}\r\n />}\r\n </PopoverContent>\r\n </Popover>\r\n </FormField>\r\n );\r\n};\r\n\r\ninterface FormDateMultiPickerProps {\r\n label?: string;\r\n dates?: number[];\r\n setter?: (value: number[]) => void;\r\n className?: string;\r\n contentClassName?: string;\r\n required?: boolean;\r\n tooltip?: string;\r\n labelAddon?: React.ReactNode;\r\n /** Only these local calendar dates can be selected. */\r\n allowedDates?: Date[];\r\n disabledDays?: Matcher | Matcher[];\r\n}\r\n\r\nconst FormDateMultiPicker = ({\r\n label,\r\n dates = [],\r\n setter,\r\n className,\r\n contentClassName,\r\n required = false,\r\n tooltip,\r\n labelAddon,\r\n allowedDates,\r\n disabledDays,\r\n}: FormDateMultiPickerProps) => {\r\n const [open, setOpen] = React.useState(false);\r\n const selected = dates\r\n .filter((value) => Number.isFinite(value))\r\n .map((value) => {\r\n const parts = new Intl.DateTimeFormat('en-US', {\r\n timeZone: 'Asia/Manila',\r\n year: 'numeric',\r\n month: 'numeric',\r\n day: 'numeric',\r\n }).formatToParts(new Date(value));\r\n const get = (type: string) =>\r\n Number(parts.find((part) => part.type === type)?.value);\r\n return new Date(get('year'), get('month') - 1, get('day'));\r\n });\r\n const toManilaTimestamp = (date: Date) =>\r\n Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) -\r\n 8 * 60 * 60 * 1000;\r\n\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n labelAddon={labelAddon}\r\n className={cn('flex flex-col', className)}\r\n >\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"outline\"\r\n className={cn(\"w-full justify-between px-field-padding-x py-0\", fieldTriggerClassName)}\r\n >\r\n {selected.length\r\n ? `${selected.length} date${selected.length === 1 ? '' : 's'} selected`\r\n : 'Select dates'}\r\n <CalendarDays className=\"h-4 w-4 text-muted-foreground\" />\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent\r\n align=\"start\"\r\n sideOffset={6}\r\n className={cn(\r\n 'w-auto overflow-hidden p-0',\r\n contentClassName,\r\n )}\r\n >\r\n <Calendar\r\n mode=\"multiple\"\r\n captionLayout=\"label\"\r\n allowedDates={allowedDates}\r\n disabled={disabledDays}\r\n selected={selected}\r\n onSelect={(next) =>\r\n setter?.(\r\n (next ?? []).map(toManilaTimestamp).sort((a, b) => a - b),\r\n )\r\n }\r\n />\r\n </PopoverContent>\r\n </Popover>\r\n {!!selected.length && (\r\n <div className=\"flex flex-wrap gap-1.5\">\r\n {selected.map((date) => (\r\n <Button\r\n key={date.getTime()}\r\n type=\"button\"\r\n variant=\"outline\"\r\n size=\"sm\"\r\n className=\"h-7 gap-1 px-2 text-xs\"\r\n onClick={() =>\r\n setter?.(\r\n selected\r\n .filter(\r\n (selectedDate) =>\r\n selectedDate.getTime() !== date.getTime(),\r\n )\r\n .map(toManilaTimestamp),\r\n )\r\n }\r\n >\r\n {date.toLocaleDateString(undefined, {\r\n month: 'short',\r\n day: 'numeric',\r\n year: 'numeric',\r\n })}\r\n <X className=\"h-3 w-3\" />\r\n <span className=\"sr-only\">\r\n Remove {date.toLocaleDateString()}\r\n </span>\r\n </Button>\r\n ))}\r\n </div>\r\n )}\r\n </FormField>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;AA2DO;AA0BL;;;;AAIyB;;AAwCb;;;AAGF;AAUE;AACA;;AACF;AAMZ;AAgBA;AAYE;;AAEG;AACA;;AAEG;AACA;AACA;AACA;;;;AAKJ;;AAGA;AAEF;AAeY;AACC;AAsCM;;AASL;AACA;AACA;AACD;AAWf;;"}
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- export interface FormInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
- label?: string;
4
- setter?: (value: string) => void;
5
- required?: boolean;
6
- className?: string;
7
- tooltip?: string;
8
- tooltipId?: string;
9
- labelAddon?: React.ReactNode;
10
- }
11
- export declare const FormInput: React.ForwardRefExoticComponent<FormInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { jsx } from 'react/jsx-runtime';
3
- import * as React from 'react';
4
- import { cn } from '../utils.js';
5
- import { Input } from './input.js';
6
- import { FormField } from './form-field.js';
7
-
8
- const FormInput = React.forwardRef(function FormInput({ label, value, setter, required = true, className, tooltip, tooltipId, labelAddon, ...props }, ref) {
9
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, labelAddon: labelAddon, children: jsx(Input, { ref: ref, value: value ?? '', onChange: (e) => setter && setter(e.target.value), className: cn(className), ...props }) }));
10
- });
11
-
12
- export { FormInput };
13
- //# sourceMappingURL=form-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-input.js","sources":["../../src/components/form-input.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { Input } from '@/components/input';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormInputProps extends React.InputHTMLAttributes<HTMLInputElement> {\r\n label?: string;\r\n setter?: (value: string) => void;\r\n required?: boolean;\r\n className?: string;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n labelAddon?: React.ReactNode;\r\n}\r\n\r\nexport const FormInput = React.forwardRef<HTMLInputElement, FormInputProps>(\r\n function FormInput(\r\n {\r\n label,\r\n value,\r\n setter,\r\n required = true,\r\n className,\r\n tooltip,\r\n tooltipId,\r\n labelAddon,\r\n ...props\r\n },\r\n ref,\r\n ) {\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n labelAddon={labelAddon}\r\n >\r\n <Input\r\n ref={ref}\r\n value={value ?? ''}\r\n onChange={(e) => setter && setter(e.target.value)}\r\n className={cn(className)}\r\n {...props}\r\n />\r\n </FormField>\r\n );\r\n },\r\n);\r\n"],"names":[],"mappings":";;;;;;;AAkBO;AAeH;AAiBF;;"}
@@ -1,56 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import * as React from 'react';
4
- import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';
5
- import { cn } from '../utils.js';
6
- import { fieldTriggerClassName } from '../hooks/use-field-focus.js';
7
- import { Button } from './button.js';
8
- import { Popover, PopoverTrigger, PopoverContent } from './popover.js';
9
- import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from './select.js';
10
- import { FormField } from './form-field.js';
11
-
12
- const FormMonthPicker = ({ label, date, setter, className, side = 'bottom', align = 'start', sideOffset = 6, contentClassName, placeholder = 'Select month', format = (d) => d.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }), fromYear = new Date().getFullYear() - 5, toYear = new Date().getFullYear() + 5, autoClose = true, tooltip, tooltipId, required = false, ...props }) => {
13
- const [open, setOpen] = React.useState(false);
14
- // normalize incoming ms -> first day of month
15
- const selected = React.useMemo(() => {
16
- if (date == null)
17
- return undefined;
18
- const d = new Date(date);
19
- return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);
20
- }, [date]);
21
- const [viewYear, setViewYear] = React.useState(selected?.getFullYear() ?? new Date().getFullYear());
22
- React.useEffect(() => {
23
- if (selected)
24
- setViewYear(selected.getFullYear());
25
- }, [selected]);
26
- const months = React.useMemo(() => Array.from({ length: 12 }, (_, m) => ({
27
- m,
28
- label: new Date(2000, m, 1).toLocaleString(undefined, {
29
- month: 'short',
30
- }),
31
- })), []);
32
- const clampYear = (y) => Math.min(Math.max(y, fromYear), toYear);
33
- const selectMonth = (monthIndex) => {
34
- const y = clampYear(viewYear);
35
- const firstOfMonth = new Date(y, monthIndex, 1, 0, 0, 0, 0).getTime();
36
- setter?.(firstOfMonth);
37
- if (autoClose)
38
- setOpen(false);
39
- };
40
- const prevYear = () => setViewYear((y) => clampYear(y - 1));
41
- const nextYear = () => setViewYear((y) => clampYear(y + 1));
42
- const isYearMin = viewYear <= fromYear;
43
- const isYearMax = viewYear >= toYear;
44
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, className: cn('flex flex-col', className), children: jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { variant: "outline", id: props.id ?? 'month', className: cn("w-full justify-between px-field-padding-x py-0", fieldTriggerClassName), children: [selected ? format(selected) : jsx("span", { className: "text-muted-foreground/40", children: placeholder }), jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground" })] }) }), jsxs(PopoverContent, { align: align, side: side, sideOffset: sideOffset, className: cn('w-72 p-3', contentClassName), children: [jsxs("div", { className: "mb-3 flex items-center justify-between", children: [jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Previous year", onClick: prevYear, disabled: isYearMin, children: jsx(ChevronLeft, { className: "h-4 w-4" }) }), jsxs(Select, { value: String(viewYear), onValueChange: (val) => setViewYear(clampYear(Number(val))), children: [jsx(SelectTrigger, { className: "w-fit text-sm", children: jsx(SelectValue, {}) }), jsx(SelectContent, { className: "h-fit", children: Array.from({ length: toYear - fromYear + 1 }, (_, i) => fromYear + i).map((y) => (jsx(SelectItem, { value: String(y), children: y }, y))) })] }), jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Next year", onClick: nextYear, disabled: isYearMax, children: jsx(ChevronRight, { className: "h-4 w-4" }) })] }), jsx("div", { className: "grid grid-cols-3 gap-2", children: months.map(({ m, label: monthLabel }) => {
45
- const isActive = selected &&
46
- selected.getFullYear() === viewYear &&
47
- selected.getMonth() === m;
48
- return (jsx(Button, { type: "button", variant: isActive ? 'solid' : 'outline', className: cn('h-9 justify-center rounded-control-lg', isActive ? '' : 'bg-background'), onClick: () => selectMonth(m), children: jsx("span", { className: "text-sm", children: monthLabel }) }, m));
49
- }) }), jsx("div", { className: "mt-3 flex justify-end", children: jsx(Button, { type: "button", variant: "ghost", className: "h-8 px-2 text-xs", onClick: () => {
50
- setter?.(undefined);
51
- setOpen(false);
52
- }, children: "Clear" }) })] })] }) }));
53
- };
54
-
55
- export { FormMonthPicker };
56
- //# sourceMappingURL=form-month-picker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-month-picker.js","sources":["../../src/components/form-month-picker.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { fieldTriggerClassName } from '@/hooks/use-field-focus';\r\nimport { Button } from '@/components/button';\r\nimport {\r\n Popover,\r\n PopoverContent,\r\n PopoverTrigger,\r\n} from '@/components/popover';\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from '@/components/select';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormMonthPickerProps extends React.InputHTMLAttributes<HTMLInputElement> {\r\n label?: string;\r\n /** ms since epoch; will be normalized to the first day of the month */\r\n date?: number;\r\n /** setter receives ms since epoch (first day of month at local midnight) or undefined when cleared */\r\n setter?: (value?: number) => void;\r\n className?: string;\r\n side?: 'top' | 'right' | 'bottom' | 'left';\r\n align?: 'start' | 'center' | 'end';\r\n sideOffset?: number;\r\n contentClassName?: string;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n required?: boolean;\r\n\r\n /** Placeholder text when no month selected */\r\n placeholder?: string;\r\n\r\n /** Format the button text */\r\n format?: (d: Date) => string;\r\n\r\n /** Year bounds for navigation (inclusive) */\r\n fromYear?: number;\r\n toYear?: number;\r\n\r\n /** Close popover automatically on select (default true) */\r\n autoClose?: boolean;\r\n}\r\n\r\nexport const FormMonthPicker = ({\r\n label,\r\n date,\r\n setter,\r\n className,\r\n side = 'bottom',\r\n align = 'start',\r\n sideOffset = 6,\r\n contentClassName,\r\n placeholder = 'Select month',\r\n format = (d) =>\r\n d.toLocaleDateString(undefined, { month: 'short', year: 'numeric' }),\r\n fromYear = new Date().getFullYear() - 5,\r\n toYear = new Date().getFullYear() + 5,\r\n autoClose = true,\r\n tooltip,\r\n tooltipId,\r\n required = false,\r\n ...props\r\n}: FormMonthPickerProps) => {\r\n const [open, setOpen] = React.useState(false);\r\n\r\n // normalize incoming ms -> first day of month\r\n const selected = React.useMemo(() => {\r\n if (date == null) return undefined;\r\n const d = new Date(date);\r\n return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);\r\n }, [date]);\r\n\r\n const [viewYear, setViewYear] = React.useState<number>(\r\n selected?.getFullYear() ?? new Date().getFullYear(),\r\n );\r\n\r\n React.useEffect(() => {\r\n if (selected) setViewYear(selected.getFullYear());\r\n }, [selected]);\r\n\r\n const months = React.useMemo(\r\n () =>\r\n Array.from({ length: 12 }, (_, m) => ({\r\n m,\r\n label: new Date(2000, m, 1).toLocaleString(undefined, {\r\n month: 'short',\r\n }),\r\n })),\r\n [],\r\n );\r\n\r\n const clampYear = (y: number) => Math.min(Math.max(y, fromYear), toYear);\r\n\r\n const selectMonth = (monthIndex: number) => {\r\n const y = clampYear(viewYear);\r\n const firstOfMonth = new Date(y, monthIndex, 1, 0, 0, 0, 0).getTime();\r\n setter?.(firstOfMonth);\r\n if (autoClose) setOpen(false);\r\n };\r\n\r\n const prevYear = () => setViewYear((y) => clampYear(y - 1));\r\n const nextYear = () => setViewYear((y) => clampYear(y + 1));\r\n\r\n const isYearMin = viewYear <= fromYear;\r\n const isYearMax = viewYear >= toYear;\r\n\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n className={cn('flex flex-col', className)}\r\n >\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"outline\"\r\n id={props.id ?? 'month'}\r\n className={cn(\"w-full justify-between px-field-padding-x py-0\", fieldTriggerClassName)}\r\n >\r\n {selected ? format(selected) : <span className=\"text-muted-foreground/40\">{placeholder}</span>}\r\n <ChevronDown className=\"h-4 w-4 text-muted-foreground\" />\r\n </Button>\r\n </PopoverTrigger>\r\n\r\n <PopoverContent\r\n align={align}\r\n side={side}\r\n sideOffset={sideOffset}\r\n className={cn('w-72 p-3', contentClassName)}\r\n >\r\n {/* Header: year controls */}\r\n <div className=\"mb-3 flex items-center justify-between\">\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"sm\"\r\n className=\"h-8 w-8 p-0\"\r\n aria-label=\"Previous year\"\r\n onClick={prevYear}\r\n disabled={isYearMin}\r\n >\r\n <ChevronLeft className=\"h-4 w-4\" />\r\n </Button>\r\n\r\n <Select\r\n value={String(viewYear)}\r\n onValueChange={(val) => setViewYear(clampYear(Number(val)))}\r\n >\r\n <SelectTrigger className=\"w-fit text-sm\">\r\n <SelectValue />\r\n </SelectTrigger>\r\n <SelectContent className=\"h-fit\">\r\n {Array.from(\r\n { length: toYear - fromYear + 1 },\r\n (_, i) => fromYear + i,\r\n ).map((y) => (\r\n <SelectItem key={y} value={String(y)}>\r\n {y}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"sm\"\r\n className=\"h-8 w-8 p-0\"\r\n aria-label=\"Next year\"\r\n onClick={nextYear}\r\n disabled={isYearMax}\r\n >\r\n <ChevronRight className=\"h-4 w-4\" />\r\n </Button>\r\n </div>\r\n\r\n {/* Month grid */}\r\n <div className=\"grid grid-cols-3 gap-2\">\r\n {months.map(({ m, label: monthLabel }) => {\r\n const isActive =\r\n selected &&\r\n selected.getFullYear() === viewYear &&\r\n selected.getMonth() === m;\r\n\r\n return (\r\n <Button\r\n key={m}\r\n type=\"button\"\r\n variant={isActive ? 'solid' : 'outline'}\r\n className={cn(\r\n 'h-9 justify-center rounded-control-lg',\r\n isActive ? '' : 'bg-background',\r\n )}\r\n onClick={() => selectMonth(m)}\r\n >\r\n <span className=\"text-sm\">{monthLabel}</span>\r\n </Button>\r\n );\r\n })}\r\n </div>\r\n\r\n {/* Clear (optional) */}\r\n <div className=\"mt-3 flex justify-end\">\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n className=\"h-8 px-2 text-xs\"\r\n onClick={() => {\r\n setter?.(undefined);\r\n setOpen(false);\r\n }}\r\n >\r\n Clear\r\n </Button>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n </FormField>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;;AAuEE;;AAGA;;AACoB;AAClB;;AAEF;;AAMA;AACE;AAAc;AAChB;;;AAMM;AACE;;AAEH;;AAML;AACE;;AAEA;AACA;;AACF;AAEA;AACA;AAEA;AACA;AAEA;;AA6Ec;AACA;;;AA0BA;;AAEF;AASd;;"}
@@ -1,15 +0,0 @@
1
- export interface FormRadioProps<T extends string | boolean = string> {
2
- options: {
3
- value: T;
4
- label: string;
5
- }[];
6
- value?: T;
7
- setter?: (value: T) => void;
8
- label?: string;
9
- required?: boolean;
10
- className?: string;
11
- name?: string;
12
- tooltip?: string;
13
- tooltipId?: string;
14
- }
15
- export declare const FormRadio: <T extends string | boolean = string>({ label, value, options, setter, required, className, tooltip, tooltipId, name, }: FormRadioProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,20 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { RadioGroup, RadioGroupItem } from './radio-group.js';
3
- import { FormField } from './form-field.js';
4
-
5
- const FormRadio = ({ label, value, options, setter, required = false, className, tooltip, tooltipId, name, }) => {
6
- const stringValue = value?.toString() || '';
7
- const handleValueChange = (next) => {
8
- if (!setter)
9
- return;
10
- // Find the original option to get the correct type
11
- const selectedOption = options.find((option) => option.value.toString() === next);
12
- if (selectedOption) {
13
- setter(selectedOption.value);
14
- }
15
- };
16
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, className: className, children: jsx(RadioGroup, { value: stringValue, onValueChange: handleValueChange, className: "gap-field-label-gap", name: name, children: options.map((option) => (jsxs("div", { className: "flex items-center space-x-3", children: [jsx(RadioGroupItem, { value: option.value.toString(), id: `${name}-${option.value.toString()}` }), jsx("label", { htmlFor: `${name}-${option.value.toString()}`, className: "flex-1 cursor-pointer text-sm font-medium", children: option.label })] }, option.value.toString()))) }) }));
17
- };
18
-
19
- export { FormRadio };
20
- //# sourceMappingURL=form-radio.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-radio.js","sources":["../../src/components/form-radio.tsx"],"sourcesContent":["import { RadioGroup, RadioGroupItem } from './radio-group';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormRadioProps<T extends string | boolean = string> {\r\n options: { value: T; label: string }[];\r\n value?: T;\r\n setter?: (value: T) => void;\r\n label?: string;\r\n required?: boolean;\r\n className?: string;\r\n name?: string;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n}\r\n\r\nexport const FormRadio = <T extends string | boolean = string>({\r\n label,\r\n value,\r\n options,\r\n setter,\r\n required = false,\r\n className,\r\n tooltip,\r\n tooltipId,\r\n name,\r\n}: FormRadioProps<T>) => {\r\n const stringValue = value?.toString() || '';\r\n\r\n const handleValueChange = (next: string) => {\r\n if (!setter) return;\r\n\r\n // Find the original option to get the correct type\r\n const selectedOption = options.find(\r\n (option) => option.value.toString() === next,\r\n );\r\n if (selectedOption) {\r\n setter(selectedOption.value);\r\n }\r\n };\r\n\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n className={className}\r\n >\r\n <RadioGroup\r\n value={stringValue}\r\n onValueChange={handleValueChange}\r\n className=\"gap-field-label-gap\"\r\n name={name}\r\n >\r\n {options.map((option) => (\r\n <div\r\n key={option.value.toString()}\r\n className=\"flex items-center space-x-3\"\r\n >\r\n <RadioGroupItem\r\n value={option.value.toString()}\r\n id={`${name}-${option.value.toString()}`}\r\n />\r\n\r\n <label\r\n htmlFor={`${name}-${option.value.toString()}`}\r\n className=\"flex-1 cursor-pointer text-sm font-medium\"\r\n >\r\n {option.label}\r\n </label>\r\n </div>\r\n ))}\r\n </RadioGroup>\r\n </FormField>\r\n );\r\n};\r\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAeO,MAAM,SAAS,GAAG,CAAsC,EAC7D,KAAK,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,OAAO,EACP,SAAS,EACT,IAAI,GACc,KAAI;IACtB,MAAM,WAAW,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;AAE3C,IAAA,MAAM,iBAAiB,GAAG,CAAC,IAAY,KAAI;AACzC,QAAA,IAAI,CAAC,MAAM;YAAE;;QAGb,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CACjC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,IAAI,CAC7C;QACD,IAAI,cAAc,EAAE;AAClB,YAAA,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;QAC9B;AACF,IAAA,CAAC;IAED,QACEA,GAAA,CAAC,SAAS,EAAA,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EAAA,QAAA,EAEpBA,GAAA,CAAC,UAAU,EAAA,EACT,KAAK,EAAE,WAAW,EAClB,aAAa,EAAE,iBAAiB,EAChC,SAAS,EAAC,qBAAqB,EAC/B,IAAI,EAAE,IAAI,EAAA,QAAA,EAET,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAClBC,IAAA,CAAA,KAAA,EAAA,EAEE,SAAS,EAAC,6BAA6B,EAAA,QAAA,EAAA,CAEvCD,GAAA,CAAC,cAAc,EAAA,EACb,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAC9B,EAAE,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA,CAAE,EAAA,CACxC,EAEFA,GAAA,CAAA,OAAA,EAAA,EACE,OAAO,EAAE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA,CAAE,EAC7C,SAAS,EAAC,2CAA2C,EAAA,QAAA,EAEpD,MAAM,CAAC,KAAK,EAAA,CACP,CAAA,EAAA,EAbH,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAcxB,CACP,CAAC,EAAA,CACS,EAAA,CACH;AAEhB;;;;"}
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- export interface FormTextareaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {
3
- label?: string;
4
- setter?: (value: string) => void;
5
- required?: boolean;
6
- className?: string;
7
- tooltip?: string;
8
- tooltipId?: string;
9
- labelAddon?: React.ReactNode;
10
- }
11
- export declare const FormTextarea: ({ label, value, setter, required, className, tooltip, tooltipId, labelAddon, ...props }: FormTextareaProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- "use client";
2
- import { jsx } from 'react/jsx-runtime';
3
- import { cn } from '../utils.js';
4
- import { Textarea } from './textarea.js';
5
- import { FormField } from './form-field.js';
6
-
7
- const FormTextarea = ({ label, value, setter, required = true, className, tooltip, tooltipId, labelAddon, ...props }) => {
8
- return (jsx(FormField, { label: label, required: required, tooltip: tooltip, tooltipId: tooltipId, labelAddon: labelAddon, children: jsx(Textarea, { value: value ?? '', onChange: (e) => setter && setter(e.target.value), className: cn(className), ...props }) }));
9
- };
10
-
11
- export { FormTextarea };
12
- //# sourceMappingURL=form-textarea.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-textarea.js","sources":["../../src/components/form-textarea.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { Textarea } from '@/components/textarea';\r\nimport { FormField } from './form-field';\r\n\r\nexport interface FormTextareaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {\r\n label?: string;\r\n setter?: (value: string) => void;\r\n required?: boolean;\r\n className?: string;\r\n tooltip?: string;\r\n tooltipId?: string;\r\n labelAddon?: React.ReactNode;\r\n}\r\n\r\nexport const FormTextarea = ({\r\n label,\r\n value,\r\n setter,\r\n required = true,\r\n className,\r\n tooltip,\r\n tooltipId,\r\n labelAddon,\r\n ...props\r\n}: FormTextareaProps) => {\r\n return (\r\n <FormField\r\n label={label}\r\n required={required}\r\n tooltip={tooltip}\r\n tooltipId={tooltipId}\r\n labelAddon={labelAddon}\r\n >\r\n <Textarea\r\n value={value ?? ''}\r\n onChange={(e) => setter && setter(e.target.value)}\r\n className={cn(className)}\r\n {...props}\r\n />\r\n </FormField>\r\n );\r\n};\r\n"],"names":[],"mappings":";;;;;;AAkBO;AAWL;AAgBF;;"}
@@ -1,24 +0,0 @@
1
- import * as React from "react";
2
- import { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
3
- declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getErrors, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe, }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
4
- declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
5
- declare const useFormField: () => {
6
- invalid: boolean;
7
- isDirty: boolean;
8
- isTouched: boolean;
9
- isValidating: boolean;
10
- error?: import("react-hook-form").FieldError | undefined;
11
- id: string;
12
- name: string;
13
- formItemId: string;
14
- formDescriptionId: string;
15
- formMessageId: string;
16
- };
17
- declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
18
- declare const FormLabel: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & {
19
- required?: boolean;
20
- } & React.RefAttributes<HTMLLabelElement>>;
21
- declare const FormControl: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-slot").SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
22
- declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
23
- declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
24
- export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };