@flanksource/clicky-ui 0.3.83 → 0.3.84

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 (137) hide show
  1. package/dist/components/DateField.cjs.map +1 -1
  2. package/dist/components/DateField.d.ts +3 -2
  3. package/dist/components/DateField.d.ts.map +1 -1
  4. package/dist/components/DateField.js.map +1 -1
  5. package/dist/components/DatePicker.cjs +9 -61
  6. package/dist/components/DatePicker.cjs.map +1 -1
  7. package/dist/components/DatePicker.d.ts +5 -19
  8. package/dist/components/DatePicker.d.ts.map +1 -1
  9. package/dist/components/DatePicker.js +11 -63
  10. package/dist/components/DatePicker.js.map +1 -1
  11. package/dist/components/DateTimePicker.cjs +9 -78
  12. package/dist/components/DateTimePicker.cjs.map +1 -1
  13. package/dist/components/DateTimePicker.d.ts +5 -19
  14. package/dist/components/DateTimePicker.d.ts.map +1 -1
  15. package/dist/components/DateTimePicker.js +11 -80
  16. package/dist/components/DateTimePicker.js.map +1 -1
  17. package/dist/components/calendar-grid.cjs +83 -0
  18. package/dist/components/calendar-grid.cjs.map +1 -0
  19. package/dist/components/calendar-grid.d.ts +9 -0
  20. package/dist/components/calendar-grid.d.ts.map +1 -0
  21. package/dist/components/calendar-grid.js +83 -0
  22. package/dist/components/calendar-grid.js.map +1 -0
  23. package/dist/components/date-input-field.cjs +88 -0
  24. package/dist/components/date-input-field.cjs.map +1 -0
  25. package/dist/components/date-input-field.d.ts +37 -0
  26. package/dist/components/date-input-field.d.ts.map +1 -0
  27. package/dist/components/date-input-field.js +88 -0
  28. package/dist/components/date-input-field.js.map +1 -0
  29. package/dist/components/date-math.cjs +67 -0
  30. package/dist/components/date-math.cjs.map +1 -0
  31. package/dist/components/date-math.d.ts +33 -0
  32. package/dist/components/date-math.d.ts.map +1 -0
  33. package/dist/components/date-math.js +60 -0
  34. package/dist/components/date-math.js.map +1 -0
  35. package/dist/components/date-picker-menu.cjs +129 -0
  36. package/dist/components/date-picker-menu.cjs.map +1 -0
  37. package/dist/components/date-picker-menu.d.ts +18 -0
  38. package/dist/components/date-picker-menu.d.ts.map +1 -0
  39. package/dist/components/date-picker-menu.js +129 -0
  40. package/dist/components/date-picker-menu.js.map +1 -0
  41. package/dist/components/json-schema-form-date-math.cjs +15 -11
  42. package/dist/components/json-schema-form-date-math.cjs.map +1 -1
  43. package/dist/components/json-schema-form-date-math.d.ts +3 -0
  44. package/dist/components/json-schema-form-date-math.d.ts.map +1 -1
  45. package/dist/components/json-schema-form-date-math.js +15 -12
  46. package/dist/components/json-schema-form-date-math.js.map +1 -1
  47. package/dist/components.d.ts +1 -0
  48. package/dist/components.d.ts.map +1 -1
  49. package/dist/data/PromptDialog.cjs +19 -5
  50. package/dist/data/PromptDialog.cjs.map +1 -1
  51. package/dist/data/PromptDialog.d.ts +15 -1
  52. package/dist/data/PromptDialog.d.ts.map +1 -1
  53. package/dist/data/PromptDialog.js +19 -5
  54. package/dist/data/PromptDialog.js.map +1 -1
  55. package/dist/data/PromptIndicator.cjs +3 -2
  56. package/dist/data/PromptIndicator.cjs.map +1 -1
  57. package/dist/data/PromptIndicator.d.ts +4 -1
  58. package/dist/data/PromptIndicator.d.ts.map +1 -1
  59. package/dist/data/PromptIndicator.js +3 -2
  60. package/dist/data/PromptIndicator.js.map +1 -1
  61. package/dist/data/diagnostics/ErrorDetails.cjs +155 -110
  62. package/dist/data/diagnostics/ErrorDetails.cjs.map +1 -1
  63. package/dist/data/diagnostics/ErrorDetails.d.ts.map +1 -1
  64. package/dist/data/diagnostics/ErrorDetails.js +155 -110
  65. package/dist/data/diagnostics/ErrorDetails.js.map +1 -1
  66. package/dist/data/test-runner/TestDetailPanel.cjs +109 -46
  67. package/dist/data/test-runner/TestDetailPanel.cjs.map +1 -1
  68. package/dist/data/test-runner/TestDetailPanel.d.ts.map +1 -1
  69. package/dist/data/test-runner/TestDetailPanel.js +110 -47
  70. package/dist/data/test-runner/TestDetailPanel.js.map +1 -1
  71. package/dist/data/test-runner/TestTreeNode.cjs +84 -63
  72. package/dist/data/test-runner/TestTreeNode.cjs.map +1 -1
  73. package/dist/data/test-runner/TestTreeNode.d.ts.map +1 -1
  74. package/dist/data/test-runner/TestTreeNode.js +84 -63
  75. package/dist/data/test-runner/TestTreeNode.js.map +1 -1
  76. package/dist/data/test-runner/adapter.cjs.map +1 -1
  77. package/dist/data/test-runner/adapter.d.ts +2 -2
  78. package/dist/data/test-runner/adapter.d.ts.map +1 -1
  79. package/dist/data/test-runner/adapter.js.map +1 -1
  80. package/dist/data/test-runner/copy.cjs +62 -10
  81. package/dist/data/test-runner/copy.cjs.map +1 -1
  82. package/dist/data/test-runner/copy.d.ts +52 -9
  83. package/dist/data/test-runner/copy.d.ts.map +1 -1
  84. package/dist/data/test-runner/copy.js +60 -11
  85. package/dist/data/test-runner/copy.js.map +1 -1
  86. package/dist/data/test-runner/index.d.ts +1 -1
  87. package/dist/data/test-runner/index.d.ts.map +1 -1
  88. package/dist/data/verification/StepFilesView.cjs +90 -0
  89. package/dist/data/verification/StepFilesView.cjs.map +1 -0
  90. package/dist/data/verification/StepFilesView.d.ts +9 -0
  91. package/dist/data/verification/StepFilesView.d.ts.map +1 -0
  92. package/dist/data/verification/StepFilesView.js +90 -0
  93. package/dist/data/verification/StepFilesView.js.map +1 -0
  94. package/dist/data/verification/adapterViews.cjs +129 -69
  95. package/dist/data/verification/adapterViews.cjs.map +1 -1
  96. package/dist/data/verification/adapterViews.d.ts +3 -1
  97. package/dist/data/verification/adapterViews.d.ts.map +1 -1
  98. package/dist/data/verification/adapterViews.js +130 -70
  99. package/dist/data/verification/adapterViews.js.map +1 -1
  100. package/dist/data/verification/adapters.cjs +9 -0
  101. package/dist/data/verification/adapters.cjs.map +1 -1
  102. package/dist/data/verification/adapters.d.ts +2 -0
  103. package/dist/data/verification/adapters.d.ts.map +1 -1
  104. package/dist/data/verification/adapters.js +11 -2
  105. package/dist/data/verification/adapters.js.map +1 -1
  106. package/dist/data/verification/index.d.ts +2 -1
  107. package/dist/data/verification/index.d.ts.map +1 -1
  108. package/dist/data/verification/stepKind.cjs +63 -7
  109. package/dist/data/verification/stepKind.cjs.map +1 -1
  110. package/dist/data/verification/stepKind.d.ts +55 -6
  111. package/dist/data/verification/stepKind.d.ts.map +1 -1
  112. package/dist/data/verification/stepKind.js +62 -8
  113. package/dist/data/verification/stepKind.js.map +1 -1
  114. package/dist/data/verification/stepKindViews.cjs +318 -106
  115. package/dist/data/verification/stepKindViews.cjs.map +1 -1
  116. package/dist/data/verification/stepKindViews.d.ts +17 -6
  117. package/dist/data/verification/stepKindViews.d.ts.map +1 -1
  118. package/dist/data/verification/stepKindViews.js +319 -108
  119. package/dist/data/verification/stepKindViews.js.map +1 -1
  120. package/dist/data/version-info.cjs +3 -3
  121. package/dist/data/version-info.js +3 -3
  122. package/dist/data.cjs +4 -0
  123. package/dist/data.d.ts +1 -1
  124. package/dist/data.d.ts.map +1 -1
  125. package/dist/data.js +3 -2
  126. package/dist/hooks/use-prompts.cjs +52 -30
  127. package/dist/hooks/use-prompts.cjs.map +1 -1
  128. package/dist/hooks/use-prompts.d.ts +6 -0
  129. package/dist/hooks/use-prompts.d.ts.map +1 -1
  130. package/dist/hooks/use-prompts.js +52 -30
  131. package/dist/hooks/use-prompts.js.map +1 -1
  132. package/dist/index.cjs +5 -1
  133. package/dist/index.js +4 -3
  134. package/dist/runtime/barrels.json +5874 -5867
  135. package/dist/runtime/importmap.json +2175 -2170
  136. package/dist/styles.css +1 -1
  137. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DateField.cjs","names":["forwardRef","DateTimePicker","DatePicker"],"sources":["../../src/components/DateField.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateTimePicker } from \"./DateTimePicker\";\nimport type { ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateFieldMode = \"date\" | \"datetime\";\n\nexport type DateFieldProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n /** Selects native date input or date-time input behavior. */\n mode?: DateFieldMode;\n /** ISO date or datetime-local string shown in the input. */\n value?: string;\n /** Called with the next ISO-like value whenever the input changes. */\n onChange?: (value: string) => void;\n /** Classes applied to the outer picker wrapper. */\n className?: string;\n /** Classes applied to the text input. */\n inputClassName?: string;\n /** Classes applied to the calendar/open button. */\n buttonClassName?: string;\n /** Accessible label for the calendar/open button. */\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateField = forwardRef<HTMLInputElement, DateFieldProps>(\n ({ mode = \"date\", ...props }, ref) => {\n if (mode === \"datetime\") {\n return <DateTimePicker ref={ref} {...props} />;\n }\n\n return <DatePicker ref={ref} {...props} />;\n },\n);\n\nDateField.displayName = \"DateField\";\n"],"mappings":";;;;;AAiCA,IAAa,aAAA,GAAYA,MAAAA,WAAAA,EACtB,EAAE,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACpC,IAAI,SAAS,YACX,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,gBAAD;EAAqB;EAAK,GAAI;CAAQ,CAAA;CAG/C,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD;EAAiB;EAAK,GAAI;CAAQ,CAAA;AAC3C,CACF;AAEA,UAAU,cAAc"}
1
+ {"version":3,"file":"DateField.cjs","names":["forwardRef","DateTimePicker","DatePicker"],"sources":["../../src/components/DateField.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateTimePicker } from \"./DateTimePicker\";\nimport type { DateMathProps } from \"./date-math\";\nimport type { ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateFieldMode = \"date\" | \"datetime\";\n\nexport type DateFieldProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & DateMathProps & {\n /** Selects native date input or date-time input behavior. */\n mode?: DateFieldMode;\n /** ISO date or datetime-local string shown in the input. */\n value?: string;\n /** Called with the next ISO-like value whenever the input changes. */\n onChange?: (value: string) => void;\n /** Classes applied to the outer picker wrapper. */\n className?: string;\n /** Classes applied to the text input. */\n inputClassName?: string;\n /** Classes applied to the calendar/open button. */\n buttonClassName?: string;\n /** Accessible label for the calendar/open button. */\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateField = forwardRef<HTMLInputElement, DateFieldProps>(\n ({ mode = \"date\", ...props }, ref) => {\n if (mode === \"datetime\") {\n return <DateTimePicker ref={ref} {...props} />;\n }\n\n return <DatePicker ref={ref} {...props} />;\n },\n);\n\nDateField.displayName = \"DateField\";\n"],"mappings":";;;;;AAkCA,IAAa,aAAA,GAAYA,MAAAA,WAAAA,EACtB,EAAE,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACpC,IAAI,SAAS,YACX,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,gBAAD;EAAqB;EAAK,GAAI;CAAQ,CAAA;CAG/C,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD;EAAiB;EAAK,GAAI;CAAQ,CAAA;AAC3C,CACF;AAEA,UAAU,cAAc"}
@@ -1,7 +1,8 @@
1
1
  import { InputHTMLAttributes, ReactNode } from 'react';
2
+ import { DateMathProps } from './date-math.js';
2
3
  import { ClearableFieldProps } from './field-clear-button.js';
3
4
  export type DateFieldMode = "date" | "datetime";
4
- export type DateFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange" | "prefix"> & ClearableFieldProps & {
5
+ export type DateFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange" | "prefix"> & ClearableFieldProps & DateMathProps & {
5
6
  /** Selects native date input or date-time input behavior. */
6
7
  mode?: DateFieldMode;
7
8
  /** ISO date or datetime-local string shown in the input. */
@@ -21,7 +22,7 @@ export type DateFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type"
21
22
  /** Leading in-field adornment, rendered at the left edge of the input. */
22
23
  prefix?: ReactNode;
23
24
  };
24
- export declare const DateField: import('react').ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & ClearableFieldProps & {
25
+ export declare const DateField: import('react').ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & ClearableFieldProps & DateMathProps & {
25
26
  /** Selects native date input or date-time input behavior. */
26
27
  mode?: DateFieldMode;
27
28
  /** ISO date or datetime-local string shown in the input. */
@@ -1 +1 @@
1
- {"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/components/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,mBAAmB,CAAC,gBAAgB,CAAC,EAGrC,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CACzC,GAAG,mBAAmB,GAAG;IACxB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,SAAS;IApBpB,6DAA6D;WACtD,aAAa;IACpB,4DAA4D;YACpD,MAAM;IACd,sEAAsE;eAC3D,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAClC,mDAAmD;gBACvC,MAAM;IAClB,yCAAyC;qBACxB,MAAM;IACvB,mDAAmD;sBACjC,MAAM;IACxB,qDAAqD;sBACnC,MAAM;IACxB,yEAAyE;aAChE,SAAS;IAClB,0EAA0E;aACjE,SAAS;oDAWnB,CAAC"}
1
+ {"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/components/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,mBAAmB,CAAC,gBAAgB,CAAC,EAGrC,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CACzC,GAAG,mBAAmB,GAAG,aAAa,GAAG;IACxC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,SAAS;IApBpB,6DAA6D;WACtD,aAAa;IACpB,4DAA4D;YACpD,MAAM;IACd,sEAAsE;eAC3D,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAClC,mDAAmD;gBACvC,MAAM;IAClB,yCAAyC;qBACxB,MAAM;IACvB,mDAAmD;sBACjC,MAAM;IACxB,qDAAqD;sBACnC,MAAM;IACxB,yEAAyE;aAChE,SAAS;IAClB,0EAA0E;aACjE,SAAS;oDAWnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DateField.js","names":[],"sources":["../../src/components/DateField.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateTimePicker } from \"./DateTimePicker\";\nimport type { ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateFieldMode = \"date\" | \"datetime\";\n\nexport type DateFieldProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n /** Selects native date input or date-time input behavior. */\n mode?: DateFieldMode;\n /** ISO date or datetime-local string shown in the input. */\n value?: string;\n /** Called with the next ISO-like value whenever the input changes. */\n onChange?: (value: string) => void;\n /** Classes applied to the outer picker wrapper. */\n className?: string;\n /** Classes applied to the text input. */\n inputClassName?: string;\n /** Classes applied to the calendar/open button. */\n buttonClassName?: string;\n /** Accessible label for the calendar/open button. */\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateField = forwardRef<HTMLInputElement, DateFieldProps>(\n ({ mode = \"date\", ...props }, ref) => {\n if (mode === \"datetime\") {\n return <DateTimePicker ref={ref} {...props} />;\n }\n\n return <DatePicker ref={ref} {...props} />;\n },\n);\n\nDateField.displayName = \"DateField\";\n"],"mappings":";;;;;AAiCA,IAAa,YAAY,YACtB,EAAE,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACpC,IAAI,SAAS,YACX,OAAO,oBAAC,gBAAD;EAAqB;EAAK,GAAI;CAAQ,CAAA;CAG/C,OAAO,oBAAC,YAAD;EAAiB;EAAK,GAAI;CAAQ,CAAA;AAC3C,CACF;AAEA,UAAU,cAAc"}
1
+ {"version":3,"file":"DateField.js","names":[],"sources":["../../src/components/DateField.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateTimePicker } from \"./DateTimePicker\";\nimport type { DateMathProps } from \"./date-math\";\nimport type { ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateFieldMode = \"date\" | \"datetime\";\n\nexport type DateFieldProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & DateMathProps & {\n /** Selects native date input or date-time input behavior. */\n mode?: DateFieldMode;\n /** ISO date or datetime-local string shown in the input. */\n value?: string;\n /** Called with the next ISO-like value whenever the input changes. */\n onChange?: (value: string) => void;\n /** Classes applied to the outer picker wrapper. */\n className?: string;\n /** Classes applied to the text input. */\n inputClassName?: string;\n /** Classes applied to the calendar/open button. */\n buttonClassName?: string;\n /** Accessible label for the calendar/open button. */\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateField = forwardRef<HTMLInputElement, DateFieldProps>(\n ({ mode = \"date\", ...props }, ref) => {\n if (mode === \"datetime\") {\n return <DateTimePicker ref={ref} {...props} />;\n }\n\n return <DatePicker ref={ref} {...props} />;\n },\n);\n\nDateField.displayName = \"DateField\";\n"],"mappings":";;;;;AAkCA,IAAa,YAAY,YACtB,EAAE,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACpC,IAAI,SAAS,YACX,OAAO,oBAAC,gBAAD;EAAqB;EAAK,GAAI;CAAQ,CAAA;CAG/C,OAAO,oBAAC,YAAD;EAAiB;EAAK,GAAI;CAAQ,CAAA;AAC3C,CACF;AAEA,UAAU,cAAc"}
@@ -1,67 +1,15 @@
1
- const require_Icon = require("../data/Icon.cjs");
2
- const require_UiCalendar = require("../icons/components/UiCalendar.cjs");
3
- const require_utils = require("../lib/utils.cjs");
4
- const require_field_clear_button = require("./field-clear-button.cjs");
1
+ const require_date_math = require("./date-math.cjs");
2
+ const require_date_input_field = require("./date-input-field.cjs");
5
3
  let react = require("react");
6
4
  let react_jsx_runtime = require("react/jsx-runtime");
7
5
  // src/components/DatePicker.tsx
8
- var DatePicker = (0, react.forwardRef)(({ value = "", onChange, className, inputClassName, buttonClassName, openButtonLabel = "Open date picker", suffix, prefix, clearable, onClear, clearLabel, ...props }, ref) => {
9
- const localRef = (0, react.useRef)(null);
10
- const showClear = clearable && value !== "" && !props.disabled && !props.readOnly;
11
- function assignRef(node) {
12
- localRef.current = node;
13
- if (typeof ref === "function") ref(node);
14
- else if (ref) ref.current = node;
15
- }
16
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
17
- "data-jsf-control": true,
18
- "data-clearable-field": true,
19
- className: require_utils.cn("relative", className),
20
- children: [
21
- prefix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
22
- className: "absolute inset-y-0 left-1.5 flex items-center",
23
- children: prefix
24
- }),
25
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
26
- ...props,
27
- ref: assignRef,
28
- type: "date",
29
- value,
30
- className: require_utils.cn("h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring", "[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none", prefix && "pl-8", inputClassName, (showClear || suffix) && "pr-16", showClear && suffix && "pr-24"),
31
- onChange: (event) => onChange?.(event.target.value)
32
- }),
33
- suffix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
34
- className: require_utils.cn("absolute inset-y-0 flex items-center", showClear ? "right-14" : "right-7"),
35
- children: suffix
36
- }),
37
- showClear && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
38
- className: "absolute inset-y-0 right-7 flex items-center",
39
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_field_clear_button.FieldClearButton, {
40
- ...clearLabel ? { clearLabel } : {},
41
- onClear: () => {
42
- if (onClear) onClear();
43
- else onChange?.("");
44
- localRef.current?.focus();
45
- }
46
- })
47
- }),
48
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
49
- type: "button",
50
- "aria-label": openButtonLabel,
51
- disabled: props.disabled || props.readOnly,
52
- className: require_utils.cn("absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground", buttonClassName),
53
- onClick: () => {
54
- localRef.current?.focus();
55
- localRef.current?.showPicker?.();
56
- },
57
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, {
58
- icon: require_UiCalendar.UiCalendar,
59
- className: "text-sm"
60
- })
61
- })
62
- ]
63
- });
64
- });
6
+ var DatePicker = (0, react.forwardRef)(({ openButtonLabel = "Open date picker", dateMathPresets = require_date_math.DATE_PICKER_DATE_MATH_PRESETS, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_date_input_field.DateInputField, {
7
+ ...props,
8
+ ref,
9
+ openButtonLabel,
10
+ dateMathPresets,
11
+ withTime: false
12
+ }));
65
13
  DatePicker.displayName = "DatePicker";
66
14
  exports.DatePicker = DatePicker;
67
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.cjs","names":["forwardRef","useRef","cn","FieldClearButton","Icon","UiCalendar"],"sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { UiCalendar } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { FieldClearButton, type ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DatePickerProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n value?: string;\n onChange?: (value: string) => void;\n className?: string;\n inputClassName?: string;\n buttonClassName?: string;\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (\n {\n value = \"\",\n onChange,\n className,\n inputClassName,\n buttonClassName,\n openButtonLabel = \"Open date picker\",\n suffix,\n prefix,\n clearable,\n onClear,\n clearLabel,\n ...props\n },\n ref,\n ) => {\n const localRef = useRef<HTMLInputElement | null>(null);\n const showClear = clearable && value !== \"\" && !props.disabled && !props.readOnly;\n\n function assignRef(node: HTMLInputElement | null) {\n localRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n\n return (\n <div data-jsf-control data-clearable-field className={cn(\"relative\", className)}>\n {prefix && <div className=\"absolute inset-y-0 left-1.5 flex items-center\">{prefix}</div>}\n <input\n {...props}\n ref={assignRef}\n type=\"date\"\n value={value}\n className={cn(\n \"h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none\",\n prefix && \"pl-8\",\n inputClassName,\n (showClear || suffix) && \"pr-16\",\n showClear && suffix && \"pr-24\",\n )}\n onChange={(event) => onChange?.(event.target.value)}\n />\n {suffix && (\n <div className={cn(\"absolute inset-y-0 flex items-center\", showClear ? \"right-14\" : \"right-7\")}>{suffix}</div>\n )}\n {showClear && <span className=\"absolute inset-y-0 right-7 flex items-center\"><FieldClearButton {...(clearLabel ? { clearLabel } : {})} onClear={() => { if (onClear) onClear(); else onChange?.(\"\"); localRef.current?.focus(); }} /></span>}\n <button\n type=\"button\"\n aria-label={openButtonLabel}\n disabled={props.disabled || props.readOnly}\n className={cn(\n \"absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground\",\n buttonClassName,\n )}\n onClick={() => {\n localRef.current?.focus();\n localRef.current?.showPicker?.();\n }}\n >\n <Icon icon={UiCalendar} className=\"text-sm\" />\n </button>\n </div>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"mappings":";;;;;;;AAwBA,IAAa,cAAA,GAAaA,MAAAA,WAAAA,EAEtB,EACE,QAAQ,IACR,UACA,WACA,gBACA,iBACA,kBAAkB,oBAClB,QACA,QACA,WACA,SACA,YACA,GAAG,SAEL,QACG;CACH,MAAM,YAAA,GAAWC,MAAAA,OAAAA,CAAgC,IAAI;CACrD,MAAM,YAAY,aAAa,UAAU,MAAM,CAAC,MAAM,YAAY,CAAC,MAAM;CAEzE,SAAS,UAAU,MAA+B;EAChD,SAAS,UAAU;EACnB,IAAI,OAAO,QAAQ,YACjB,IAAI,IAAI;OACH,IAAI,KACT,IAAI,UAAU;CAElB;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,oBAAA;EAAiB,wBAAA;EAAqB,WAAWC,cAAAA,GAAG,YAAY,SAAS;EAA9E,UAAA;GACG,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAU;IAAiD,UAAA;GAAY,CAAA;GACvF,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACE,GAAI;IACJ,KAAK;IACL,MAAK;IACE;IACP,WAAWA,cAAAA,GACT,wJACA,wGACA,UAAU,QACV,iBACC,aAAa,WAAW,SACzB,aAAa,UAAU,OACzB;IACA,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAWA,cAAAA,GAAG,wCAAwC,YAAY,aAAa,SAAS;IAAI,UAAA;GAAY,CAAA;GAE9G,aAAa,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IAAM,WAAU;IAA+C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,2BAAAA,kBAAD;KAAkB,GAAK,aAAa,EAAE,WAAW,IAAI,CAAC;KAAI,eAAe;MAAE,IAAI,SAAS,QAAQ;WAAQ,WAAW,EAAE;MAAG,SAAS,SAAS,MAAM;KAAG;IAAI,CAAA;GAAO,CAAA;GAC3O,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;IACE,MAAK;IACL,cAAY;IACZ,UAAU,MAAM,YAAY,MAAM;IAClC,WAAWD,cAAAA,GACT,6EACA,eACF;IACA,eAAe;KACb,SAAS,SAAS,MAAM;KACxB,SAAS,SAAS,aAAa;IACjC;IAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACE,aAAAA,MAAD;KAAM,MAAMC,mBAAAA;KAAY,WAAU;IAAW,CAAA;GACvC,CAAA;EACL;;AAET,CACF;AAEA,WAAW,cAAc"}
1
+ {"version":3,"file":"DatePicker.cjs","names":["forwardRef","DATE_PICKER_DATE_MATH_PRESETS","DateInputField"],"sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DATE_PICKER_DATE_MATH_PRESETS } from \"./date-math\";\nimport { DateInputField, type DateFieldProps } from \"./date-input-field\";\n\nexport type DatePickerProps = DateFieldProps;\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (\n {\n openButtonLabel = \"Open date picker\",\n dateMathPresets = DATE_PICKER_DATE_MATH_PRESETS,\n ...props\n },\n ref,\n ) => (\n <DateInputField\n {...props}\n ref={ref}\n openButtonLabel={openButtonLabel}\n dateMathPresets={dateMathPresets}\n withTime={false}\n />\n ),\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"mappings":";;;;;AAMA,IAAa,cAAA,GAAaA,MAAAA,WAAAA,EAEtB,EACE,kBAAkB,oBAClB,kBAAkBC,kBAAAA,+BAClB,GAAG,SAEL,QAEA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,gBAAD;CACE,GAAI;CACC;CACY;CACA;CACjB,UAAU;AACX,CAAA,CAEL;AAEA,WAAW,cAAc"}
@@ -1,27 +1,13 @@
1
- import { InputHTMLAttributes, ReactNode } from 'react';
2
- import { ClearableFieldProps } from './field-clear-button.js';
3
- export type DatePickerProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange" | "prefix"> & ClearableFieldProps & {
1
+ import { DateFieldProps } from './date-input-field.js';
2
+ export type DatePickerProps = DateFieldProps;
3
+ export declare const DatePicker: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & import('./field-clear-button.js').ClearableFieldProps & import('./date-math.js').DateMathProps & {
4
4
  value?: string;
5
5
  onChange?: (value: string) => void;
6
6
  className?: string;
7
7
  inputClassName?: string;
8
8
  buttonClassName?: string;
9
9
  openButtonLabel?: string;
10
- /** Trailing in-field adornment, rendered left of the calendar button. */
11
- suffix?: ReactNode;
12
- /** Leading in-field adornment, rendered at the left edge of the input. */
13
- prefix?: ReactNode;
14
- };
15
- export declare const DatePicker: import('react').ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & ClearableFieldProps & {
16
- value?: string;
17
- onChange?: (value: string) => void;
18
- className?: string;
19
- inputClassName?: string;
20
- buttonClassName?: string;
21
- openButtonLabel?: string;
22
- /** Trailing in-field adornment, rendered left of the calendar button. */
23
- suffix?: ReactNode;
24
- /** Leading in-field adornment, rendered at the left edge of the input. */
25
- prefix?: ReactNode;
10
+ suffix?: import('react').ReactNode;
11
+ prefix?: import('react').ReactNode;
26
12
  } & import('react').RefAttributes<HTMLInputElement>>;
27
13
  //# sourceMappingURL=DatePicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrF,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAElF,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,mBAAmB,CAAC,gBAAgB,CAAC,EAGrC,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CACzC,GAAG,mBAAmB,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU;YAZb,MAAM;eACH,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;gBACtB,MAAM;qBACD,MAAM;sBACL,MAAM;sBACN,MAAM;IACxB,yEAAyE;aAChE,SAAS;IAClB,0EAA0E;aACjE,SAAS;oDAyEnB,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAE7C,eAAO,MAAM,UAAU;;;;;;;;;oDAiBtB,CAAC"}
@@ -1,67 +1,15 @@
1
- import { Icon } from "../data/Icon.js";
2
- import { UiCalendar } from "../icons/components/UiCalendar.js";
3
- import { cn } from "../lib/utils.js";
4
- import { FieldClearButton } from "./field-clear-button.js";
5
- import { forwardRef, useRef } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { DATE_PICKER_DATE_MATH_PRESETS } from "./date-math.js";
2
+ import { DateInputField } from "./date-input-field.js";
3
+ import { forwardRef } from "react";
4
+ import { jsx } from "react/jsx-runtime";
7
5
  // src/components/DatePicker.tsx
8
- var DatePicker = forwardRef(({ value = "", onChange, className, inputClassName, buttonClassName, openButtonLabel = "Open date picker", suffix, prefix, clearable, onClear, clearLabel, ...props }, ref) => {
9
- const localRef = useRef(null);
10
- const showClear = clearable && value !== "" && !props.disabled && !props.readOnly;
11
- function assignRef(node) {
12
- localRef.current = node;
13
- if (typeof ref === "function") ref(node);
14
- else if (ref) ref.current = node;
15
- }
16
- return /* @__PURE__ */ jsxs("div", {
17
- "data-jsf-control": true,
18
- "data-clearable-field": true,
19
- className: cn("relative", className),
20
- children: [
21
- prefix && /* @__PURE__ */ jsx("div", {
22
- className: "absolute inset-y-0 left-1.5 flex items-center",
23
- children: prefix
24
- }),
25
- /* @__PURE__ */ jsx("input", {
26
- ...props,
27
- ref: assignRef,
28
- type: "date",
29
- value,
30
- className: cn("h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring", "[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none", prefix && "pl-8", inputClassName, (showClear || suffix) && "pr-16", showClear && suffix && "pr-24"),
31
- onChange: (event) => onChange?.(event.target.value)
32
- }),
33
- suffix && /* @__PURE__ */ jsx("div", {
34
- className: cn("absolute inset-y-0 flex items-center", showClear ? "right-14" : "right-7"),
35
- children: suffix
36
- }),
37
- showClear && /* @__PURE__ */ jsx("span", {
38
- className: "absolute inset-y-0 right-7 flex items-center",
39
- children: /* @__PURE__ */ jsx(FieldClearButton, {
40
- ...clearLabel ? { clearLabel } : {},
41
- onClear: () => {
42
- if (onClear) onClear();
43
- else onChange?.("");
44
- localRef.current?.focus();
45
- }
46
- })
47
- }),
48
- /* @__PURE__ */ jsx("button", {
49
- type: "button",
50
- "aria-label": openButtonLabel,
51
- disabled: props.disabled || props.readOnly,
52
- className: cn("absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground", buttonClassName),
53
- onClick: () => {
54
- localRef.current?.focus();
55
- localRef.current?.showPicker?.();
56
- },
57
- children: /* @__PURE__ */ jsx(Icon, {
58
- icon: UiCalendar,
59
- className: "text-sm"
60
- })
61
- })
62
- ]
63
- });
64
- });
6
+ var DatePicker = forwardRef(({ openButtonLabel = "Open date picker", dateMathPresets = DATE_PICKER_DATE_MATH_PRESETS, ...props }, ref) => /* @__PURE__ */ jsx(DateInputField, {
7
+ ...props,
8
+ ref,
9
+ openButtonLabel,
10
+ dateMathPresets,
11
+ withTime: false
12
+ }));
65
13
  DatePicker.displayName = "DatePicker";
66
14
  export { DatePicker };
67
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","names":[],"sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { UiCalendar } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { FieldClearButton, type ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DatePickerProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n value?: string;\n onChange?: (value: string) => void;\n className?: string;\n inputClassName?: string;\n buttonClassName?: string;\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (\n {\n value = \"\",\n onChange,\n className,\n inputClassName,\n buttonClassName,\n openButtonLabel = \"Open date picker\",\n suffix,\n prefix,\n clearable,\n onClear,\n clearLabel,\n ...props\n },\n ref,\n ) => {\n const localRef = useRef<HTMLInputElement | null>(null);\n const showClear = clearable && value !== \"\" && !props.disabled && !props.readOnly;\n\n function assignRef(node: HTMLInputElement | null) {\n localRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n\n return (\n <div data-jsf-control data-clearable-field className={cn(\"relative\", className)}>\n {prefix && <div className=\"absolute inset-y-0 left-1.5 flex items-center\">{prefix}</div>}\n <input\n {...props}\n ref={assignRef}\n type=\"date\"\n value={value}\n className={cn(\n \"h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"[&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none\",\n prefix && \"pl-8\",\n inputClassName,\n (showClear || suffix) && \"pr-16\",\n showClear && suffix && \"pr-24\",\n )}\n onChange={(event) => onChange?.(event.target.value)}\n />\n {suffix && (\n <div className={cn(\"absolute inset-y-0 flex items-center\", showClear ? \"right-14\" : \"right-7\")}>{suffix}</div>\n )}\n {showClear && <span className=\"absolute inset-y-0 right-7 flex items-center\"><FieldClearButton {...(clearLabel ? { clearLabel } : {})} onClear={() => { if (onClear) onClear(); else onChange?.(\"\"); localRef.current?.focus(); }} /></span>}\n <button\n type=\"button\"\n aria-label={openButtonLabel}\n disabled={props.disabled || props.readOnly}\n className={cn(\n \"absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground\",\n buttonClassName,\n )}\n onClick={() => {\n localRef.current?.focus();\n localRef.current?.showPicker?.();\n }}\n >\n <Icon icon={UiCalendar} className=\"text-sm\" />\n </button>\n </div>\n );\n },\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"mappings":";;;;;;;AAwBA,IAAa,aAAa,YAEtB,EACE,QAAQ,IACR,UACA,WACA,gBACA,iBACA,kBAAkB,oBAClB,QACA,QACA,WACA,SACA,YACA,GAAG,SAEL,QACG;CACH,MAAM,WAAW,OAAgC,IAAI;CACrD,MAAM,YAAY,aAAa,UAAU,MAAM,CAAC,MAAM,YAAY,CAAC,MAAM;CAEzE,SAAS,UAAU,MAA+B;EAChD,SAAS,UAAU;EACnB,IAAI,OAAO,QAAQ,YACjB,IAAI,IAAI;OACH,IAAI,KACT,IAAI,UAAU;CAElB;CAEA,OACE,qBAAC,OAAD;EAAK,oBAAA;EAAiB,wBAAA;EAAqB,WAAW,GAAG,YAAY,SAAS;EAA9E,UAAA;GACG,UAAU,oBAAC,OAAD;IAAK,WAAU;IAAiD,UAAA;GAAY,CAAA;GACvF,oBAAC,SAAD;IACE,GAAI;IACJ,KAAK;IACL,MAAK;IACE;IACP,WAAW,GACT,wJACA,wGACA,UAAU,QACV,iBACC,aAAa,WAAW,SACzB,aAAa,UAAU,OACzB;IACA,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACA,UACC,oBAAC,OAAD;IAAK,WAAW,GAAG,wCAAwC,YAAY,aAAa,SAAS;IAAI,UAAA;GAAY,CAAA;GAE9G,aAAa,oBAAC,QAAD;IAAM,WAAU;IAA+C,UAAA,oBAAC,kBAAD;KAAkB,GAAK,aAAa,EAAE,WAAW,IAAI,CAAC;KAAI,eAAe;MAAE,IAAI,SAAS,QAAQ;WAAQ,WAAW,EAAE;MAAG,SAAS,SAAS,MAAM;KAAG;IAAI,CAAA;GAAO,CAAA;GAC3O,oBAAC,UAAD;IACE,MAAK;IACL,cAAY;IACZ,UAAU,MAAM,YAAY,MAAM;IAClC,WAAW,GACT,6EACA,eACF;IACA,eAAe;KACb,SAAS,SAAS,MAAM;KACxB,SAAS,SAAS,aAAa;IACjC;IAEA,UAAA,oBAAC,MAAD;KAAM,MAAM;KAAY,WAAU;IAAW,CAAA;GACvC,CAAA;EACL;;AAET,CACF;AAEA,WAAW,cAAc"}
1
+ {"version":3,"file":"DatePicker.js","names":[],"sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DATE_PICKER_DATE_MATH_PRESETS } from \"./date-math\";\nimport { DateInputField, type DateFieldProps } from \"./date-input-field\";\n\nexport type DatePickerProps = DateFieldProps;\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (\n {\n openButtonLabel = \"Open date picker\",\n dateMathPresets = DATE_PICKER_DATE_MATH_PRESETS,\n ...props\n },\n ref,\n ) => (\n <DateInputField\n {...props}\n ref={ref}\n openButtonLabel={openButtonLabel}\n dateMathPresets={dateMathPresets}\n withTime={false}\n />\n ),\n);\n\nDatePicker.displayName = \"DatePicker\";\n"],"mappings":";;;;;AAMA,IAAa,aAAa,YAEtB,EACE,kBAAkB,oBAClB,kBAAkB,+BAClB,GAAG,SAEL,QAEA,oBAAC,gBAAD;CACE,GAAI;CACC;CACY;CACA;CACjB,UAAU;AACX,CAAA,CAEL;AAEA,WAAW,cAAc"}
@@ -1,85 +1,16 @@
1
- const require_Icon = require("../data/Icon.cjs");
2
- const require_UiCalendar = require("../icons/components/UiCalendar.cjs");
3
- const require_utils = require("../lib/utils.cjs");
4
- const require_field_clear_button = require("./field-clear-button.cjs");
1
+ const require_date_math = require("./date-math.cjs");
2
+ const require_date_input_field = require("./date-input-field.cjs");
5
3
  let react = require("react");
6
4
  let react_jsx_runtime = require("react/jsx-runtime");
7
5
  // src/components/DateTimePicker.tsx
8
- var DateTimePicker = (0, react.forwardRef)(({ value = "", onChange, className, inputClassName, buttonClassName, openButtonLabel = "Open time picker", suffix, prefix, clearable, onClear, clearLabel, ...props }, ref) => {
9
- const visibleRef = (0, react.useRef)(null);
10
- const pickerRef = (0, react.useRef)(null);
11
- const showClear = clearable && value !== "" && !props.disabled && !props.readOnly;
12
- function assignRef(node) {
13
- visibleRef.current = node;
14
- if (typeof ref === "function") ref(node);
15
- else if (ref) ref.current = node;
16
- }
17
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
18
- "data-jsf-control": true,
19
- "data-clearable-field": true,
20
- className: require_utils.cn("relative", className),
21
- children: [
22
- prefix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
23
- className: "absolute inset-y-0 left-1.5 flex items-center",
24
- children: prefix
25
- }),
26
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
27
- ...props,
28
- ref: assignRef,
29
- type: "text",
30
- value,
31
- className: require_utils.cn("h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", prefix && "pl-8", inputClassName, (showClear || suffix) && "pr-16", showClear && suffix && "pr-24"),
32
- onChange: (event) => onChange?.(event.target.value)
33
- }),
34
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
35
- ref: pickerRef,
36
- type: "datetime-local",
37
- tabIndex: -1,
38
- "aria-hidden": "true",
39
- className: "pointer-events-none absolute left-0 top-0 h-0 w-0 opacity-0",
40
- value: toDateTimeLocalValue(value),
41
- onChange: (event) => onChange?.(event.target.value)
42
- }),
43
- suffix && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
44
- className: require_utils.cn("absolute inset-y-0 flex items-center", showClear ? "right-14" : "right-7"),
45
- children: suffix
46
- }),
47
- showClear && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
48
- className: "absolute inset-y-0 right-7 flex items-center",
49
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_field_clear_button.FieldClearButton, {
50
- ...clearLabel ? { clearLabel } : {},
51
- onClear: () => {
52
- if (onClear) onClear();
53
- else onChange?.("");
54
- visibleRef.current?.focus();
55
- }
56
- })
57
- }),
58
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
59
- type: "button",
60
- "aria-label": openButtonLabel,
61
- disabled: props.disabled || props.readOnly,
62
- className: require_utils.cn("absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", buttonClassName),
63
- onClick: () => {
64
- visibleRef.current?.focus();
65
- pickerRef.current?.showPicker?.();
66
- },
67
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Icon.Icon, {
68
- icon: require_UiCalendar.UiCalendar,
69
- className: "text-sm"
70
- })
71
- })
72
- ]
73
- });
74
- });
6
+ var DateTimePicker = (0, react.forwardRef)(({ openButtonLabel = "Open time picker", dateMathPresets = require_date_math.DATE_TIME_PICKER_DATE_MATH_PRESETS, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_date_input_field.DateInputField, {
7
+ ...props,
8
+ ref,
9
+ openButtonLabel,
10
+ dateMathPresets,
11
+ withTime: true
12
+ }));
75
13
  DateTimePicker.displayName = "DateTimePicker";
76
- function toDateTimeLocalValue(value) {
77
- const trimmed = value.trim();
78
- if (!trimmed) return "";
79
- if (trimmed === "now" || trimmed.startsWith("now")) return "";
80
- const withTime = /^\d{4}-\d{2}-\d{2}$/.test(trimmed) ? `${trimmed}T00:00` : trimmed;
81
- return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(withTime) ? withTime.slice(0, 16) : "";
82
- }
83
14
  exports.DateTimePicker = DateTimePicker;
84
15
 
85
16
  //# sourceMappingURL=DateTimePicker.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.cjs","names":["forwardRef","useRef","cn","FieldClearButton","Icon","UiCalendar"],"sources":["../../src/components/DateTimePicker.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { UiCalendar } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { FieldClearButton, type ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateTimePickerProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n value?: string;\n onChange?: (value: string) => void;\n className?: string;\n inputClassName?: string;\n buttonClassName?: string;\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\n (\n {\n value = \"\",\n onChange,\n className,\n inputClassName,\n buttonClassName,\n openButtonLabel = \"Open time picker\",\n suffix,\n prefix,\n clearable,\n onClear,\n clearLabel,\n ...props\n },\n ref,\n ) => {\n const visibleRef = useRef<HTMLInputElement | null>(null);\n const pickerRef = useRef<HTMLInputElement | null>(null);\n const showClear = clearable && value !== \"\" && !props.disabled && !props.readOnly;\n\n function assignRef(node: HTMLInputElement | null) {\n visibleRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n\n return (\n <div data-jsf-control data-clearable-field className={cn(\"relative\", className)}>\n {prefix && <div className=\"absolute inset-y-0 left-1.5 flex items-center\">{prefix}</div>}\n <input\n {...props}\n ref={assignRef}\n type=\"text\"\n value={value}\n className={cn(\n \"h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n prefix && \"pl-8\",\n inputClassName,\n (showClear || suffix) && \"pr-16\",\n showClear && suffix && \"pr-24\",\n )}\n onChange={(event) => onChange?.(event.target.value)}\n />\n <input\n ref={pickerRef}\n type=\"datetime-local\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute left-0 top-0 h-0 w-0 opacity-0\"\n value={toDateTimeLocalValue(value)}\n onChange={(event) => onChange?.(event.target.value)}\n />\n {suffix && (\n <div className={cn(\"absolute inset-y-0 flex items-center\", showClear ? \"right-14\" : \"right-7\")}>{suffix}</div>\n )}\n {showClear && <span className=\"absolute inset-y-0 right-7 flex items-center\"><FieldClearButton {...(clearLabel ? { clearLabel } : {})} onClear={() => { if (onClear) onClear(); else onChange?.(\"\"); visibleRef.current?.focus(); }} /></span>}\n <button\n type=\"button\"\n aria-label={openButtonLabel}\n disabled={props.disabled || props.readOnly}\n className={cn(\n \"absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n buttonClassName,\n )}\n onClick={() => {\n visibleRef.current?.focus();\n pickerRef.current?.showPicker?.();\n }}\n >\n <Icon icon={UiCalendar} className=\"text-sm\" />\n </button>\n </div>\n );\n },\n);\n\nDateTimePicker.displayName = \"DateTimePicker\";\n\nfunction toDateTimeLocalValue(value: string) {\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n if (trimmed === \"now\" || trimmed.startsWith(\"now\")) return \"\";\n\n const withTime = /^\\d{4}-\\d{2}-\\d{2}$/.test(trimmed) ? `${trimmed}T00:00` : trimmed;\n\n return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/.test(withTime) ? withTime.slice(0, 16) : \"\";\n}\n"],"mappings":";;;;;;;AAwBA,IAAa,kBAAA,GAAiBA,MAAAA,WAAAA,EAE1B,EACE,QAAQ,IACR,UACA,WACA,gBACA,iBACA,kBAAkB,oBAClB,QACA,QACA,WACA,SACA,YACA,GAAG,SAEL,QACG;CACH,MAAM,cAAA,GAAaC,MAAAA,OAAAA,CAAgC,IAAI;CACvD,MAAM,aAAA,GAAYA,MAAAA,OAAAA,CAAgC,IAAI;CACtD,MAAM,YAAY,aAAa,UAAU,MAAM,CAAC,MAAM,YAAY,CAAC,MAAM;CAEzE,SAAS,UAAU,MAA+B;EAChD,WAAW,UAAU;EACrB,IAAI,OAAO,QAAQ,YACjB,IAAI,IAAI;OACH,IAAI,KACT,IAAI,UAAU;CAElB;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,oBAAA;EAAiB,wBAAA;EAAqB,WAAWC,cAAAA,GAAG,YAAY,SAAS;EAA9E,UAAA;GACG,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAU;IAAiD,UAAA;GAAY,CAAA;GACvF,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACE,GAAI;IACJ,KAAK;IACL,MAAK;IACE;IACP,WAAWA,cAAAA,GACT,wMACA,UAAU,QACV,iBACC,aAAa,WAAW,SACzB,aAAa,UAAU,OACzB;IACA,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACE,KAAK;IACL,MAAK;IACL,UAAU;IACV,eAAY;IACZ,WAAU;IACV,OAAO,qBAAqB,KAAK;IACjC,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAWA,cAAAA,GAAG,wCAAwC,YAAY,aAAa,SAAS;IAAI,UAAA;GAAY,CAAA;GAE9G,aAAa,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IAAM,WAAU;IAA+C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,2BAAAA,kBAAD;KAAkB,GAAK,aAAa,EAAE,WAAW,IAAI,CAAC;KAAI,eAAe;MAAE,IAAI,SAAS,QAAQ;WAAQ,WAAW,EAAE;MAAG,WAAW,SAAS,MAAM;KAAG;IAAI,CAAA;GAAO,CAAA;GAC7O,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;IACE,MAAK;IACL,cAAY;IACZ,UAAU,MAAM,YAAY,MAAM;IAClC,WAAWD,cAAAA,GACT,6HACA,eACF;IACA,eAAe;KACb,WAAW,SAAS,MAAM;KAC1B,UAAU,SAAS,aAAa;IAClC;IAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACE,aAAAA,MAAD;KAAM,MAAMC,mBAAAA;KAAY,WAAU;IAAW,CAAA;GACvC,CAAA;EACL;;AAET,CACF;AAEA,eAAe,cAAc;AAE7B,SAAS,qBAAqB,OAAe;CAC3C,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,YAAY,SAAS,QAAQ,WAAW,KAAK,GAAG,OAAO;CAE3D,MAAM,WAAW,sBAAsB,KAAK,OAAO,IAAI,GAAG,QAAQ,UAAU;CAE5E,OAAO,iCAAiC,KAAK,QAAQ,IAAI,SAAS,MAAM,GAAG,EAAE,IAAI;AACnF"}
1
+ {"version":3,"file":"DateTimePicker.cjs","names":["forwardRef","DATE_TIME_PICKER_DATE_MATH_PRESETS","DateInputField"],"sources":["../../src/components/DateTimePicker.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DATE_TIME_PICKER_DATE_MATH_PRESETS } from \"./date-math\";\nimport { DateInputField, type DateFieldProps } from \"./date-input-field\";\n\nexport type DateTimePickerProps = DateFieldProps;\n\nexport const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\n (\n {\n openButtonLabel = \"Open time picker\",\n dateMathPresets = DATE_TIME_PICKER_DATE_MATH_PRESETS,\n ...props\n },\n ref,\n ) => (\n <DateInputField\n {...props}\n ref={ref}\n openButtonLabel={openButtonLabel}\n dateMathPresets={dateMathPresets}\n withTime\n />\n ),\n);\n\nDateTimePicker.displayName = \"DateTimePicker\";\n"],"mappings":";;;;;AAMA,IAAa,kBAAA,GAAiBA,MAAAA,WAAAA,EAE1B,EACE,kBAAkB,oBAClB,kBAAkBC,kBAAAA,oCAClB,GAAG,SAEL,QAEA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,gBAAD;CACE,GAAI;CACC;CACY;CACA;CACjB,UAAA;AACD,CAAA,CAEL;AAEA,eAAe,cAAc"}
@@ -1,27 +1,13 @@
1
- import { InputHTMLAttributes, ReactNode } from 'react';
2
- import { ClearableFieldProps } from './field-clear-button.js';
3
- export type DateTimePickerProps = Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "onChange" | "prefix"> & ClearableFieldProps & {
1
+ import { DateFieldProps } from './date-input-field.js';
2
+ export type DateTimePickerProps = DateFieldProps;
3
+ export declare const DateTimePicker: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & import('./field-clear-button.js').ClearableFieldProps & import('./date-math.js').DateMathProps & {
4
4
  value?: string;
5
5
  onChange?: (value: string) => void;
6
6
  className?: string;
7
7
  inputClassName?: string;
8
8
  buttonClassName?: string;
9
9
  openButtonLabel?: string;
10
- /** Trailing in-field adornment, rendered left of the calendar button. */
11
- suffix?: ReactNode;
12
- /** Leading in-field adornment, rendered at the left edge of the input. */
13
- prefix?: ReactNode;
14
- };
15
- export declare const DateTimePicker: import('react').ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "type" | "value" | "onChange"> & ClearableFieldProps & {
16
- value?: string;
17
- onChange?: (value: string) => void;
18
- className?: string;
19
- inputClassName?: string;
20
- buttonClassName?: string;
21
- openButtonLabel?: string;
22
- /** Trailing in-field adornment, rendered left of the calendar button. */
23
- suffix?: ReactNode;
24
- /** Leading in-field adornment, rendered at the left edge of the input. */
25
- prefix?: ReactNode;
10
+ suffix?: import('react').ReactNode;
11
+ prefix?: import('react').ReactNode;
26
12
  } & import('react').RefAttributes<HTMLInputElement>>;
27
13
  //# sourceMappingURL=DateTimePicker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../src/components/DateTimePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrF,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAElF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,mBAAmB,CAAC,gBAAgB,CAAC,EAGrC,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CACzC,GAAG,mBAAmB,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc;YAZjB,MAAM;eACH,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;gBACtB,MAAM;qBACD,MAAM;sBACL,MAAM;sBACN,MAAM;IACxB,yEAAyE;aAChE,SAAS;IAClB,0EAA0E;aACjE,SAAS;oDAkFnB,CAAC"}
1
+ {"version":3,"file":"DateTimePicker.d.ts","sourceRoot":"","sources":["../../src/components/DateTimePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAEjD,eAAO,MAAM,cAAc;;;;;;;;;oDAiB1B,CAAC"}
@@ -1,85 +1,16 @@
1
- import { Icon } from "../data/Icon.js";
2
- import { UiCalendar } from "../icons/components/UiCalendar.js";
3
- import { cn } from "../lib/utils.js";
4
- import { FieldClearButton } from "./field-clear-button.js";
5
- import { forwardRef, useRef } from "react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { DATE_TIME_PICKER_DATE_MATH_PRESETS } from "./date-math.js";
2
+ import { DateInputField } from "./date-input-field.js";
3
+ import { forwardRef } from "react";
4
+ import { jsx } from "react/jsx-runtime";
7
5
  // src/components/DateTimePicker.tsx
8
- var DateTimePicker = forwardRef(({ value = "", onChange, className, inputClassName, buttonClassName, openButtonLabel = "Open time picker", suffix, prefix, clearable, onClear, clearLabel, ...props }, ref) => {
9
- const visibleRef = useRef(null);
10
- const pickerRef = useRef(null);
11
- const showClear = clearable && value !== "" && !props.disabled && !props.readOnly;
12
- function assignRef(node) {
13
- visibleRef.current = node;
14
- if (typeof ref === "function") ref(node);
15
- else if (ref) ref.current = node;
16
- }
17
- return /* @__PURE__ */ jsxs("div", {
18
- "data-jsf-control": true,
19
- "data-clearable-field": true,
20
- className: cn("relative", className),
21
- children: [
22
- prefix && /* @__PURE__ */ jsx("div", {
23
- className: "absolute inset-y-0 left-1.5 flex items-center",
24
- children: prefix
25
- }),
26
- /* @__PURE__ */ jsx("input", {
27
- ...props,
28
- ref: assignRef,
29
- type: "text",
30
- value,
31
- className: cn("h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", prefix && "pl-8", inputClassName, (showClear || suffix) && "pr-16", showClear && suffix && "pr-24"),
32
- onChange: (event) => onChange?.(event.target.value)
33
- }),
34
- /* @__PURE__ */ jsx("input", {
35
- ref: pickerRef,
36
- type: "datetime-local",
37
- tabIndex: -1,
38
- "aria-hidden": "true",
39
- className: "pointer-events-none absolute left-0 top-0 h-0 w-0 opacity-0",
40
- value: toDateTimeLocalValue(value),
41
- onChange: (event) => onChange?.(event.target.value)
42
- }),
43
- suffix && /* @__PURE__ */ jsx("div", {
44
- className: cn("absolute inset-y-0 flex items-center", showClear ? "right-14" : "right-7"),
45
- children: suffix
46
- }),
47
- showClear && /* @__PURE__ */ jsx("span", {
48
- className: "absolute inset-y-0 right-7 flex items-center",
49
- children: /* @__PURE__ */ jsx(FieldClearButton, {
50
- ...clearLabel ? { clearLabel } : {},
51
- onClear: () => {
52
- if (onClear) onClear();
53
- else onChange?.("");
54
- visibleRef.current?.focus();
55
- }
56
- })
57
- }),
58
- /* @__PURE__ */ jsx("button", {
59
- type: "button",
60
- "aria-label": openButtonLabel,
61
- disabled: props.disabled || props.readOnly,
62
- className: cn("absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", buttonClassName),
63
- onClick: () => {
64
- visibleRef.current?.focus();
65
- pickerRef.current?.showPicker?.();
66
- },
67
- children: /* @__PURE__ */ jsx(Icon, {
68
- icon: UiCalendar,
69
- className: "text-sm"
70
- })
71
- })
72
- ]
73
- });
74
- });
6
+ var DateTimePicker = forwardRef(({ openButtonLabel = "Open time picker", dateMathPresets = DATE_TIME_PICKER_DATE_MATH_PRESETS, ...props }, ref) => /* @__PURE__ */ jsx(DateInputField, {
7
+ ...props,
8
+ ref,
9
+ openButtonLabel,
10
+ dateMathPresets,
11
+ withTime: true
12
+ }));
75
13
  DateTimePicker.displayName = "DateTimePicker";
76
- function toDateTimeLocalValue(value) {
77
- const trimmed = value.trim();
78
- if (!trimmed) return "";
79
- if (trimmed === "now" || trimmed.startsWith("now")) return "";
80
- const withTime = /^\d{4}-\d{2}-\d{2}$/.test(trimmed) ? `${trimmed}T00:00` : trimmed;
81
- return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(withTime) ? withTime.slice(0, 16) : "";
82
- }
83
14
  export { DateTimePicker };
84
15
 
85
16
  //# sourceMappingURL=DateTimePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimePicker.js","names":[],"sources":["../../src/components/DateTimePicker.tsx"],"sourcesContent":["import { forwardRef, useRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../data/Icon\";\nimport { UiCalendar } from \"../icons\";\nimport { cn } from \"../lib/utils\";\nimport { FieldClearButton, type ClearableFieldProps } from \"./field-clear-button\";\n\nexport type DateTimePickerProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n // `prefix` is a global HTML attribute typed as string; omit it so our\n // ReactNode adornment prop below is not intersected down to `string & ReactNode`.\n \"type\" | \"value\" | \"onChange\" | \"prefix\"\n> & ClearableFieldProps & {\n value?: string;\n onChange?: (value: string) => void;\n className?: string;\n inputClassName?: string;\n buttonClassName?: string;\n openButtonLabel?: string;\n /** Trailing in-field adornment, rendered left of the calendar button. */\n suffix?: ReactNode;\n /** Leading in-field adornment, rendered at the left edge of the input. */\n prefix?: ReactNode;\n};\n\nexport const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\n (\n {\n value = \"\",\n onChange,\n className,\n inputClassName,\n buttonClassName,\n openButtonLabel = \"Open time picker\",\n suffix,\n prefix,\n clearable,\n onClear,\n clearLabel,\n ...props\n },\n ref,\n ) => {\n const visibleRef = useRef<HTMLInputElement | null>(null);\n const pickerRef = useRef<HTMLInputElement | null>(null);\n const showClear = clearable && value !== \"\" && !props.disabled && !props.readOnly;\n\n function assignRef(node: HTMLInputElement | null) {\n visibleRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }\n\n return (\n <div data-jsf-control data-clearable-field className={cn(\"relative\", className)}>\n {prefix && <div className=\"absolute inset-y-0 left-1.5 flex items-center\">{prefix}</div>}\n <input\n {...props}\n ref={assignRef}\n type=\"text\"\n value={value}\n className={cn(\n \"h-control-h w-full rounded-md border border-input bg-background px-control-px pr-8 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n prefix && \"pl-8\",\n inputClassName,\n (showClear || suffix) && \"pr-16\",\n showClear && suffix && \"pr-24\",\n )}\n onChange={(event) => onChange?.(event.target.value)}\n />\n <input\n ref={pickerRef}\n type=\"datetime-local\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute left-0 top-0 h-0 w-0 opacity-0\"\n value={toDateTimeLocalValue(value)}\n onChange={(event) => onChange?.(event.target.value)}\n />\n {suffix && (\n <div className={cn(\"absolute inset-y-0 flex items-center\", showClear ? \"right-14\" : \"right-7\")}>{suffix}</div>\n )}\n {showClear && <span className=\"absolute inset-y-0 right-7 flex items-center\"><FieldClearButton {...(clearLabel ? { clearLabel } : {})} onClear={() => { if (onClear) onClear(); else onChange?.(\"\"); visibleRef.current?.focus(); }} /></span>}\n <button\n type=\"button\"\n aria-label={openButtonLabel}\n disabled={props.disabled || props.readOnly}\n className={cn(\n \"absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n buttonClassName,\n )}\n onClick={() => {\n visibleRef.current?.focus();\n pickerRef.current?.showPicker?.();\n }}\n >\n <Icon icon={UiCalendar} className=\"text-sm\" />\n </button>\n </div>\n );\n },\n);\n\nDateTimePicker.displayName = \"DateTimePicker\";\n\nfunction toDateTimeLocalValue(value: string) {\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n if (trimmed === \"now\" || trimmed.startsWith(\"now\")) return \"\";\n\n const withTime = /^\\d{4}-\\d{2}-\\d{2}$/.test(trimmed) ? `${trimmed}T00:00` : trimmed;\n\n return /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/.test(withTime) ? withTime.slice(0, 16) : \"\";\n}\n"],"mappings":";;;;;;;AAwBA,IAAa,iBAAiB,YAE1B,EACE,QAAQ,IACR,UACA,WACA,gBACA,iBACA,kBAAkB,oBAClB,QACA,QACA,WACA,SACA,YACA,GAAG,SAEL,QACG;CACH,MAAM,aAAa,OAAgC,IAAI;CACvD,MAAM,YAAY,OAAgC,IAAI;CACtD,MAAM,YAAY,aAAa,UAAU,MAAM,CAAC,MAAM,YAAY,CAAC,MAAM;CAEzE,SAAS,UAAU,MAA+B;EAChD,WAAW,UAAU;EACrB,IAAI,OAAO,QAAQ,YACjB,IAAI,IAAI;OACH,IAAI,KACT,IAAI,UAAU;CAElB;CAEA,OACE,qBAAC,OAAD;EAAK,oBAAA;EAAiB,wBAAA;EAAqB,WAAW,GAAG,YAAY,SAAS;EAA9E,UAAA;GACG,UAAU,oBAAC,OAAD;IAAK,WAAU;IAAiD,UAAA;GAAY,CAAA;GACvF,oBAAC,SAAD;IACE,GAAI;IACJ,KAAK;IACL,MAAK;IACE;IACP,WAAW,GACT,wMACA,UAAU,QACV,iBACC,aAAa,WAAW,SACzB,aAAa,UAAU,OACzB;IACA,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACD,oBAAC,SAAD;IACE,KAAK;IACL,MAAK;IACL,UAAU;IACV,eAAY;IACZ,WAAU;IACV,OAAO,qBAAqB,KAAK;IACjC,WAAW,UAAU,WAAW,MAAM,OAAO,KAAK;GACnD,CAAA;GACA,UACC,oBAAC,OAAD;IAAK,WAAW,GAAG,wCAAwC,YAAY,aAAa,SAAS;IAAI,UAAA;GAAY,CAAA;GAE9G,aAAa,oBAAC,QAAD;IAAM,WAAU;IAA+C,UAAA,oBAAC,kBAAD;KAAkB,GAAK,aAAa,EAAE,WAAW,IAAI,CAAC;KAAI,eAAe;MAAE,IAAI,SAAS,QAAQ;WAAQ,WAAW,EAAE;MAAG,WAAW,SAAS,MAAM;KAAG;IAAI,CAAA;GAAO,CAAA;GAC7O,oBAAC,UAAD;IACE,MAAK;IACL,cAAY;IACZ,UAAU,MAAM,YAAY,MAAM;IAClC,WAAW,GACT,6HACA,eACF;IACA,eAAe;KACb,WAAW,SAAS,MAAM;KAC1B,UAAU,SAAS,aAAa;IAClC;IAEA,UAAA,oBAAC,MAAD;KAAM,MAAM;KAAY,WAAU;IAAW,CAAA;GACvC,CAAA;EACL;;AAET,CACF;AAEA,eAAe,cAAc;AAE7B,SAAS,qBAAqB,OAAe;CAC3C,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,YAAY,SAAS,QAAQ,WAAW,KAAK,GAAG,OAAO;CAE3D,MAAM,WAAW,sBAAsB,KAAK,OAAO,IAAI,GAAG,QAAQ,UAAU;CAE5E,OAAO,iCAAiC,KAAK,QAAQ,IAAI,SAAS,MAAM,GAAG,EAAE,IAAI;AACnF"}
1
+ {"version":3,"file":"DateTimePicker.js","names":[],"sources":["../../src/components/DateTimePicker.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { DATE_TIME_PICKER_DATE_MATH_PRESETS } from \"./date-math\";\nimport { DateInputField, type DateFieldProps } from \"./date-input-field\";\n\nexport type DateTimePickerProps = DateFieldProps;\n\nexport const DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\n (\n {\n openButtonLabel = \"Open time picker\",\n dateMathPresets = DATE_TIME_PICKER_DATE_MATH_PRESETS,\n ...props\n },\n ref,\n ) => (\n <DateInputField\n {...props}\n ref={ref}\n openButtonLabel={openButtonLabel}\n dateMathPresets={dateMathPresets}\n withTime\n />\n ),\n);\n\nDateTimePicker.displayName = \"DateTimePicker\";\n"],"mappings":";;;;;AAMA,IAAa,iBAAiB,YAE1B,EACE,kBAAkB,oBAClB,kBAAkB,oCAClB,GAAG,SAEL,QAEA,oBAAC,gBAAD;CACE,GAAI;CACC;CACY;CACA;CACjB,UAAA;AACD,CAAA,CAEL;AAEA,eAAe,cAAc"}