@alepha/ui 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/$pageAccount.d.ts +1 -1
- package/dist/account/$pageAccount.d.ts.map +1 -1
- package/dist/account/$pageAccount.js.map +1 -1
- package/dist/account/AccountDisplay.d.ts +13 -0
- package/dist/account/AccountDisplay.d.ts.map +1 -0
- package/dist/account/AccountDisplay.js +48 -0
- package/dist/account/AccountDisplay.js.map +1 -0
- package/dist/account/AccountProfile.d.ts.map +1 -1
- package/dist/account/AccountProfile.js +14 -10
- package/dist/account/AccountProfile.js.map +1 -1
- package/dist/account/AccountRouter.d.ts +6 -6
- package/dist/account/AccountRouter.d.ts.map +1 -1
- package/dist/account/index.d.ts +5 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +2 -1
- package/dist/admin/$pageAdmin.d.ts +1 -1
- package/dist/admin/$pageAdmin.d.ts.map +1 -1
- package/dist/admin/$pageAdmin.js.map +1 -1
- package/dist/admin/AdminAudits.js.map +1 -1
- package/dist/admin/AdminJobDetail.js.map +1 -1
- package/dist/admin/AdminJobs.js.map +1 -1
- package/dist/admin/AdminNotifications.js.map +1 -1
- package/dist/admin/AdminRouter.d.ts +14 -14
- package/dist/admin/AdminRouter.d.ts.map +1 -1
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/admin/AdminUsers.js.map +1 -1
- package/dist/admin/ParameterHistoryItem.js.map +1 -1
- package/dist/ai/AiChat.d.ts +26 -39
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +65 -123
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatDock.d.ts +23 -0
- package/dist/ai/AiChatDock.d.ts.map +1 -0
- package/dist/ai/AiChatDock.js +90 -0
- package/dist/ai/AiChatDock.js.map +1 -0
- package/dist/ai/AiChatDockSlot.d.ts +15 -0
- package/dist/ai/AiChatDockSlot.d.ts.map +1 -0
- package/dist/ai/AiChatDockSlot.js +20 -0
- package/dist/ai/AiChatDockSlot.js.map +1 -0
- package/dist/ai/AiChatLauncher.d.ts +17 -0
- package/dist/ai/AiChatLauncher.d.ts.map +1 -0
- package/dist/ai/AiChatLauncher.js +42 -0
- package/dist/ai/AiChatLauncher.js.map +1 -0
- package/dist/ai/AiChatMessage.d.ts +7 -1
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +27 -7
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/AiChatPanel.d.ts +71 -0
- package/dist/ai/AiChatPanel.d.ts.map +1 -0
- package/dist/ai/AiChatPanel.js +143 -0
- package/dist/ai/AiChatPanel.js.map +1 -0
- package/dist/ai/index.d.ts +8 -4
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -1
- package/dist/ai/useAiChat.d.ts +17 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +38 -17
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/auth/AuthLogin.d.ts +9 -0
- package/dist/auth/AuthLogin.d.ts.map +1 -1
- package/dist/auth/AuthLogin.js +2 -2
- package/dist/auth/AuthLogin.js.map +1 -1
- package/dist/auth/AuthRegister.d.ts +4 -1
- package/dist/auth/AuthRegister.d.ts.map +1 -1
- package/dist/auth/AuthRegister.js +1 -1
- package/dist/auth/AuthRegister.js.map +1 -1
- package/dist/auth/AuthResetPassword.d.ts +8 -0
- package/dist/auth/AuthResetPassword.d.ts.map +1 -1
- package/dist/auth/AuthResetPassword.js +2 -2
- package/dist/auth/AuthResetPassword.js.map +1 -1
- package/dist/auth/AuthRouter.d.ts +4 -4
- package/dist/auth/AuthRouter.d.ts.map +1 -1
- package/dist/core/Badge.d.ts.map +1 -1
- package/dist/core/Badge.js +7 -3
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Collapsible.d.ts +50 -0
- package/dist/core/Collapsible.d.ts.map +1 -0
- package/dist/core/Collapsible.js +70 -0
- package/dist/core/Collapsible.js.map +1 -0
- package/dist/core/Combobox.d.ts +7 -1
- package/dist/core/Combobox.d.ts.map +1 -1
- package/dist/core/Combobox.js +2 -2
- package/dist/core/Combobox.js.map +1 -1
- package/dist/core/PaneRail.d.ts +24 -7
- package/dist/core/PaneRail.d.ts.map +1 -1
- package/dist/core/PaneRail.js +24 -19
- package/dist/core/PaneRail.js.map +1 -1
- package/dist/core/Stepper.d.ts +36 -0
- package/dist/core/Stepper.d.ts.map +1 -0
- package/dist/core/Stepper.js +54 -0
- package/dist/core/Stepper.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/useToast.js +13 -13
- package/dist/core/useToast.js.map +1 -1
- package/dist/form/AutoForm.d.ts.map +1 -1
- package/dist/form/AutoForm.js +29 -0
- package/dist/form/AutoForm.js.map +1 -1
- package/dist/form/AutoFormErrorPopover.js +13 -3
- package/dist/form/AutoFormErrorPopover.js.map +1 -1
- package/dist/form/Control.d.ts +14 -1
- package/dist/form/Control.d.ts.map +1 -1
- package/dist/form/Control.js +12 -2
- package/dist/form/Control.js.map +1 -1
- package/dist/form/ControlDate.d.ts.map +1 -1
- package/dist/form/ControlDate.js +3 -0
- package/dist/form/ControlDate.js.map +1 -1
- package/dist/form/ControlDateRange.d.ts +12 -1
- package/dist/form/ControlDateRange.d.ts.map +1 -1
- package/dist/form/ControlDateRange.js +11 -1
- package/dist/form/ControlDateRange.js.map +1 -1
- package/dist/form/ControlNumber.d.ts.map +1 -1
- package/dist/form/ControlNumber.js +2 -0
- package/dist/form/ControlNumber.js.map +1 -1
- package/dist/form/ControlObject.d.ts.map +1 -1
- package/dist/form/ControlObject.js +15 -1
- package/dist/form/ControlObject.js.map +1 -1
- package/dist/form/ControlPassword.d.ts +4 -0
- package/dist/form/ControlPassword.d.ts.map +1 -1
- package/dist/form/ControlPassword.js +1 -0
- package/dist/form/ControlPassword.js.map +1 -1
- package/dist/form/ControlSelect.d.ts +23 -1
- package/dist/form/ControlSelect.d.ts.map +1 -1
- package/dist/form/ControlSelect.js +5 -0
- package/dist/form/ControlSelect.js.map +1 -1
- package/dist/form/ControlSelectCombobox.d.ts +11 -1
- package/dist/form/ControlSelectCombobox.d.ts.map +1 -1
- package/dist/form/ControlSelectCombobox.js +9 -1
- package/dist/form/ControlSelectCombobox.js.map +1 -1
- package/dist/form/ControlUpload.d.ts.map +1 -1
- package/dist/form/ControlUpload.js +1 -0
- package/dist/form/ControlUpload.js.map +1 -1
- package/dist/form/FormField.d.ts +5 -0
- package/dist/form/FormField.d.ts.map +1 -1
- package/dist/form/FormField.js +7 -0
- package/dist/form/FormField.js.map +1 -1
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +15 -0
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/shell/$pageNav.d.ts +2 -2
- package/dist/shell/$pageNav.d.ts.map +1 -1
- package/dist/shell/$pageNav.js.map +1 -1
- package/dist/shell/AppShell.d.ts +6 -0
- package/dist/shell/AppShell.d.ts.map +1 -1
- package/dist/shell/AppShell.js +31 -27
- package/dist/shell/AppShell.js.map +1 -1
- package/dist/shell/ButtonSettings.d.ts +6 -2
- package/dist/shell/ButtonSettings.d.ts.map +1 -1
- package/dist/shell/ButtonSettings.js +17 -3
- package/dist/shell/ButtonSettings.js.map +1 -1
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts +16 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.d.ts.map +1 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js +24 -0
- package/dist/shell/ButtonSettingsVisionMenuItem.js.map +1 -0
- package/dist/shell/ButtonVision.d.ts +28 -0
- package/dist/shell/ButtonVision.d.ts.map +1 -0
- package/dist/shell/ButtonVision.js +46 -0
- package/dist/shell/ButtonVision.js.map +1 -0
- package/dist/shell/index.d.ts +6 -3
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -1
- package/dist/styles.css +57 -0
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +29 -4
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableColumnPicker.d.ts.map +1 -1
- package/dist/table/DataTableColumnPicker.js +1 -0
- package/dist/table/DataTableColumnPicker.js.map +1 -1
- package/dist/table/DataTableFilterBar.d.ts +1 -1
- package/dist/table/DataTableFilterBar.d.ts.map +1 -1
- package/dist/table/DataTableFilterBar.js +5 -108
- package/dist/table/DataTableFilterBar.js.map +1 -1
- package/dist/table/DataTableHeaderFilter.d.ts +51 -0
- package/dist/table/DataTableHeaderFilter.d.ts.map +1 -0
- package/dist/table/DataTableHeaderFilter.js +113 -0
- package/dist/table/DataTableHeaderFilter.js.map +1 -0
- package/dist/table/DataTableHeaderRow.d.ts +7 -0
- package/dist/table/DataTableHeaderRow.d.ts.map +1 -1
- package/dist/table/DataTableHeaderRow.js +92 -74
- package/dist/table/DataTableHeaderRow.js.map +1 -1
- package/dist/table/DataTableTabs.d.ts +42 -0
- package/dist/table/DataTableTabs.d.ts.map +1 -0
- package/dist/table/DataTableTabs.js +55 -0
- package/dist/table/DataTableTabs.js.map +1 -0
- package/dist/table/dataTableBaseProps.d.ts +12 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.d.ts.map +1 -1
- package/dist/table/dataTablePersistence.js +4 -2
- package/dist/table/dataTablePersistence.js.map +1 -1
- package/dist/table/dataTableTypes.d.ts +18 -0
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/index.d.ts +5 -2
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +2 -1
- package/dist/table/useDataTableColumns.d.ts.map +1 -1
- package/dist/table/useDataTableColumns.js +1 -0
- package/dist/table/useDataTableColumns.js.map +1 -1
- package/dist/table/useDataTableFilterModel.d.ts +110 -0
- package/dist/table/useDataTableFilterModel.d.ts.map +1 -0
- package/dist/table/useDataTableFilterModel.js +154 -0
- package/dist/table/useDataTableFilterModel.js.map +1 -0
- package/docs/packages-alepha-ui-account.md +4 -0
- package/docs/packages-alepha-ui-ai.md +5 -5
- package/docs/packages-alepha-ui-shell.md +4 -3
- package/docs/packages-alepha-ui-table.md +4 -2
- package/package.json +8 -8
- package/src/account/$pageAccount.tsx +5 -4
- package/src/account/AccountDisplay.tsx +58 -0
- package/src/account/AccountProfile.tsx +30 -42
- package/src/account/__tests__/AccountProfile.browser.spec.tsx +141 -0
- package/src/account/__tests__/AccountRecoveryCodes.browser.spec.tsx +1 -1
- package/src/account/index.ts +5 -0
- package/src/admin/$pageAdmin.tsx +5 -4
- package/src/admin/AdminAudits.tsx +1 -1
- package/src/admin/AdminJobDetail.tsx +1 -1
- package/src/admin/AdminJobs.tsx +1 -1
- package/src/admin/AdminNotifications.tsx +1 -1
- package/src/admin/AdminUserDetail.tsx +1 -1
- package/src/admin/AdminUsers.tsx +1 -1
- package/src/admin/ParameterHistoryItem.tsx +1 -1
- package/src/admin/__tests__/AdminFilesUsageCard.browser.spec.tsx +17 -9
- package/src/ai/AiChat.tsx +94 -183
- package/src/ai/AiChatDock.tsx +129 -0
- package/src/ai/AiChatDockSlot.tsx +23 -0
- package/src/ai/AiChatLauncher.tsx +58 -0
- package/src/ai/AiChatMessage.tsx +48 -9
- package/src/ai/AiChatPanel.tsx +252 -0
- package/src/ai/__tests__/AiChat.browser.spec.tsx +197 -5
- package/src/ai/index.ts +8 -4
- package/src/ai/useAiChat.ts +80 -14
- package/src/auth/AuthLogin.tsx +19 -4
- package/src/auth/AuthRegister.tsx +6 -3
- package/src/auth/AuthResetPassword.tsx +18 -8
- package/src/auth/__tests__/AuthCancel.browser.spec.tsx +129 -0
- package/src/core/Badge.tsx +7 -3
- package/src/core/Collapsible.tsx +95 -0
- package/src/core/Combobox.tsx +11 -3
- package/src/core/PaneRail.tsx +36 -20
- package/src/core/Stepper.tsx +118 -0
- package/src/core/__tests__/Badge.browser.spec.tsx +5 -5
- package/src/core/__tests__/Collapsible.browser.spec.tsx +88 -0
- package/src/core/__tests__/PaneRail.browser.spec.tsx +48 -0
- package/src/core/__tests__/Stepper.browser.spec.tsx +39 -0
- package/src/core/__tests__/primitiveSlots.spec.ts +7 -0
- package/src/core/index.ts +15 -0
- package/src/form/AutoForm.tsx +32 -0
- package/src/form/AutoFormErrorPopover.tsx +27 -6
- package/src/form/Control.tsx +22 -0
- package/src/form/ControlDate.tsx +3 -0
- package/src/form/ControlDateRange.tsx +87 -58
- package/src/form/ControlNumber.tsx +2 -0
- package/src/form/ControlObject.tsx +20 -1
- package/src/form/ControlPassword.tsx +5 -0
- package/src/form/ControlSelect.tsx +32 -1
- package/src/form/ControlSelectCombobox.tsx +82 -56
- package/src/form/ControlUpload.tsx +1 -0
- package/src/form/FormField.tsx +23 -1
- package/src/form/__tests__/ControlFieldErrors.browser.spec.tsx +253 -0
- package/src/form/__tests__/ControlValidateMode.browser.spec.tsx +217 -0
- package/src/form/__tests__/ControlVariantErrors.browser.spec.tsx +133 -0
- package/src/i18n/fr/uiFr.ts +19 -1
- package/src/markdown/css.d.ts +11 -0
- package/src/shell/$pageNav.tsx +6 -4
- package/src/shell/AppShell.tsx +7 -0
- package/src/shell/ButtonSettings.tsx +20 -5
- package/src/shell/ButtonSettingsVisionMenuItem.tsx +40 -0
- package/src/shell/ButtonVision.tsx +73 -0
- package/src/shell/__tests__/ButtonSettings.browser.spec.tsx +42 -2
- package/src/shell/__tests__/ButtonVision.browser.spec.tsx +73 -0
- package/src/shell/__tests__/visionTokens.spec.ts +104 -0
- package/src/shell/index.ts +6 -3
- package/src/styles.css +57 -0
- package/src/table/DataTable.tsx +52 -4
- package/src/table/DataTableColumnPicker.tsx +3 -0
- package/src/table/DataTableFilterBar.tsx +18 -191
- package/src/table/DataTableHeaderFilter.tsx +156 -0
- package/src/table/DataTableHeaderRow.tsx +78 -40
- package/src/table/DataTableTabs.tsx +114 -0
- package/src/table/__tests__/DataTableHeaderFilter.browser.spec.tsx +174 -0
- package/src/table/__tests__/DataTableStaleColumns.browser.spec.tsx +80 -0
- package/src/table/__tests__/DataTableTabs.browser.spec.tsx +72 -0
- package/src/table/dataTableBaseProps.ts +12 -0
- package/src/table/dataTablePersistence.ts +11 -5
- package/src/table/dataTableTypes.ts +18 -0
- package/src/table/index.ts +9 -2
- package/src/table/useDataTableColumns.ts +1 -0
- package/src/table/useDataTableFilterModel.tsx +240 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.d.ts","sourceRoot":"","sources":["../../src/form/Control.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAOf,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKvE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI7E,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,gBAAgB,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,C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P,IAAI,CACF,kBAAkB,EAClB,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CACpD,CAAC;CACP;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAW,YAAY,cAsjB1C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,UACrB,cAAc,GAAG,SAAS,KAChC,OAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,UAAW,cAAc,GAAG,SAAS,SAWzE,CAAC"}
|
package/dist/form/Control.js
CHANGED
|
@@ -55,6 +55,7 @@ const Control = (props) => {
|
|
|
55
55
|
if (merged.custom) {
|
|
56
56
|
const Custom = merged.custom;
|
|
57
57
|
return wrapWithSlots(merged, /* @__PURE__ */ jsx(FormField, {
|
|
58
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
58
59
|
id: meta.id,
|
|
59
60
|
label: merged.label ?? meta.label,
|
|
60
61
|
description: merged.description ?? meta.description,
|
|
@@ -118,7 +119,9 @@ const Control = (props) => {
|
|
|
118
119
|
clearable: merged.clearable,
|
|
119
120
|
placeholder: merged.placeholder,
|
|
120
121
|
triggerClassName: merged.triggerClassName,
|
|
121
|
-
triggerPrefix: props.triggerPrefix
|
|
122
|
+
triggerPrefix: props.triggerPrefix,
|
|
123
|
+
trigger: props.trigger,
|
|
124
|
+
onPopupOpenChange: props.onPopupOpenChange
|
|
122
125
|
}));
|
|
123
126
|
if (merged.select || merged.combobox || merged.segmented || merged.checkboxes || meta.isEnum || meta.isArray && !meta.isArrayOfObjects || items != null) return wrapWithSlots(merged, /* @__PURE__ */ jsx(ControlSelect, {
|
|
124
127
|
input: props.input,
|
|
@@ -143,9 +146,12 @@ const Control = (props) => {
|
|
|
143
146
|
triggerProps: merged.inputProps,
|
|
144
147
|
popupHeader: props.popupHeader,
|
|
145
148
|
triggerPrefix: props.triggerPrefix,
|
|
146
|
-
popupClassName: merged.popupClassName
|
|
149
|
+
popupClassName: merged.popupClassName,
|
|
150
|
+
trigger: props.trigger,
|
|
151
|
+
onPopupOpenChange: props.onPopupOpenChange
|
|
147
152
|
}));
|
|
148
153
|
if (meta.type === "boolean" && merged.switch !== false) return wrapWithSlots(merged, /* @__PURE__ */ jsx(FormField, {
|
|
154
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
149
155
|
id: meta.id,
|
|
150
156
|
label: merged.label ?? meta.label,
|
|
151
157
|
description: merged.description ?? meta.description,
|
|
@@ -180,6 +186,7 @@ const Control = (props) => {
|
|
|
180
186
|
birthdate: merged.birthdate
|
|
181
187
|
}));
|
|
182
188
|
if (merged.file) return wrapWithSlots(merged, /* @__PURE__ */ jsx(FormField, {
|
|
189
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
183
190
|
id: meta.id,
|
|
184
191
|
label: merged.label ?? meta.label,
|
|
185
192
|
description: merged.description ?? meta.description,
|
|
@@ -198,6 +205,7 @@ const Control = (props) => {
|
|
|
198
205
|
if (merged.area || maxLength > 256) {
|
|
199
206
|
const rows = merged.rows ?? (maxLength > 1024 ? 6 : maxLength > 512 ? 4 : 2);
|
|
200
207
|
return wrapWithSlots(merged, /* @__PURE__ */ jsx(FormField, {
|
|
208
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
201
209
|
id: meta.id,
|
|
202
210
|
label: merged.label ?? meta.label,
|
|
203
211
|
description: merged.description ?? meta.description,
|
|
@@ -225,6 +233,7 @@ const Control = (props) => {
|
|
|
225
233
|
}));
|
|
226
234
|
}
|
|
227
235
|
if (merged.password || meta.iconHint === "password" || meta.format === "password") return wrapWithSlots(merged, /* @__PURE__ */ jsx(ControlPassword, {
|
|
236
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
228
237
|
id: meta.id,
|
|
229
238
|
name: props.input.props.name,
|
|
230
239
|
label: merged.label ?? meta.label,
|
|
@@ -256,6 +265,7 @@ const Control = (props) => {
|
|
|
256
265
|
const showTrailing = !showSave && !showClear && merged.trailing != null;
|
|
257
266
|
const reserveGutter = showSave || showTrailing;
|
|
258
267
|
return wrapWithSlots(merged, /* @__PURE__ */ jsx(FormField, {
|
|
268
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
259
269
|
id: meta.id,
|
|
260
270
|
label: merged.label ?? meta.label,
|
|
261
271
|
description: merged.description ?? meta.description,
|
package/dist/form/Control.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.js","names":[],"sources":["../../src/form/Control.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport { useAlepha } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { resolveSchemaControl, type SchemaControl } from \"alepha/react/ui\";\nimport { Check, X } from \"lucide-react\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useState,\n} from \"react\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Switch } from \"../core/Switch.tsx\";\nimport { Textarea } from \"../core/Textarea.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { ControlArray, type ControlArrayProps } from \"./ControlArray.tsx\";\nimport { ControlDate, type ControlDateProps } from \"./ControlDate.tsx\";\nimport { ControlDateRange } from \"./ControlDateRange.tsx\";\nimport { ControlNumber } from \"./ControlNumber.tsx\";\nimport { ControlObject } from \"./ControlObject.tsx\";\nimport { ControlPassword } from \"./ControlPassword.tsx\";\nimport {\n ControlSelect,\n type ControlSelectSize,\n type SelectOption,\n} from \"./ControlSelect.tsx\";\nimport { ControlUpload, type ControlUploadProps } from \"./ControlUpload.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport { useFormFieldAutoSave } from \"./FormFieldAutoSaveProvider.tsx\";\nimport { useFormFieldLayout } from \"./FormFieldLayoutProvider.tsx\";\nimport { type IconComponent, iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlProps {\n /**\n * Bound `InputField` from `useForm`. Carries value, schema, and error state.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title` or the field name.\n */\n label?: string;\n /**\n * Helper text shown below the control. Falls back to schema `description`.\n */\n description?: string;\n /**\n * Force a specific input variant — renders a single-line text input.\n */\n text?: boolean;\n /**\n * Force a textarea.\n */\n area?: boolean;\n /**\n * Force a masked password input.\n */\n password?: boolean;\n /**\n * Force a `<Switch>` (boolean toggle).\n */\n switch?: boolean;\n /**\n * Force a numeric input.\n */\n number?: boolean;\n /**\n * Force the file-upload control (alias for `upload`).\n */\n file?: boolean;\n /**\n * The file picker's `accept` filter (`\".csv,text/csv\"`, `\"image/*\"`), for\n * `file` and for `upload`; an `upload` object's own `accept` wins.\n */\n accept?: string;\n /**\n * Force a date picker.\n */\n date?: boolean;\n /**\n * Force a date-time picker.\n */\n datetime?: boolean;\n /**\n * Force a date-range picker, regardless of the schema's format.\n *\n * Rarely needed: `z.dateRange()` tags the array itself, so the control\n * selects itself. Here for the same reason `date` and `datetime` are - a\n * field whose schema is a plain pair of strings can still ask for it.\n */\n dateRange?: boolean;\n /**\n * Force a month picker: the value is `YYYY-MM`.\n */\n month?: boolean;\n /**\n * Force a time picker.\n */\n time?: boolean;\n /**\n * Date picker caption style — `\"dropdown\"` swaps the month arrows for\n * month/year selects. See {@link ControlDateProps.captionLayout}.\n */\n captionLayout?: ControlDateProps[\"captionLayout\"];\n /** First selectable month of a date picker. */\n startMonth?: Date;\n /** Last selectable month of a date picker. */\n endMonth?: Date;\n /**\n * Date-of-birth shorthand: a year dropdown covering the last 120 years.\n * See {@link ControlDateProps.birthdate}.\n */\n birthdate?: boolean;\n /**\n * Force a `<Select>`.\n */\n select?: boolean;\n /**\n * Force a combobox (searchable select). Alias for `searchable: true`.\n */\n combobox?: boolean;\n /**\n * Force the select's search input on or off. Defaults to \"auto\" — on for an\n * async list, when `createNewEntry` is set, or above ~50 options.\n */\n searchable?: boolean;\n /**\n * Force a `<Segmented>` control (one option visible at a time).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array of options) as a group of\n * checkboxes, every option visible. See `ControlSelectProps.checkboxes`.\n */\n checkboxes?: boolean;\n /**\n * Force a slider (numeric only).\n */\n slider?: boolean;\n /**\n * Force a nested `<ControlObject>` for object-typed schemas.\n */\n object?: boolean;\n /**\n * Force a nested `<ControlArray>` for array-typed schemas.\n */\n array?: boolean;\n /**\n * Props forwarded to the nested `<ControlObject>`, keyed by child field name.\n * This is the only way to reach INSIDE an object field — without it a caller\n * can style/override the object as a whole but never one of its children\n * (e.g. attaching a `custom` widget to `payg.zoneFareCents`).\n */\n /**\n * Dictionary prefix for schema-generated labels/help: this field reads\n * `<prefix>.<name>` and `<prefix>.<name>.desc`, and passes the extended\n * prefix down into nested objects and array items.\n */\n i18nPrefix?: string;\n objectProps?: {\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n variant?: \"fieldset\" | \"plain\";\n defaultExpanded?: boolean;\n };\n /**\n * Custom render component receiving `{value, onChange}`.\n */\n custom?: ComponentType<{ value: unknown; onChange: (v: unknown) => void }>;\n /**\n * Override icon — pass `null` to remove the schema-inferred icon.\n */\n icon?: IconComponent | string | null;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Render slot before the control.\n */\n top?: ReactNode;\n /**\n * Render slot after the control.\n */\n bottom?: ReactNode;\n /**\n * A status drawn inside the right end of a text input, such as a tick or a\n * cross saying whether the value is accepted. Decoration only: it takes no\n * pointer events, so put anything the reader must act on in `bottom`.\n *\n * The auto-save tick and the clear button own that corner when they show,\n * and hide it meanwhile. The input reserves its gutter while it is drawn.\n */\n trailing?: ReactNode;\n /**\n * An error to show now, drawn exactly like a validation error. Wins over\n * the form's own, which only exists once the form has been submitted: a\n * multi-step wizard whose Next is not a submit uses this to refuse a value\n * the moment it is typed.\n */\n error?: string;\n /**\n * Width slot inside an `<AutoForm>` group (mapped to a CSS grid column\n * span). Read by the parent group; ignored when rendering standalone.\n */\n width?: 100 | 75 | 66 | 50 | 33 | 25;\n /**\n * HTML `autocomplete` hint passed to the underlying input.\n */\n autoComplete?: string;\n /**\n * Placeholder text. On a text-shaped control this is the HTML\n * `placeholder`; on a select it is the trigger text shown while nothing is\n * picked.\n */\n placeholder?: string;\n /**\n * Autofocus the control on mount. Forwarded to the text, number, password\n * or textarea input the control renders. Ignored by the variants that are\n * not a single focusable field (select, date, upload, array, object).\n *\n * Every forward site carries an `oxlint-disable-next-line\n * jsx-a11y/no-autofocus`. That rule is right about a page that grabs focus\n * unbidden and wrong here: nothing focuses unless a caller passed this prop,\n * and it is the caller the rule should be asking. Left to fire, it did real\n * damage once - a lint pass deleted the forwarding and left the prop\n * declared, so login and dialog forms silently stopped focusing their first\n * field and two components grew `getElementById(...).focus()` workarounds.\n */\n autoFocus?: boolean;\n /**\n * Visible row count for the textarea variant. Overrides the value\n * auto-derived from the schema's `maxLength`. Ignored by other variants.\n */\n rows?: number;\n /**\n * Escape hatch — extra native attributes (event handlers, `className`,\n * `aria-*`, `data-*`, `style`, …) forwarded to whichever element the\n * control actually renders (text input / textarea / password input). The\n * form bindings (`value`, `onChange`, `id`, `name`) always win and cannot\n * be overridden here.\n *\n * `data-*` is spelled out because `HTMLAttributes` does not carry it:\n * TypeScript special-cases dashed attributes in JSX only, so an object\n * literal `{ \"data-testid\": … }` is an excess property and fails to\n * compile. Without this a control cannot carry a test hook, which meant a\n * surface with an e2e had to keep a raw `<input>` rather than adopt the\n * shared control.\n *\n * ⚠️ **`autoComplete` does not go here.** `Control` takes it as a\n * first-class prop, and `ControlPassword` writes its own after spreading\n * this object - so a value passed through `inputProps` is silently\n * replaced by `\"current-password\"`, which on a field holding a deploy\n * token is the password-manager prompt the masking exists to avoid.\n */\n inputProps?: HTMLAttributes<HTMLElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n };\n /**\n * Allow user to create new entries in select / multi-select.\n */\n createNewEntry?: boolean | ((query: string) => unknown);\n /**\n * Inline option list for select / combobox controls. Infer array or\n * async loader. Overrides schema-derived `enum` when present.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Whether the field offers a way back to empty.\n *\n * On a `ControlSelect`, `true` adds a synthetic \"none\" row that resets the\n * field to `undefined` — use it for optional filter chips.\n *\n * On a text field the affordance is the opposite way round: an optional\n * field already shows a clear (×) button whenever it holds a value, and\n * `false` takes it away. Pass `false` when emptying the field is not\n * something the API can honour — a username has no \"unset\" on the server,\n * so offering the button would promise an edit that silently does nothing.\n */\n clearable?: boolean;\n /**\n * Forwarded to `ControlSelect` — label of the `clearable` row, also\n * used as the empty-state trigger placeholder. Defaults to \"None\".\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * Forwarded to `ControlSelect`: the longest joined text a multi-select\n * trigger names its selection with before it collapses to `countLabel`.\n * Defaults to 20.\n */\n maxTriggerLength?: number;\n /**\n * Forwarded to `ControlSelect` — extra className on the trigger.\n * Useful for sizing filter chips inline.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale, for the select-shaped controls. Defaults\n * to `default`; `xs` is for a control that sits ON a row of text rather\n * than in a form.\n */\n size?: ControlSelectSize;\n /**\n * Render the select trigger borderless and transparent, so it reads as the\n * row it sits on rather than as a form field. Pairs with `size=\"xs\"`.\n */\n minimal?: boolean;\n /**\n * Forwarded to `ControlSelect`: drawn at the top of a select's popup, for\n * a setting that changes what the choice means (a filter's \"is / is not\").\n */\n popupHeader?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: a short qualifier drawn before the\n * selected label on the trigger (\"not Active\").\n */\n triggerPrefix?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: extra className on a select's popup, e.g.\n * `w-max min-w-48` to size it from its content rather than its trigger.\n */\n popupClassName?: string;\n /**\n * Render a managed upload control (image preview, multi, drag-drop)\n * that calls `FileController.uploadFile` and stores the file ID(s) in\n * the form value. Pass `true` for defaults or an options object.\n */\n upload?:\n | boolean\n | Pick<\n ControlUploadProps,\n \"multi\" | \"accept\" | \"maxSize\" | \"bucket\" | \"image\"\n >;\n}\n\n/**\n * Schema-driven form field renderer. Inspects the bound `InputField` from\n * `useForm`, evaluates `schema.$control` (object or function), merges the\n * result with explicit props, and dispatches to the right sub-control.\n */\nexport const Control = (props: ControlProps) => {\n const form = useFormState(props.input, [\"error\", \"dirty\"]);\n const autoSaveEnabled = useFormFieldAutoSave();\n const rowLayout = useFormFieldLayout() === \"row\";\n const [value, setValue] = useFieldValue(props.input);\n\n // Function-form `$control` reads other fields → re-render on any\n // change. Infer `$control` (object) does not need this subscription.\n useDynamicControlRefresh(props.input);\n\n if (!props.input?.props) return null;\n\n const parsed = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n const meta = props.error ? { ...parsed, error: props.error } : parsed;\n\n // ── Resolve $control (object | function | false) ─────────────────\n const resolved = resolveSchemaControl(meta.control, {\n form: props.input.form,\n value,\n });\n // `null` is gone, `hidden` is present-but-invisible. A control renders\n // nothing for either; only the LAYOUT tells them apart.\n if (resolved === null || resolved.hidden) return null;\n\n const merged = {\n ...props,\n ...(resolved as Partial<ControlProps>),\n } as ControlProps & Partial<SchemaControl>;\n\n // ── Custom escape hatch ──────────────────────────────────────────\n if (merged.custom) {\n const Custom = merged.custom;\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Custom value={value} onChange={(v) => setValue(v)} />\n </FormField>,\n );\n }\n\n // ── Recursive: object / array of objects ─────────────────────────\n if (merged.object || meta.isObject) {\n return wrapWithSlots(\n merged,\n <ControlObject\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n i18nPrefix={merged.i18nPrefix}\n controlProps={merged.objectProps?.controlProps}\n variant={merged.objectProps?.variant}\n defaultExpanded={merged.objectProps?.defaultExpanded}\n clearable={merged.clearable}\n />,\n );\n }\n if (merged.array || meta.isArrayOfObjects) {\n const arrayProps = (merged as { arrayProps?: Record<string, unknown> })\n .arrayProps;\n return wrapWithSlots(\n merged,\n <ControlArray\n input={props.input}\n i18nPrefix={merged.i18nPrefix}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n confirmDelete={\n arrayProps?.confirmDelete as ControlArrayProps[\"confirmDelete\"]\n }\n renderTabName={\n arrayProps?.renderTabName as ControlArrayProps[\"renderTabName\"]\n }\n forceTabs={arrayProps?.forceTabs as boolean | undefined}\n />,\n );\n }\n\n // ── File: managed upload (image preview, multi, drag-drop) ──────\n // Checked early so it wins over the array→combobox branch below\n // when the schema is `z.array(z.string())` with $control.upload.\n if (merged.upload) {\n const uploadOpts =\n typeof merged.upload === \"object\"\n ? (merged.upload as Partial<ControlUploadProps>)\n : {};\n return wrapWithSlots(\n merged,\n <ControlUpload\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n accept={merged.accept}\n {...uploadOpts}\n />,\n );\n }\n\n // ── Items provided → select / multi / combobox ───────────────────\n // Read before the numeric branch, because that branch owns every numeric\n // schema by default and `ControlNumber` has nowhere to put an option list:\n // a `z.number()` field handed `items` used to render a bare spinner and drop\n // the rows on the floor, silently. An explicit list is an explicit request\n // for a select, so it wins - `slider` / `number` still override it below.\n const items = (merged as Record<string, unknown>).items as\n | undefined\n | unknown[]\n | ((q: string) => unknown);\n\n // ── Number / slider ──────────────────────────────────────────────\n if (\n merged.slider ||\n merged.number ||\n (!merged.select &&\n !merged.segmented &&\n !merged.combobox &&\n items == null &&\n (meta.type === \"number\" || meta.type === \"integer\"))\n ) {\n return wrapWithSlots(\n merged,\n <ControlNumber\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n slider={merged.slider}\n disabled={merged.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n />,\n );\n }\n\n // ── Date range ───────────────────────────────────────────────────\n //\n // ⚠️ ABOVE the array branch below, and that placement is the whole of it.\n // `z.dateRange()` IS an array, so the `meta.isArray` test twenty lines down\n // matches it first and renders a range as a multi-select combobox - which\n // looks like a deliberate control and is silently the wrong one. Sitting\n // this beside the date branch further down, where it reads as though it\n // belongs, is exactly the mistake.\n //\n // Keyed on the format LITERAL, never on \"array whose items are dates\": that\n // second test cannot tell a range from an ordinary list of two days, and it\n // is what would make a later `date-time-range` a rewrite rather than one\n // more literal plus a `withTime` prop.\n if (merged.dateRange || meta.format === \"date-range\") {\n return wrapWithSlots(\n merged,\n <ControlDateRange\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n clearable={merged.clearable}\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n // From `props`, like the select's below: a node has no place in a\n // schema's `$control`.\n triggerPrefix={props.triggerPrefix}\n />,\n );\n }\n\n if (\n merged.select ||\n merged.combobox ||\n merged.segmented ||\n merged.checkboxes ||\n meta.isEnum ||\n (meta.isArray && !meta.isArrayOfObjects) ||\n items != null\n ) {\n return wrapWithSlots(\n merged,\n <ControlSelect\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n segmented={merged.segmented}\n checkboxes={merged.checkboxes}\n combobox={merged.combobox}\n searchable={merged.searchable}\n items={items as never}\n // Every field carries a leading icon, a select included: the list\n // glyph unless the caller names one or passes `null`. Not on a\n // `minimal` trigger, the toolbar filter chip, which names itself with\n // a `triggerPrefix` and would only get noisier.\n icon={\n merged.minimal\n ? resolveIcon(merged.icon)\n : resolveIcon(merged.icon, \"list\")\n }\n disabled={merged.disabled}\n createNewEntry={\n merged.createNewEntry as boolean | ((q: string) => never) | undefined\n }\n clearable={merged.clearable}\n clearLabel={merged.clearLabel}\n countLabel={merged.countLabel}\n maxTriggerLength={merged.maxTriggerLength}\n // Dropped here until now, so a picker that needed to name its own\n // empty state (\"Pick an epic…\") could not be a `Control` at all.\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n size={merged.size}\n minimal={merged.minimal}\n // Used to be dropped here, silently: every `inputProps={{ \"aria-label\"\n // }}` on a select-shaped Control (the epics and quests status filters\n // among them) named nothing at all, because the trigger is a button\n // with no visible label to borrow a name from.\n triggerProps={merged.inputProps}\n // From `props`, not `merged`: a node has no business in a schema's\n // `$control`, so there is nothing for the merge to contribute.\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={merged.popupClassName}\n />,\n );\n }\n\n // ── Boolean → switch ─────────────────────────────────────────────\n if (meta.type === \"boolean\" && merged.switch !== false) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n // A switch always holds a value, on or off: a required marker on it\n // asks for something the reader cannot fail to give. `aria-required`\n // is left off for the same reason.\n required={false}\n >\n <div className=\"flex h-9 items-center\">\n <Switch\n {...merged.inputProps}\n id={meta.id}\n // Same omission as the numeric control had: without a name the\n // toggle is invisible to `[name=\"…\"]` lookups, including\n // `AutoForm`'s scroll-to-first-error.\n name={props.input.props.name}\n disabled={merged.disabled}\n checked={Boolean(value)}\n onCheckedChange={(v) => setValue(v)}\n />\n </div>\n </FormField>,\n );\n }\n\n // ── Date / time ──────────────────────────────────────────────────\n if (\n merged.date ||\n merged.datetime ||\n merged.time ||\n merged.month ||\n meta.format === \"date\" ||\n meta.format === \"date-time\" ||\n meta.format === \"time\"\n ) {\n return wrapWithSlots(\n merged,\n <ControlDate\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n date={merged.date}\n datetime={merged.datetime}\n time={merged.time}\n month={merged.month}\n inputProps={merged.inputProps}\n disabled={merged.disabled}\n clearable={merged.clearable}\n captionLayout={merged.captionLayout}\n startMonth={merged.startMonth}\n endMonth={merged.endMonth}\n birthdate={merged.birthdate}\n />,\n );\n }\n\n // ── File (raw) ───────────────────────────────────────────────────\n if (merged.file) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Input\n id={meta.id}\n name={props.input.props.name}\n type=\"file\"\n accept={merged.accept}\n disabled={merged.disabled}\n onChange={(e) => setValue(e.target.files?.[0])}\n />\n </FormField>,\n );\n }\n\n // ── Auto-textarea: explicit `area` or maxLength > 256 ────────────\n const maxLength = meta.constraints.maxLength ?? 0;\n if (merged.area || maxLength > 256) {\n const rows =\n merged.rows ?? (maxLength > 1024 ? 6 : maxLength > 512 ? 4 : 2);\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Textarea\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n rows={rows}\n disabled={merged.disabled}\n maxLength={maxLength || undefined}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n onChange={(e) => setValue(e.target.value)}\n />\n </FormField>,\n );\n }\n\n // ── Password ─────────────────────────────────────────────────────\n const isPassword =\n merged.password ||\n meta.iconHint === \"password\" ||\n meta.format === \"password\";\n if (isPassword) {\n return wrapWithSlots(\n merged,\n <ControlPassword\n id={meta.id}\n name={props.input.props.name}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n disabled={merged.disabled}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n inputProps={merged.inputProps}\n icon={resolveIcon(merged.icon, \"password\")}\n value={String(value ?? \"\")}\n onChange={(v) => setValue(v)}\n />,\n );\n }\n\n // ── Default text input with format-driven HTML5 type + icon ──────\n const Icon = resolveIcon(merged.icon, meta.iconHint);\n const htmlType =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : \"text\";\n\n // Derive a sensible HTML `autocomplete` hint from the schema format so\n // password managers and browser autofill behave correctly out of the box.\n // Explicit `autoComplete` prop always wins.\n const autoCompleteFromFormat =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : undefined;\n const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;\n\n // A value typed verbatim (an account identifier, an address, a code) must\n // not be rewritten by the keyboard: iOS capitalises the first letter of a\n // username by default, and a sign-in then fails on \"Test@mobile.test\".\n const verbatim =\n htmlType === \"email\" ||\n htmlType === \"url\" ||\n [\"username\", \"email\", \"tel\", \"url\", \"one-time-code\"].includes(\n autoComplete ?? \"\",\n );\n\n // ── Right-side affordance: tick (when dirty) or clear (when nullable) ─\n // Tick only renders inside an `<AutoForm autoSave>` tree (or any caller\n // that explicitly wraps with `<FormFieldAutoSaveProvider value>`).\n const showSave = autoSaveEnabled && !!form.dirty && !merged.disabled;\n const isNullable =\n !meta.required && value != null && value !== \"\" && !merged.disabled;\n // `clearable !== false`, not `clearable === true`: an optional text field\n // offers the button by default and a caller opts *out* of it. See the prop.\n const showClear = !showSave && isNullable && merged.clearable !== false;\n // The right gutter is reserved only while the tick is drawn, or while the\n // cross is drawn AND the field has focus. Kept on every editable field, it\n // took 36px from the text of each one and cut placeholders short for a\n // button that was not there (\"Rechercher client, terr…\"). At rest the cross\n // floats over the end of the value on a fade instead, so a settings row\n // shows \"Delete project\" rather than \"Delete proj\"; once focused the gutter\n // comes back, since the caret must never sit under the button. The input\n // is border-box, so the padding never changes its width.\n const showTrailing = !showSave && !showClear && merged.trailing != null;\n const reserveGutter = showSave || showTrailing;\n\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n autoCapitalize={verbatim ? \"none\" : undefined}\n autoCorrect={verbatim ? \"off\" : undefined}\n spellCheck={verbatim ? false : undefined}\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n type={htmlType}\n disabled={merged.disabled}\n autoComplete={autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n minLength={meta.constraints.minLength}\n maxLength={meta.constraints.maxLength}\n pattern={meta.constraints.pattern}\n // `cn`, not a plain join: the settings width below has to be\n // overridable by the caller, and only `cn`'s merge can decide\n // that `sm:w-96` beats `sm:w-64` rather than both landing on the\n // element. Order is precedence — later wins.\n className={cn(\n // Row layout is the settings-card shape, whose right-hand cell is\n // an `auto` grid column: `w-full` there resolves against the\n // input's own intrinsic size (~172px), so every card would get a\n // slightly different control column. 256px is the width every\n // hand-written `SettingsRow` already passes; encoded once here.\n // Below `sm` the row stacks, and `w-full` from `<Input>` is right.\n rowLayout && \"sm:w-64\",\n merged.inputProps?.className,\n Icon && \"pl-9\",\n reserveGutter && \"pr-9\",\n showClear && \"focus:pr-9\",\n )}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n merged.inputProps?.onKeyDown?.(e);\n if (e.defaultPrevented || e.key !== \"Enter\") return;\n // The commit the auto-save effect deliberately withholds from a\n // text field on every keystroke. Its comment offers \"Enter or the\n // inline tick button\" as the two ways to commit - and only the\n // tick ever existed. `AutoForm` in auto-save mode renders no\n // submit button, so the browser's implicit submission never fires\n // and Enter did nothing at all, on every text field in every\n // auto-saving form.\n //\n // Guarded on `showSave` so it is inert outside auto-save mode and\n // on a pristine field, where a normal form's own Enter handling\n // must keep working.\n if (!showSave) return;\n e.preventDefault();\n // `props.input.form`, the same handle the tick button submits\n // through. The local `form` is only the `dirty` / `error` slice.\n void props.input.form.submit();\n }}\n />\n {showSave && (\n <button\n type=\"button\"\n onClick={() => props.input.form.submit()}\n aria-label=\"Save\"\n className=\"text-primary hover:text-primary/80 absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <Check className=\"size-3.5\" />\n </button>\n )}\n {showClear && (\n <button\n type=\"button\"\n onClick={() => setValue(undefined)}\n aria-label=\"Clear\"\n // `data-slot` like every other clear in the kit\n // (`combobox-clear`, and `control-clear` on the field trigger).\n // It was the only one without a hook, so the only way to address\n // it was its `aria-label` - which is translated, so a French UI\n // would have matched nothing. Purely an identification hook: no\n // style and no behaviour rides on it here.\n data-slot=\"control-clear\"\n // Over the value, inside the border (`inset-y-px right-px`), on a\n // fade into the surface behind the field (`--surface`, which any\n // element painting a surface token declares, see `styles.css`).\n // In dark the input carries its own\n // `bg-input/30` tint, so the fade stacks that tint over the\n // surface to match it exactly.\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-px right-px flex items-center rounded-r-[calc(var(--radius-lg)-1px)] bg-[linear-gradient(to_right,transparent,var(--surface)_1.25rem)] pr-2.5 pl-6 dark:bg-[linear-gradient(to_right,transparent,color-mix(in_oklab,var(--input)_30%,transparent)_1.25rem),linear-gradient(to_right,transparent,var(--surface)_1.25rem)]\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n {showTrailing && (\n <span\n data-slot=\"control-trailing\"\n className=\"pointer-events-none absolute top-1/2 right-3 flex -translate-y-1/2 items-center\"\n >\n {merged.trailing}\n </span>\n )}\n </div>\n </FormField>,\n );\n};\n\n/**\n * The raw `$control` a field declares, object form or function form.\n *\n * It rides on zod's `.meta()` registry rather than being a plain schema\n * property, and the field may be wrapped (optional / nullable / default), so\n * the wrapper has to be peeled before the meta is readable.\n *\n * Exported because the LAYOUT needs it too: `AutoForm` sizes a grid cell from\n * the width `$control` asks for, and a function-form `$control` has no `.width`\n * to read off the function itself. Pair it with {@link resolveSchemaControl}.\n */\nexport const readSchemaControl = (\n input: BaseInputField | undefined,\n): unknown => {\n const base = input?.schema ? z.schema.unwrap(input.schema) : undefined;\n return (base as { meta?: () => { $control?: unknown } } | undefined)?.meta?.()\n ?.$control;\n};\n\n/**\n * Re-render when a function-form `$control` may have changed its mind, which\n * is on any change to a field OTHER than this one. An object-form `$control`\n * is static and needs no subscription.\n *\n * Exported alongside {@link readSchemaControl}, and for the same reason: a\n * consumer that resolves `$control` itself has to re-resolve on the same\n * events, or it renders a stale answer.\n */\nexport const useDynamicControlRefresh = (input: BaseInputField | undefined) => {\n const alepha = useAlepha();\n const [, bump] = useState(0);\n const isDynamic = typeof readSchemaControl(input) === \"function\";\n useEffect(() => {\n if (!isDynamic || !input?.form) return;\n const formId = input.form.id;\n return alepha.events.on(\"form:changed\", (e) => {\n if (e.id === formId && e.path !== input.path) bump((n) => n + 1);\n });\n }, [alepha, input?.form, input?.path, isDynamic]);\n};\n\nconst resolveIcon = (\n icon: ControlProps[\"icon\"],\n fallback?: string | null,\n): IconComponent | undefined => {\n if (icon === null) return undefined;\n if (typeof icon === \"string\") return iconFor(icon);\n if (icon) return icon;\n return iconFor(fallback);\n};\n\nconst wrapWithSlots = (\n props: ControlProps & Partial<SchemaControl>,\n body: ReactNode,\n): ReactNode => {\n const top = (props.top as ReactNode) ?? null;\n const bottom = (props.bottom as ReactNode) ?? null;\n if (!top && !bottom) return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aAAU;KAOV,WAAU;KAEV,UAAA,oBAAC,GAAD,EAAG,WAAU,WAAY,CAAA;IACnB,CAAA;IAET,gBACC,oBAAC,QAAD;KACE,aAAU;KACV,WAAU;KAET,UAAA,OAAO;IACJ,CAAA;GAEL;;CACI,CAAA,CACb;AACF;;;;;;;;;;;;AAaA,MAAa,qBACX,UACY;CAEZ,QADa,OAAO,SAAS,EAAE,OAAO,OAAO,MAAM,MAAM,IAAI,KAAA,EAAA,EACS,OAAO,CAAC,EAC1E;AACN;;;;;;;;;;AAWA,MAAa,4BAA4B,UAAsC;CAC7E,MAAM,SAAS,UAAU;CACzB,MAAM,GAAG,QAAQ,SAAS,CAAC;CAC3B,MAAM,YAAY,OAAO,kBAAkB,KAAK,MAAM;CACtD,gBAAgB;EACd,IAAI,CAAC,aAAa,CAAC,OAAO,MAAM;EAChC,MAAM,SAAS,MAAM,KAAK;EAC1B,OAAO,OAAO,OAAO,GAAG,iBAAiB,MAAM;GAC7C,IAAI,EAAE,OAAO,UAAU,EAAE,SAAS,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC;EACjE,CAAC;CACH,GAAG;EAAC;EAAQ,OAAO;EAAM,OAAO;EAAM;CAAS,CAAC;AAClD;AAEA,MAAM,eACJ,MACA,aAC8B;CAC9B,IAAI,SAAS,MAAM,OAAO,KAAA;CAC1B,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;CACjD,IAAI,MAAM,OAAO;CACjB,OAAO,QAAQ,QAAQ;AACzB;AAEA,MAAM,iBACJ,OACA,SACc;CACd,MAAM,MAAO,MAAM,OAAqB;CACxC,MAAM,SAAU,MAAM,UAAwB;CAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,OAAO;CAC5B,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG;GACA;GACA;EACE;;AAET"}
|
|
1
|
+
{"version":3,"file":"Control.js","names":[],"sources":["../../src/form/Control.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport { useAlepha } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { resolveSchemaControl, type SchemaControl } from \"alepha/react/ui\";\nimport { Check, X } from \"lucide-react\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n useEffect,\n useState,\n} from \"react\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Switch } from \"../core/Switch.tsx\";\nimport { Textarea } from \"../core/Textarea.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { ControlArray, type ControlArrayProps } from \"./ControlArray.tsx\";\nimport { ControlDate, type ControlDateProps } from \"./ControlDate.tsx\";\nimport { ControlDateRange } from \"./ControlDateRange.tsx\";\nimport { ControlNumber } from \"./ControlNumber.tsx\";\nimport { ControlObject } from \"./ControlObject.tsx\";\nimport { ControlPassword } from \"./ControlPassword.tsx\";\nimport {\n ControlSelect,\n type ControlSelectSize,\n type SelectOption,\n} from \"./ControlSelect.tsx\";\nimport { ControlUpload, type ControlUploadProps } from \"./ControlUpload.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport { useFormFieldAutoSave } from \"./FormFieldAutoSaveProvider.tsx\";\nimport { useFormFieldLayout } from \"./FormFieldLayoutProvider.tsx\";\nimport { type IconComponent, iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlProps {\n /**\n * Bound `InputField` from `useForm`. Carries value, schema, and error state.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title` or the field name.\n */\n label?: string;\n /**\n * Helper text shown below the control. Falls back to schema `description`.\n */\n description?: string;\n /**\n * Force a specific input variant — renders a single-line text input.\n */\n text?: boolean;\n /**\n * Force a textarea.\n */\n area?: boolean;\n /**\n * Force a masked password input.\n */\n password?: boolean;\n /**\n * Force a `<Switch>` (boolean toggle).\n */\n switch?: boolean;\n /**\n * Force a numeric input.\n */\n number?: boolean;\n /**\n * Force the file-upload control (alias for `upload`).\n */\n file?: boolean;\n /**\n * The file picker's `accept` filter (`\".csv,text/csv\"`, `\"image/*\"`), for\n * `file` and for `upload`; an `upload` object's own `accept` wins.\n */\n accept?: string;\n /**\n * Force a date picker.\n */\n date?: boolean;\n /**\n * Force a date-time picker.\n */\n datetime?: boolean;\n /**\n * Force a date-range picker, regardless of the schema's format.\n *\n * Rarely needed: `z.dateRange()` tags the array itself, so the control\n * selects itself. Here for the same reason `date` and `datetime` are - a\n * field whose schema is a plain pair of strings can still ask for it.\n */\n dateRange?: boolean;\n /**\n * Force a month picker: the value is `YYYY-MM`.\n */\n month?: boolean;\n /**\n * Force a time picker.\n */\n time?: boolean;\n /**\n * Date picker caption style — `\"dropdown\"` swaps the month arrows for\n * month/year selects. See {@link ControlDateProps.captionLayout}.\n */\n captionLayout?: ControlDateProps[\"captionLayout\"];\n /** First selectable month of a date picker. */\n startMonth?: Date;\n /** Last selectable month of a date picker. */\n endMonth?: Date;\n /**\n * Date-of-birth shorthand: a year dropdown covering the last 120 years.\n * See {@link ControlDateProps.birthdate}.\n */\n birthdate?: boolean;\n /**\n * Force a `<Select>`.\n */\n select?: boolean;\n /**\n * Force a combobox (searchable select). Alias for `searchable: true`.\n */\n combobox?: boolean;\n /**\n * Force the select's search input on or off. Defaults to \"auto\" — on for an\n * async list, when `createNewEntry` is set, or above ~50 options.\n */\n searchable?: boolean;\n /**\n * Force a `<Segmented>` control (one option visible at a time).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array of options) as a group of\n * checkboxes, every option visible. See `ControlSelectProps.checkboxes`.\n */\n checkboxes?: boolean;\n /**\n * Force a slider (numeric only).\n */\n slider?: boolean;\n /**\n * Force a nested `<ControlObject>` for object-typed schemas.\n */\n object?: boolean;\n /**\n * Force a nested `<ControlArray>` for array-typed schemas.\n */\n array?: boolean;\n /**\n * Props forwarded to the nested `<ControlObject>`, keyed by child field name.\n * This is the only way to reach INSIDE an object field — without it a caller\n * can style/override the object as a whole but never one of its children\n * (e.g. attaching a `custom` widget to `payg.zoneFareCents`).\n */\n /**\n * Dictionary prefix for schema-generated labels/help: this field reads\n * `<prefix>.<name>` and `<prefix>.<name>.desc`, and passes the extended\n * prefix down into nested objects and array items.\n */\n i18nPrefix?: string;\n objectProps?: {\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n variant?: \"fieldset\" | \"plain\";\n defaultExpanded?: boolean;\n };\n /**\n * Custom render component receiving `{value, onChange}`.\n */\n custom?: ComponentType<{ value: unknown; onChange: (v: unknown) => void }>;\n /**\n * Override icon — pass `null` to remove the schema-inferred icon.\n */\n icon?: IconComponent | string | null;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Render slot before the control.\n */\n top?: ReactNode;\n /**\n * Render slot after the control.\n */\n bottom?: ReactNode;\n /**\n * A status drawn inside the right end of a text input, such as a tick or a\n * cross saying whether the value is accepted. Decoration only: it takes no\n * pointer events, so put anything the reader must act on in `bottom`.\n *\n * The auto-save tick and the clear button own that corner when they show,\n * and hide it meanwhile. The input reserves its gutter while it is drawn.\n */\n trailing?: ReactNode;\n /**\n * An error to show now, drawn exactly like a validation error. Wins over\n * the form's own, which only exists once the form has been submitted: a\n * multi-step wizard whose Next is not a submit uses this to refuse a value\n * the moment it is typed.\n */\n error?: string;\n /**\n * Width slot inside an `<AutoForm>` group (mapped to a CSS grid column\n * span). Read by the parent group; ignored when rendering standalone.\n */\n width?: 100 | 75 | 66 | 50 | 33 | 25;\n /**\n * HTML `autocomplete` hint passed to the underlying input.\n */\n autoComplete?: string;\n /**\n * Placeholder text. On a text-shaped control this is the HTML\n * `placeholder`; on a select it is the trigger text shown while nothing is\n * picked.\n */\n placeholder?: string;\n /**\n * Autofocus the control on mount. Forwarded to the text, number, password\n * or textarea input the control renders. Ignored by the variants that are\n * not a single focusable field (select, date, upload, array, object).\n *\n * Every forward site carries an `oxlint-disable-next-line\n * jsx-a11y/no-autofocus`. That rule is right about a page that grabs focus\n * unbidden and wrong here: nothing focuses unless a caller passed this prop,\n * and it is the caller the rule should be asking. Left to fire, it did real\n * damage once - a lint pass deleted the forwarding and left the prop\n * declared, so login and dialog forms silently stopped focusing their first\n * field and two components grew `getElementById(...).focus()` workarounds.\n */\n autoFocus?: boolean;\n /**\n * Visible row count for the textarea variant. Overrides the value\n * auto-derived from the schema's `maxLength`. Ignored by other variants.\n */\n rows?: number;\n /**\n * Escape hatch — extra native attributes (event handlers, `className`,\n * `aria-*`, `data-*`, `style`, …) forwarded to whichever element the\n * control actually renders (text input / textarea / password input). The\n * form bindings (`value`, `onChange`, `id`, `name`) always win and cannot\n * be overridden here.\n *\n * `data-*` is spelled out because `HTMLAttributes` does not carry it:\n * TypeScript special-cases dashed attributes in JSX only, so an object\n * literal `{ \"data-testid\": … }` is an excess property and fails to\n * compile. Without this a control cannot carry a test hook, which meant a\n * surface with an e2e had to keep a raw `<input>` rather than adopt the\n * shared control.\n *\n * ⚠️ **`autoComplete` does not go here.** `Control` takes it as a\n * first-class prop, and `ControlPassword` writes its own after spreading\n * this object - so a value passed through `inputProps` is silently\n * replaced by `\"current-password\"`, which on a field holding a deploy\n * token is the password-manager prompt the masking exists to avoid.\n */\n inputProps?: HTMLAttributes<HTMLElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n };\n /**\n * Allow user to create new entries in select / multi-select.\n */\n createNewEntry?: boolean | ((query: string) => unknown);\n /**\n * Inline option list for select / combobox controls. Infer array or\n * async loader. Overrides schema-derived `enum` when present.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Whether the field offers a way back to empty.\n *\n * On a `ControlSelect`, `true` adds a synthetic \"none\" row that resets the\n * field to `undefined` — use it for optional filter chips.\n *\n * On a text field the affordance is the opposite way round: an optional\n * field already shows a clear (×) button whenever it holds a value, and\n * `false` takes it away. Pass `false` when emptying the field is not\n * something the API can honour — a username has no \"unset\" on the server,\n * so offering the button would promise an edit that silently does nothing.\n */\n clearable?: boolean;\n /**\n * Forwarded to `ControlSelect` — label of the `clearable` row, also\n * used as the empty-state trigger placeholder. Defaults to \"None\".\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * Forwarded to `ControlSelect`: the longest joined text a multi-select\n * trigger names its selection with before it collapses to `countLabel`.\n * Defaults to 20.\n */\n maxTriggerLength?: number;\n /**\n * Forwarded to `ControlSelect` — extra className on the trigger.\n * Useful for sizing filter chips inline.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale, for the select-shaped controls. Defaults\n * to `default`; `xs` is for a control that sits ON a row of text rather\n * than in a form.\n */\n size?: ControlSelectSize;\n /**\n * Render the select trigger borderless and transparent, so it reads as the\n * row it sits on rather than as a form field. Pairs with `size=\"xs\"`.\n */\n minimal?: boolean;\n /**\n * Forwarded to `ControlSelect`: drawn at the top of a select's popup, for\n * a setting that changes what the choice means (a filter's \"is / is not\").\n */\n popupHeader?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: a short qualifier drawn before the\n * selected label on the trigger (\"not Active\").\n */\n triggerPrefix?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: extra className on a select's popup, e.g.\n * `w-max min-w-48` to size it from its content rather than its trigger.\n */\n popupClassName?: string;\n /**\n * Forwarded to `ControlSelect` and `ControlDateRange`: an element drawn\n * INSTEAD of the field, as the button that opens its popup. See\n * `ControlSelectProps.trigger`.\n */\n trigger?: ReactElement<{ children?: ReactNode }>;\n /**\n * Forwarded to `ControlSelect` and `ControlDateRange`: the popup opened or\n * closed.\n */\n onPopupOpenChange?: (open: boolean) => void;\n /**\n * Render a managed upload control (image preview, multi, drag-drop)\n * that calls `FileController.uploadFile` and stores the file ID(s) in\n * the form value. Pass `true` for defaults or an options object.\n */\n upload?:\n | boolean\n | Pick<\n ControlUploadProps,\n \"multi\" | \"accept\" | \"maxSize\" | \"bucket\" | \"image\"\n >;\n}\n\n/**\n * Schema-driven form field renderer. Inspects the bound `InputField` from\n * `useForm`, evaluates `schema.$control` (object or function), merges the\n * result with explicit props, and dispatches to the right sub-control.\n */\nexport const Control = (props: ControlProps) => {\n const form = useFormState(props.input, [\"error\", \"dirty\"]);\n const autoSaveEnabled = useFormFieldAutoSave();\n const rowLayout = useFormFieldLayout() === \"row\";\n const [value, setValue] = useFieldValue(props.input);\n\n // Function-form `$control` reads other fields → re-render on any\n // change. Infer `$control` (object) does not need this subscription.\n useDynamicControlRefresh(props.input);\n\n if (!props.input?.props) return null;\n\n const parsed = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n const meta = props.error ? { ...parsed, error: props.error } : parsed;\n\n // ── Resolve $control (object | function | false) ─────────────────\n const resolved = resolveSchemaControl(meta.control, {\n form: props.input.form,\n value,\n });\n // `null` is gone, `hidden` is present-but-invisible. A control renders\n // nothing for either; only the LAYOUT tells them apart.\n if (resolved === null || resolved.hidden) return null;\n\n const merged = {\n ...props,\n ...(resolved as Partial<ControlProps>),\n } as ControlProps & Partial<SchemaControl>;\n\n // ── Custom escape hatch ──────────────────────────────────────────\n if (merged.custom) {\n const Custom = merged.custom;\n return wrapWithSlots(\n merged,\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Custom value={value} onChange={(v) => setValue(v)} />\n </FormField>,\n );\n }\n\n // ── Recursive: object / array of objects ─────────────────────────\n if (merged.object || meta.isObject) {\n return wrapWithSlots(\n merged,\n <ControlObject\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n i18nPrefix={merged.i18nPrefix}\n controlProps={merged.objectProps?.controlProps}\n variant={merged.objectProps?.variant}\n defaultExpanded={merged.objectProps?.defaultExpanded}\n clearable={merged.clearable}\n />,\n );\n }\n if (merged.array || meta.isArrayOfObjects) {\n const arrayProps = (merged as { arrayProps?: Record<string, unknown> })\n .arrayProps;\n return wrapWithSlots(\n merged,\n <ControlArray\n input={props.input}\n i18nPrefix={merged.i18nPrefix}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n confirmDelete={\n arrayProps?.confirmDelete as ControlArrayProps[\"confirmDelete\"]\n }\n renderTabName={\n arrayProps?.renderTabName as ControlArrayProps[\"renderTabName\"]\n }\n forceTabs={arrayProps?.forceTabs as boolean | undefined}\n />,\n );\n }\n\n // ── File: managed upload (image preview, multi, drag-drop) ──────\n // Checked early so it wins over the array→combobox branch below\n // when the schema is `z.array(z.string())` with $control.upload.\n if (merged.upload) {\n const uploadOpts =\n typeof merged.upload === \"object\"\n ? (merged.upload as Partial<ControlUploadProps>)\n : {};\n return wrapWithSlots(\n merged,\n <ControlUpload\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n accept={merged.accept}\n {...uploadOpts}\n />,\n );\n }\n\n // ── Items provided → select / multi / combobox ───────────────────\n // Read before the numeric branch, because that branch owns every numeric\n // schema by default and `ControlNumber` has nowhere to put an option list:\n // a `z.number()` field handed `items` used to render a bare spinner and drop\n // the rows on the floor, silently. An explicit list is an explicit request\n // for a select, so it wins - `slider` / `number` still override it below.\n const items = (merged as Record<string, unknown>).items as\n | undefined\n | unknown[]\n | ((q: string) => unknown);\n\n // ── Number / slider ──────────────────────────────────────────────\n if (\n merged.slider ||\n merged.number ||\n (!merged.select &&\n !merged.segmented &&\n !merged.combobox &&\n items == null &&\n (meta.type === \"number\" || meta.type === \"integer\"))\n ) {\n return wrapWithSlots(\n merged,\n <ControlNumber\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n slider={merged.slider}\n disabled={merged.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n />,\n );\n }\n\n // ── Date range ───────────────────────────────────────────────────\n //\n // ⚠️ ABOVE the array branch below, and that placement is the whole of it.\n // `z.dateRange()` IS an array, so the `meta.isArray` test twenty lines down\n // matches it first and renders a range as a multi-select combobox - which\n // looks like a deliberate control and is silently the wrong one. Sitting\n // this beside the date branch further down, where it reads as though it\n // belongs, is exactly the mistake.\n //\n // Keyed on the format LITERAL, never on \"array whose items are dates\": that\n // second test cannot tell a range from an ordinary list of two days, and it\n // is what would make a later `date-time-range` a rewrite rather than one\n // more literal plus a `withTime` prop.\n if (merged.dateRange || meta.format === \"date-range\") {\n return wrapWithSlots(\n merged,\n <ControlDateRange\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n clearable={merged.clearable}\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n // From `props`, like the select's below: a node has no place in a\n // schema's `$control`.\n triggerPrefix={props.triggerPrefix}\n trigger={props.trigger}\n onPopupOpenChange={props.onPopupOpenChange}\n />,\n );\n }\n\n if (\n merged.select ||\n merged.combobox ||\n merged.segmented ||\n merged.checkboxes ||\n meta.isEnum ||\n (meta.isArray && !meta.isArrayOfObjects) ||\n items != null\n ) {\n return wrapWithSlots(\n merged,\n <ControlSelect\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n segmented={merged.segmented}\n checkboxes={merged.checkboxes}\n combobox={merged.combobox}\n searchable={merged.searchable}\n items={items as never}\n // Every field carries a leading icon, a select included: the list\n // glyph unless the caller names one or passes `null`. Not on a\n // `minimal` trigger, the toolbar filter chip, which names itself with\n // a `triggerPrefix` and would only get noisier.\n icon={\n merged.minimal\n ? resolveIcon(merged.icon)\n : resolveIcon(merged.icon, \"list\")\n }\n disabled={merged.disabled}\n createNewEntry={\n merged.createNewEntry as boolean | ((q: string) => never) | undefined\n }\n clearable={merged.clearable}\n clearLabel={merged.clearLabel}\n countLabel={merged.countLabel}\n maxTriggerLength={merged.maxTriggerLength}\n // Dropped here until now, so a picker that needed to name its own\n // empty state (\"Pick an epic…\") could not be a `Control` at all.\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n size={merged.size}\n minimal={merged.minimal}\n // Used to be dropped here, silently: every `inputProps={{ \"aria-label\"\n // }}` on a select-shaped Control (the epics and quests status filters\n // among them) named nothing at all, because the trigger is a button\n // with no visible label to borrow a name from.\n triggerProps={merged.inputProps}\n // From `props`, not `merged`: a node has no business in a schema's\n // `$control`, so there is nothing for the merge to contribute.\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={merged.popupClassName}\n trigger={props.trigger}\n onPopupOpenChange={props.onPopupOpenChange}\n />,\n );\n }\n\n // ── Boolean → switch ─────────────────────────────────────────────\n if (meta.type === \"boolean\" && merged.switch !== false) {\n return wrapWithSlots(\n merged,\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n // A switch always holds a value, on or off: a required marker on it\n // asks for something the reader cannot fail to give. `aria-required`\n // is left off for the same reason.\n required={false}\n >\n <div className=\"flex h-9 items-center\">\n <Switch\n {...merged.inputProps}\n id={meta.id}\n // Same omission as the numeric control had: without a name the\n // toggle is invisible to `[name=\"…\"]` lookups, including\n // `AutoForm`'s scroll-to-first-error.\n name={props.input.props.name}\n disabled={merged.disabled}\n checked={Boolean(value)}\n onCheckedChange={(v) => setValue(v)}\n />\n </div>\n </FormField>,\n );\n }\n\n // ── Date / time ──────────────────────────────────────────────────\n if (\n merged.date ||\n merged.datetime ||\n merged.time ||\n merged.month ||\n meta.format === \"date\" ||\n meta.format === \"date-time\" ||\n meta.format === \"time\"\n ) {\n return wrapWithSlots(\n merged,\n <ControlDate\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n date={merged.date}\n datetime={merged.datetime}\n time={merged.time}\n month={merged.month}\n inputProps={merged.inputProps}\n disabled={merged.disabled}\n clearable={merged.clearable}\n captionLayout={merged.captionLayout}\n startMonth={merged.startMonth}\n endMonth={merged.endMonth}\n birthdate={merged.birthdate}\n />,\n );\n }\n\n // ── File (raw) ───────────────────────────────────────────────────\n if (merged.file) {\n return wrapWithSlots(\n merged,\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Input\n id={meta.id}\n name={props.input.props.name}\n type=\"file\"\n accept={merged.accept}\n disabled={merged.disabled}\n onChange={(e) => setValue(e.target.files?.[0])}\n />\n </FormField>,\n );\n }\n\n // ── Auto-textarea: explicit `area` or maxLength > 256 ────────────\n const maxLength = meta.constraints.maxLength ?? 0;\n if (merged.area || maxLength > 256) {\n const rows =\n merged.rows ?? (maxLength > 1024 ? 6 : maxLength > 512 ? 4 : 2);\n return wrapWithSlots(\n merged,\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Textarea\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n rows={rows}\n disabled={merged.disabled}\n maxLength={maxLength || undefined}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n onChange={(e) => setValue(e.target.value)}\n />\n </FormField>,\n );\n }\n\n // ── Password ─────────────────────────────────────────────────────\n const isPassword =\n merged.password ||\n meta.iconHint === \"password\" ||\n meta.format === \"password\";\n if (isPassword) {\n return wrapWithSlots(\n merged,\n <ControlPassword\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n name={props.input.props.name}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n disabled={merged.disabled}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n inputProps={merged.inputProps}\n icon={resolveIcon(merged.icon, \"password\")}\n value={String(value ?? \"\")}\n onChange={(v) => setValue(v)}\n />,\n );\n }\n\n // ── Default text input with format-driven HTML5 type + icon ──────\n const Icon = resolveIcon(merged.icon, meta.iconHint);\n const htmlType =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : \"text\";\n\n // Derive a sensible HTML `autocomplete` hint from the schema format so\n // password managers and browser autofill behave correctly out of the box.\n // Explicit `autoComplete` prop always wins.\n const autoCompleteFromFormat =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : undefined;\n const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;\n\n // A value typed verbatim (an account identifier, an address, a code) must\n // not be rewritten by the keyboard: iOS capitalises the first letter of a\n // username by default, and a sign-in then fails on \"Test@mobile.test\".\n const verbatim =\n htmlType === \"email\" ||\n htmlType === \"url\" ||\n [\"username\", \"email\", \"tel\", \"url\", \"one-time-code\"].includes(\n autoComplete ?? \"\",\n );\n\n // ── Right-side affordance: tick (when dirty) or clear (when nullable) ─\n // Tick only renders inside an `<AutoForm autoSave>` tree (or any caller\n // that explicitly wraps with `<FormFieldAutoSaveProvider value>`).\n const showSave = autoSaveEnabled && !!form.dirty && !merged.disabled;\n const isNullable =\n !meta.required && value != null && value !== \"\" && !merged.disabled;\n // `clearable !== false`, not `clearable === true`: an optional text field\n // offers the button by default and a caller opts *out* of it. See the prop.\n const showClear = !showSave && isNullable && merged.clearable !== false;\n // The right gutter is reserved only while the tick is drawn, or while the\n // cross is drawn AND the field has focus. Kept on every editable field, it\n // took 36px from the text of each one and cut placeholders short for a\n // button that was not there (\"Rechercher client, terr…\"). At rest the cross\n // floats over the end of the value on a fade instead, so a settings row\n // shows \"Delete project\" rather than \"Delete proj\"; once focused the gutter\n // comes back, since the caret must never sit under the button. The input\n // is border-box, so the padding never changes its width.\n const showTrailing = !showSave && !showClear && merged.trailing != null;\n const reserveGutter = showSave || showTrailing;\n\n return wrapWithSlots(\n merged,\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n autoCapitalize={verbatim ? \"none\" : undefined}\n autoCorrect={verbatim ? \"off\" : undefined}\n spellCheck={verbatim ? false : undefined}\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n type={htmlType}\n disabled={merged.disabled}\n autoComplete={autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n minLength={meta.constraints.minLength}\n maxLength={meta.constraints.maxLength}\n pattern={meta.constraints.pattern}\n // `cn`, not a plain join: the settings width below has to be\n // overridable by the caller, and only `cn`'s merge can decide\n // that `sm:w-96` beats `sm:w-64` rather than both landing on the\n // element. Order is precedence — later wins.\n className={cn(\n // Row layout is the settings-card shape, whose right-hand cell is\n // an `auto` grid column: `w-full` there resolves against the\n // input's own intrinsic size (~172px), so every card would get a\n // slightly different control column. 256px is the width every\n // hand-written `SettingsRow` already passes; encoded once here.\n // Below `sm` the row stacks, and `w-full` from `<Input>` is right.\n rowLayout && \"sm:w-64\",\n merged.inputProps?.className,\n Icon && \"pl-9\",\n reserveGutter && \"pr-9\",\n showClear && \"focus:pr-9\",\n )}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n merged.inputProps?.onKeyDown?.(e);\n if (e.defaultPrevented || e.key !== \"Enter\") return;\n // The commit the auto-save effect deliberately withholds from a\n // text field on every keystroke. Its comment offers \"Enter or the\n // inline tick button\" as the two ways to commit - and only the\n // tick ever existed. `AutoForm` in auto-save mode renders no\n // submit button, so the browser's implicit submission never fires\n // and Enter did nothing at all, on every text field in every\n // auto-saving form.\n //\n // Guarded on `showSave` so it is inert outside auto-save mode and\n // on a pristine field, where a normal form's own Enter handling\n // must keep working.\n if (!showSave) return;\n e.preventDefault();\n // `props.input.form`, the same handle the tick button submits\n // through. The local `form` is only the `dirty` / `error` slice.\n void props.input.form.submit();\n }}\n />\n {showSave && (\n <button\n type=\"button\"\n onClick={() => props.input.form.submit()}\n aria-label=\"Save\"\n className=\"text-primary hover:text-primary/80 absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <Check className=\"size-3.5\" />\n </button>\n )}\n {showClear && (\n <button\n type=\"button\"\n onClick={() => setValue(undefined)}\n aria-label=\"Clear\"\n // `data-slot` like every other clear in the kit\n // (`combobox-clear`, and `control-clear` on the field trigger).\n // It was the only one without a hook, so the only way to address\n // it was its `aria-label` - which is translated, so a French UI\n // would have matched nothing. Purely an identification hook: no\n // style and no behaviour rides on it here.\n data-slot=\"control-clear\"\n // Over the value, inside the border (`inset-y-px right-px`), on a\n // fade into the surface behind the field (`--surface`, which any\n // element painting a surface token declares, see `styles.css`).\n // In dark the input carries its own\n // `bg-input/30` tint, so the fade stacks that tint over the\n // surface to match it exactly.\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-px right-px flex items-center rounded-r-[calc(var(--radius-lg)-1px)] bg-[linear-gradient(to_right,transparent,var(--surface)_1.25rem)] pr-2.5 pl-6 dark:bg-[linear-gradient(to_right,transparent,color-mix(in_oklab,var(--input)_30%,transparent)_1.25rem),linear-gradient(to_right,transparent,var(--surface)_1.25rem)]\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n {showTrailing && (\n <span\n data-slot=\"control-trailing\"\n className=\"pointer-events-none absolute top-1/2 right-3 flex -translate-y-1/2 items-center\"\n >\n {merged.trailing}\n </span>\n )}\n </div>\n </FormField>,\n );\n};\n\n/**\n * The raw `$control` a field declares, object form or function form.\n *\n * It rides on zod's `.meta()` registry rather than being a plain schema\n * property, and the field may be wrapped (optional / nullable / default), so\n * the wrapper has to be peeled before the meta is readable.\n *\n * Exported because the LAYOUT needs it too: `AutoForm` sizes a grid cell from\n * the width `$control` asks for, and a function-form `$control` has no `.width`\n * to read off the function itself. Pair it with {@link resolveSchemaControl}.\n */\nexport const readSchemaControl = (\n input: BaseInputField | undefined,\n): unknown => {\n const base = input?.schema ? z.schema.unwrap(input.schema) : undefined;\n return (base as { meta?: () => { $control?: unknown } } | undefined)?.meta?.()\n ?.$control;\n};\n\n/**\n * Re-render when a function-form `$control` may have changed its mind, which\n * is on any change to a field OTHER than this one. An object-form `$control`\n * is static and needs no subscription.\n *\n * Exported alongside {@link readSchemaControl}, and for the same reason: a\n * consumer that resolves `$control` itself has to re-resolve on the same\n * events, or it renders a stale answer.\n */\nexport const useDynamicControlRefresh = (input: BaseInputField | undefined) => {\n const alepha = useAlepha();\n const [, bump] = useState(0);\n const isDynamic = typeof readSchemaControl(input) === \"function\";\n useEffect(() => {\n if (!isDynamic || !input?.form) return;\n const formId = input.form.id;\n return alepha.events.on(\"form:changed\", (e) => {\n if (e.id === formId && e.path !== input.path) bump((n) => n + 1);\n });\n }, [alepha, input?.form, input?.path, isDynamic]);\n};\n\nconst resolveIcon = (\n icon: ControlProps[\"icon\"],\n fallback?: string | null,\n): IconComponent | undefined => {\n if (icon === null) return undefined;\n if (typeof icon === \"string\") return iconFor(icon);\n if (icon) return icon;\n return iconFor(fallback);\n};\n\nconst wrapWithSlots = (\n props: ControlProps & Partial<SchemaControl>,\n body: ReactNode,\n): ReactNode => {\n const top = (props.top as ReactNode) ?? null;\n const bottom = (props.bottom as ReactNode) ?? null;\n if (!top && !bottom) return body;\n return (\n <div className=\"flex flex-col gap-1\">\n {top}\n {body}\n {bottom}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkXA,MAAa,WAAW,UAAwB;CAC9C,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,SAAS,OAAO,CAAC;CACzD,MAAM,kBAAkB,qBAAqB;CAC7C,MAAM,YAAY,mBAAmB,MAAM;CAC3C,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAInD,yBAAyB,MAAM,KAAK;CAEpC,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,SAAS,WAAW,MAAM,OAAO;EACrC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CACD,MAAM,OAAO,MAAM,QAAQ;EAAE,GAAG;EAAQ,OAAO,MAAM;CAAM,IAAI;CAG/D,MAAM,WAAW,qBAAqB,KAAK,SAAS;EAClD,MAAM,MAAM,MAAM;EAClB;CACF,CAAC;CAGD,IAAI,aAAa,QAAQ,SAAS,QAAQ,OAAO;CAEjD,MAAM,SAAS;EACb,GAAG;EACH,GAAI;CACN;CAGA,IAAI,OAAO,QAAQ;EACjB,MAAM,SAAS,OAAO;EACtB,OAAO,cACL,QACA,oBAAC,WAAD;GACE,cAAc,MAAM,MAAM,MAAM,KAAK,MAAM,MAAM,IAAI;GACrD,IAAI,KAAK;GACT,OAAO,OAAO,SAAS,KAAK;GAC5B,aAAa,OAAO,eAAe,KAAK;GACxC,OAAO,KAAK;GACZ,UAAU,KAAK;GAEf,UAAA,oBAAC,QAAD;IAAe;IAAO,WAAW,MAAM,SAAS,CAAC;GAAI,CAAA;EAC5C,CAAA,CACb;CACF;CAGA,IAAI,OA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AAC;IAChB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,WAAW,UAAW,gBAAgB,6BAoGlD,CAAC"}
|
package/dist/form/ControlDate.js
CHANGED
|
@@ -21,6 +21,7 @@ const ControlDate = (props) => {
|
|
|
21
21
|
});
|
|
22
22
|
const isDateTime = props.datetime || meta.format === "date-time";
|
|
23
23
|
if (props.time || meta.format === "time") return /* @__PURE__ */ jsx(FormField, {
|
|
24
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
24
25
|
id: meta.id,
|
|
25
26
|
label: meta.label,
|
|
26
27
|
description: meta.description,
|
|
@@ -41,6 +42,7 @@ const ControlDate = (props) => {
|
|
|
41
42
|
})
|
|
42
43
|
});
|
|
43
44
|
if (props.month) return /* @__PURE__ */ jsx(FormField, {
|
|
45
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
44
46
|
id: meta.id,
|
|
45
47
|
label: meta.label,
|
|
46
48
|
description: meta.description,
|
|
@@ -57,6 +59,7 @@ const ControlDate = (props) => {
|
|
|
57
59
|
});
|
|
58
60
|
const thisYear = dateTime.now().toDate().getFullYear();
|
|
59
61
|
return /* @__PURE__ */ jsx(FormField, {
|
|
62
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
60
63
|
id: meta.id,
|
|
61
64
|
label: meta.label,
|
|
62
65
|
description: meta.description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlDate.js","names":[],"sources":["../../src/form/ControlDate.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useInject } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { Clock } from \"lucide-react\";\nimport type { HTMLAttributes } from \"react\";\nimport type { DayPickerProps } from \"react-day-picker\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { ControlDatePopover } from \"./ControlDatePopover.tsx\";\nimport { ControlMonthPopover } from \"./ControlMonthPopover.tsx\";\nimport { FormField } from \"./FormField.tsx\";\n\nexport interface ControlDateProps {\n /**\n * Bound `InputField` from `useForm`. Stores an ISO string.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the picker.\n */\n description?: string;\n /**\n * Force date-only mode regardless of schema format.\n */\n date?: boolean;\n /**\n * Force date-time mode regardless of schema format.\n */\n datetime?: boolean;\n /**\n * Force time-only mode regardless of schema format.\n */\n time?: boolean;\n /**\n * Disable the picker.\n */\n disabled?: boolean;\n /**\n * Offer a way back to empty once a date is picked.\n *\n * A calendar has no \"none\" cell, so without this an optional date field is\n * one-way: pick a day and there is no gesture that unsets it. Every other\n * control in the kit spells this `clearable`, so this one does too - and\n * draws it the same way, as the kit's `x` on the trigger.\n */\n clearable?: boolean;\n /**\n * Caption style. `\"label\"` (the default) shows the month name with\n * previous/next arrows; `\"dropdown\"` swaps both for month and year selects.\n *\n * Arrows are fine for a date near today and hopeless for one that is not:\n * reaching a 1988 birthday costs about 450 clicks on `<`. Pair `\"dropdown\"`\n * with {@link startMonth} / {@link endMonth}, or use {@link birthdate},\n * which sets both.\n */\n captionLayout?: DayPickerProps[\"captionLayout\"];\n /**\n * First selectable month. Also bounds the year dropdown, which otherwise\n * offers a narrow range around today.\n */\n startMonth?: Date;\n /** Last selectable month. */\n endMonth?: Date;\n /**\n * Shorthand for a date of birth: a year dropdown covering the last\n * {@link BIRTHDATE_YEARS} years, ending this year.\n *\n * Sugar over `captionLayout` + `startMonth` / `endMonth`, which stay\n * available for any other historical field. An explicit value for one of\n * those wins over what this sets.\n */\n birthdate?: boolean;\n /**\n * A month picker: the value is `YYYY-MM`. See `ControlMonthPopover`.\n */\n month?: boolean;\n /**\n * Forwarded to the focusable element (the time input, or the picker's\n * trigger): an `aria-label` for a field drawn without a label, a\n * `data-testid`.\n */\n inputProps?: HTMLAttributes<HTMLElement>;\n}\n\nexport const ControlDate = (props: ControlDateProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const dateTime = useInject(DateTimeProvider);\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isDateTime = props.datetime || meta.format === \"date-time\";\n const isTime = props.time || meta.format === \"time\";\n\n if (isTime) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n <Clock className=\"text-muted-foreground absolute start-3 top-1/2 size-4 -translate-y-1/2\" />\n <Input\n {...props.inputProps}\n id={meta.id}\n name={props.input.props.name}\n type=\"time\"\n className=\"ps-9\"\n disabled={props.disabled}\n value={value ?? \"\"}\n onChange={(e) => setValue(e.target.value)}\n />\n </div>\n </FormField>\n );\n }\n\n if (props.month) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlMonthPopover\n id={meta.id}\n value={value}\n disabled={props.disabled}\n clearable={props.clearable}\n triggerProps={props.inputProps}\n onChange={(v) => setValue(v)}\n />\n </FormField>\n );\n }\n\n const thisYear = dateTime.now().toDate().getFullYear();\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlDatePopover\n id={meta.id}\n triggerProps={props.inputProps}\n value={value}\n withTime={isDateTime}\n disabled={props.disabled}\n clearable={props.clearable}\n captionLayout={\n props.captionLayout ?? (props.birthdate ? \"dropdown\" : undefined)\n }\n startMonth={\n props.startMonth ??\n (props.birthdate\n ? new Date(thisYear - BIRTHDATE_YEARS, 0, 1)\n : undefined)\n }\n endMonth={\n props.endMonth ??\n (props.birthdate ? new Date(thisYear, 11, 31) : undefined)\n }\n onChange={(v) => setValue(v)}\n />\n </FormField>\n );\n};\n\n/** How many years back a `birthdate` picker offers. Covers every living\n * person; the oldest verified human reached 122. */\nconst BIRTHDATE_YEARS = 120;\n"],"mappings":";;;;;;;;;;;AAiGA,MAAa,eAAe,UAA4B;CACtD,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,WAAW,UAAU,gBAAgB;CAE3C,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,aAAa,MAAM,YAAY,KAAK,WAAW;CAGrD,IAFe,MAAM,QAAQ,KAAK,WAAW,QAG3C,OACE,oBAAC,WAAD;EACE,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EAEf,UAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,OAAD,EAAO,WAAU,yEAA0E,CAAA,GAC3F,oBAAC,OAAD;IACE,GAAI,MAAM;IACV,IAAI,KAAK;IACT,MAAM,MAAM,MAAM,MAAM;IACxB,MAAK;IACL,WAAU;IACV,UAAU,MAAM;IAChB,OAAO,SAAS;IAChB,WAAW,MAAM,SAAS,EAAE,OAAO,KAAK;GACzC,CAAA,CACE;;CACI,CAAA;CAIf,IAAI,MAAM,OACR,OACE,oBAAC,WAAD;EACE,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EAEf,UAAA,oBAAC,qBAAD;GACE,IAAI,KAAK;GACF;GACP,UAAU,MAAM;GAChB,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,WAAW,MAAM,SAAS,CAAC;EAC5B,CAAA;CACQ,CAAA;CAIf,MAAM,WAAW,SAAS,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY;CAErD,OACE,oBAAC,WAAD;EACE,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EAEf,UAAA,oBAAC,oBAAD;GACE,IAAI,KAAK;GACT,cAAc,MAAM;GACb;GACP,UAAU;GACV,UAAU,MAAM;GAChB,WAAW,MAAM;GACjB,eACE,MAAM,kBAAkB,MAAM,YAAY,aAAa,KAAA;GAEzD,YACE,MAAM,eACL,MAAM,YACH,IAAI,KAAK,WAAW,iBAAiB,GAAG,CAAC,IACzC,KAAA;GAEN,UACE,MAAM,aACL,MAAM,YAAY,IAAI,KAAK,UAAU,IAAI,EAAE,IAAI,KAAA;GAElD,WAAW,MAAM,SAAS,CAAC;EAC5B,CAAA;CACQ,CAAA;AAEf;;;AAIA,MAAM,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"ControlDate.js","names":[],"sources":["../../src/form/ControlDate.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { useInject } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { Clock } from \"lucide-react\";\nimport type { HTMLAttributes } from \"react\";\nimport type { DayPickerProps } from \"react-day-picker\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { ControlDatePopover } from \"./ControlDatePopover.tsx\";\nimport { ControlMonthPopover } from \"./ControlMonthPopover.tsx\";\nimport { FormField } from \"./FormField.tsx\";\n\nexport interface ControlDateProps {\n /**\n * Bound `InputField` from `useForm`. Stores an ISO string.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the picker.\n */\n description?: string;\n /**\n * Force date-only mode regardless of schema format.\n */\n date?: boolean;\n /**\n * Force date-time mode regardless of schema format.\n */\n datetime?: boolean;\n /**\n * Force time-only mode regardless of schema format.\n */\n time?: boolean;\n /**\n * Disable the picker.\n */\n disabled?: boolean;\n /**\n * Offer a way back to empty once a date is picked.\n *\n * A calendar has no \"none\" cell, so without this an optional date field is\n * one-way: pick a day and there is no gesture that unsets it. Every other\n * control in the kit spells this `clearable`, so this one does too - and\n * draws it the same way, as the kit's `x` on the trigger.\n */\n clearable?: boolean;\n /**\n * Caption style. `\"label\"` (the default) shows the month name with\n * previous/next arrows; `\"dropdown\"` swaps both for month and year selects.\n *\n * Arrows are fine for a date near today and hopeless for one that is not:\n * reaching a 1988 birthday costs about 450 clicks on `<`. Pair `\"dropdown\"`\n * with {@link startMonth} / {@link endMonth}, or use {@link birthdate},\n * which sets both.\n */\n captionLayout?: DayPickerProps[\"captionLayout\"];\n /**\n * First selectable month. Also bounds the year dropdown, which otherwise\n * offers a narrow range around today.\n */\n startMonth?: Date;\n /** Last selectable month. */\n endMonth?: Date;\n /**\n * Shorthand for a date of birth: a year dropdown covering the last\n * {@link BIRTHDATE_YEARS} years, ending this year.\n *\n * Sugar over `captionLayout` + `startMonth` / `endMonth`, which stay\n * available for any other historical field. An explicit value for one of\n * those wins over what this sets.\n */\n birthdate?: boolean;\n /**\n * A month picker: the value is `YYYY-MM`. See `ControlMonthPopover`.\n */\n month?: boolean;\n /**\n * Forwarded to the focusable element (the time input, or the picker's\n * trigger): an `aria-label` for a field drawn without a label, a\n * `data-testid`.\n */\n inputProps?: HTMLAttributes<HTMLElement>;\n}\n\nexport const ControlDate = (props: ControlDateProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const dateTime = useInject(DateTimeProvider);\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isDateTime = props.datetime || meta.format === \"date-time\";\n const isTime = props.time || meta.format === \"time\";\n\n if (isTime) {\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n <Clock className=\"text-muted-foreground absolute start-3 top-1/2 size-4 -translate-y-1/2\" />\n <Input\n {...props.inputProps}\n id={meta.id}\n name={props.input.props.name}\n type=\"time\"\n className=\"ps-9\"\n disabled={props.disabled}\n value={value ?? \"\"}\n onChange={(e) => setValue(e.target.value)}\n />\n </div>\n </FormField>\n );\n }\n\n if (props.month) {\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlMonthPopover\n id={meta.id}\n value={value}\n disabled={props.disabled}\n clearable={props.clearable}\n triggerProps={props.inputProps}\n onChange={(v) => setValue(v)}\n />\n </FormField>\n );\n }\n\n const thisYear = dateTime.now().toDate().getFullYear();\n\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlDatePopover\n id={meta.id}\n triggerProps={props.inputProps}\n value={value}\n withTime={isDateTime}\n disabled={props.disabled}\n clearable={props.clearable}\n captionLayout={\n props.captionLayout ?? (props.birthdate ? \"dropdown\" : undefined)\n }\n startMonth={\n props.startMonth ??\n (props.birthdate\n ? new Date(thisYear - BIRTHDATE_YEARS, 0, 1)\n : undefined)\n }\n endMonth={\n props.endMonth ??\n (props.birthdate ? new Date(thisYear, 11, 31) : undefined)\n }\n onChange={(v) => setValue(v)}\n />\n </FormField>\n );\n};\n\n/** How many years back a `birthdate` picker offers. Covers every living\n * person; the oldest verified human reached 122. */\nconst BIRTHDATE_YEARS = 120;\n"],"mappings":";;;;;;;;;;;AAiGA,MAAa,eAAe,UAA4B;CACtD,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YA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;EACrD,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,UAAU,KAAK;EAEf,UAAA,oBAAC,oBAAD;GACE,IAAI,KAAK;GACT,cAAc,MAAM;GACb;GACP,UAAU;GACV,UAAU,MAAM;GAChB,WAAW,MAAM;GACjB,eACE,MAAM,kBAAkB,MAAM,YAAY,aAAa,KAAA;GAEzD,YACE,MAAM,eACL,MAAM,YACH,IAAI,KAAK,WAAW,iBAAiB,GAAG,CAAC,IACzC,KAAA;GAEN,UACE,MAAM,aACL,MAAM,YAAY,IAAI,KAAK,UAAU,IAAI,EAAE,IAAI,KAAA;GAElD,WAAW,MAAM,SAAS,CAAC;EAC5B,CAAA;CACQ,CAAA;AAEf;;;AAIA,MAAM,kBAAkB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type BaseInputField } from "alepha/react/form";
|
|
3
|
-
import { type ReactNode } from "react";
|
|
3
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
4
4
|
export interface ControlDateRangeProps {
|
|
5
5
|
/**
|
|
6
6
|
* Bound `InputField` from `useForm`. Stores `[start, end]`, two date-only
|
|
@@ -36,6 +36,17 @@ export interface ControlDateRangeProps {
|
|
|
36
36
|
* placeholder already names it. Same contract as `ControlSelect`'s.
|
|
37
37
|
*/
|
|
38
38
|
triggerPrefix?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* An element drawn INSTEAD of the field, as the button that opens the
|
|
41
|
+
* calendar. Same contract as `ControlSelect`'s.
|
|
42
|
+
*/
|
|
43
|
+
trigger?: ReactElement<{
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* The calendar opened or closed. Same contract as `ControlSelect`'s.
|
|
48
|
+
*/
|
|
49
|
+
onPopupOpenChange?: (open: boolean) => void;
|
|
39
50
|
}
|
|
40
51
|
/**
|
|
41
52
|
* A closed range of calendar days, as one field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlDateRange.d.ts","sourceRoot":"","sources":["../../src/form/ControlDateRange.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlDateRange.d.ts","sourceRoot":"","sources":["../../src/form/ControlDateRange.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAepE,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;QAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACjD;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,6BA0M5D,CAAC"}
|
|
@@ -75,10 +75,12 @@ const ControlDateRange = (props) => {
|
|
|
75
75
|
setPending(false);
|
|
76
76
|
setValue([formatDateOnly(next.from), formatDateOnly(next.to)]);
|
|
77
77
|
setOpen(false);
|
|
78
|
+
props.onPopupOpenChange?.(false);
|
|
78
79
|
};
|
|
79
80
|
const showClear = Boolean(props.clearable && stored?.from && !props.disabled);
|
|
80
81
|
const size = TRIGGER_SIZES.default;
|
|
81
82
|
return /* @__PURE__ */ jsx(FormField, {
|
|
83
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
82
84
|
id: meta.id,
|
|
83
85
|
label: meta.label,
|
|
84
86
|
description: meta.description,
|
|
@@ -89,8 +91,16 @@ const ControlDateRange = (props) => {
|
|
|
89
91
|
onOpenChange: (next) => {
|
|
90
92
|
setOpen(next);
|
|
91
93
|
if (next) setPending(false);
|
|
94
|
+
props.onPopupOpenChange?.(next);
|
|
92
95
|
},
|
|
93
|
-
children: [/* @__PURE__ */
|
|
96
|
+
children: [props.trigger ? /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
97
|
+
id: meta.id,
|
|
98
|
+
disabled: props.disabled,
|
|
99
|
+
onPointerEnter: preloadCalendar,
|
|
100
|
+
onFocus: preloadCalendar,
|
|
101
|
+
render: props.trigger,
|
|
102
|
+
children: props.trigger.props.children
|
|
103
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
94
104
|
className: TRIGGER_WRAPPER_CLASSES,
|
|
95
105
|
children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
96
106
|
id: meta.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlDateRange.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlDateRange.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n Calendar as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n} from \"lucide-react\";\nimport { type ReactNode, useState } from \"react\";\nimport type { DateRange } from \"react-day-picker\";\n\nimport { LazyCalendar, preloadCalendar } from \"../calendar/LazyCalendar.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DATE_ONLY, formatDateOnly, parseDateOnly } from \"./dateOnly.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\n\nexport interface ControlDateRangeProps {\n /**\n * Bound `InputField` from `useForm`. Stores `[start, end]`, two date-only\n * strings, or nothing at all.\n */\n input: BaseInputField;\n label?: string;\n description?: string;\n disabled?: boolean;\n /**\n * Offer a way back to empty once a range is picked.\n *\n * A calendar has no \"none\" cell, so without this an optional range field is\n * one-way. Spelled `clearable` like every other control in the kit, and\n * drawn like one: the kit's `x` on the trigger, not a button beside it.\n */\n clearable?: boolean;\n /**\n * Shown on the trigger while the field is empty. Defaults to the\n * catalogue's `controlDateRange.placeholder`.\n */\n placeholder?: string;\n /**\n * Extra classes on the trigger button. A filter bar sizes its slots, and a\n * range trigger holds two dates rather than one, so it usually wants to be\n * wider than its neighbours.\n */\n triggerClassName?: string;\n /**\n * Drawn on the trigger just before the range, muted: the filter's name on a\n * filter bar, so a set range reads \"Created 1 Jan - 31 Jan\" the way a set\n * list reads \"Status Active\". Absent while the field is empty, because the\n * placeholder already names it. Same contract as `ControlSelect`'s.\n */\n triggerPrefix?: ReactNode;\n}\n\n/**\n * A closed range of calendar days, as one field.\n *\n * `z.dateRange()` makes both ends mandatory, so this control never writes a\n * half-range: `.optional()` on the schema is the only way to say \"no filter\",\n * and there is nothing in between.\n *\n * ⚠️ **The field is written on the second CLICK, not on the first complete\n * range**, and the difference is measured rather than assumed. The trap this\n * was written for is DayPicker handing back `{ from }` with no `to`\n * mid-gesture; react-day-picker ^10 does something else, which is worse for a\n * naive control: the first click answers `{ from: d, to: d }`, a complete\n * one-day range. A control that wrote whenever both ends existed would\n * therefore take the start date as the whole range and slam the popover shut\n * before the reader picked an end.\n *\n * So `pending` counts the gesture instead of reading its shape, and it\n * handles both behaviours: a genuinely half range holds, and a\n * DayPicker-completed first click holds too. `control-date-range.browser\n * .spec.tsx` drives two real clicks, which is what found this.\n *\n * ⚠️ **Local parts, never `new Date(value)`.** A date-only string is a\n * calendar day; parsing it as an instant shifts it by one west of Greenwich.\n * The two helpers are `control-date`'s own, shared rather than copied.\n */\nexport const ControlDateRange = (props: ControlDateRangeProps) => {\n const { tr, l } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const [open, setOpen] = useState(false);\n /**\n * Whether a selection gesture is half-made: one click in, waiting for the\n * other end. Reset whenever the popover opens, so an abandoned gesture\n * cannot make the next popover's first click look like a second one.\n */\n const [pending, setPending] = useState(false);\n\n const stored = toRange(value as unknown);\n const storedKey = Array.isArray(value) ? (value as string[]).join(\",\") : \"\";\n // The gesture in progress. Seeded from the field, and re-seeded whenever\n // the field moves underneath it - a form reset, or a value arriving from\n // the URL after the first paint.\n const [draft, setDraft] = useState<DateRange | undefined>(stored);\n const [seenKey, setSeenKey] = useState(storedKey);\n if (seenKey !== storedKey) {\n // ⚠️ Adjusted DURING render, not in an effect. React documents this as\n // the way to reset state when an input changes, and the effect version is\n // a lint error here (`react(set-state-in-effect)`) for the reason the\n // rule gives: it renders once with the stale draft and again with the new\n // one, so a value arriving from the URL is visibly wrong for a frame.\n //\n // Keyed on the joined VALUE, never on `stored`: `toRange` builds a new\n // object every render, so comparing objects would reset the draft on\n // every keystroke elsewhere in the form and discard a half-made\n // selection.\n setSeenKey(storedKey);\n setDraft(stored);\n }\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const shown = draft ?? stored;\n // Each end in the page's language, like `ControlDatePopover`: the\n // browser's own `toLocaleDateString()` turned 10 to 12 September into\n // \"9/10/2026 - 9/12/2026\" on a French page (#Q2392).\n const formatted = shown?.from\n ? shown.to\n ? `${l(shown.from)} - ${l(shown.to)}`\n : l(shown.from)\n : \"\";\n\n const handleSelect = (next: DateRange | undefined) => {\n setDraft(next);\n if (!next?.from) {\n setPending(false);\n return;\n }\n if (!next.to || !pending) {\n // The first click of a gesture, whichever shape DayPicker gave it. The\n // field keeps whatever it had: writing now would either fail the schema\n // (half a range) or record the start day as the whole range, and\n // clearing would destroy the old range before the new one exists.\n setPending(true);\n return;\n }\n setPending(false);\n setValue([formatDateOnly(next.from), formatDateOnly(next.to)]);\n setOpen(false);\n };\n\n const showClear = Boolean(props.clearable && stored?.from && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Popover\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (next) setPending(false);\n }}\n >\n {/* The kit's field trigger, and the kit's clear button positioned on\n it - `control-base/field-trigger`, the same two the selects on the\n filter bar beside this one draw (feedback #2197). The clear sits\n BESIDE the trigger rather than inside it because a button nested\n in a button is invalid, and Base UI's popover trigger would\n swallow its click anyway. */}\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n id={meta.id}\n // `date-trigger`, the same slot `ControlDate` claims: `styles.css`\n // gives the `--border-hover` border to a list of `data-slot`s, and\n // this is how the two calendars are on it.\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n // The calendar is a chunk of its own (`LazyCalendar`), fetched as\n // the pointer arrives or focus lands rather than on the click.\n onPointerEnter={preloadCalendar}\n onFocus={preloadCalendar}\n // `name` only, never the whole `input.props` spread: those\n // are an `<input>`'s props and this is a button, so their\n // `onChange` signature is genuinely incompatible. The name is\n // what `AutoForm`'s scroll-to-first-error looks a field up by.\n name={props.input.props.name}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n // Muted means \"nothing picked yet\", exactly as on a select.\n !formatted && \"text-muted-foreground\",\n props.triggerClassName,\n )}\n >\n {/* The room for the clear button - see `clearGap` in\n TRIGGER_SIZES for why it is a margin here and not padding on\n the trigger, and `ControlSelectCombobox` for `trigger-label`. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n {/*\n Muted whatever the field holds, matching every other leading\n icon in the kit. Without the class it inherits the trigger's\n own `color`, which swaps between muted and foreground to grey\n the PLACEHOLDER - so the icon brightened when a range was\n picked. An icon says what kind of field this is, which does\n not change when you fill it.\n */}\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n {/* The prefix rides in the same text run as the range, for the\n reason `ControlSelectCombobox` gives: one run, one space. */}\n <span className=\"truncate\">\n {props.triggerPrefix && formatted && (\n <span className=\"text-muted-foreground\">\n {props.triggerPrefix}{\" \"}\n </span>\n )}\n {formatted ||\n props.placeholder ||\n tr(\"controlDateRange.placeholder\", {\n default: \"Pick a date range\",\n })}\n </span>\n </span>\n {/* The same trailing caret a select trigger carries, appended by\n `ComboboxTrigger` there and written out here: this opens a\n popover, and without it the control reads as a text field that\n happens to have a calendar glyph. */}\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton\n onClick={() => {\n setDraft(undefined);\n setValue(undefined);\n }}\n />\n )}\n </div>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n {/* The range visuals were built and unused: `calendar.tsx` passes\n `...props` straight to DayPicker and already defines\n `range_start` / `range_middle` / `range_end`, which its custom\n `DayButton` reads into styled data attributes. */}\n <LazyCalendar mode=\"range\" selected={shown} onSelect={handleSelect} />\n </PopoverContent>\n </Popover>\n </FormField>\n );\n};\n\n/**\n * The stored pair as DayPicker's own shape, or nothing.\n *\n * Anything that is not two parseable date-only strings reads as empty rather\n * than as half a range: the value comes off a URL as often as off a form, and\n * a malformed one is the schema's to reject, not this control's to render.\n */\nconst toRange = (value: unknown): DateRange | undefined => {\n if (!Array.isArray(value) || value.length !== 2) return undefined;\n const [from, to] = value as string[];\n if (!from || !to || !DATE_ONLY.test(from) || !DATE_ONLY.test(to)) {\n return undefined;\n }\n return { from: parseDateOnly(from), to: parseDateOnly(to) };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAa,oBAAoB,UAAiC;CAChE,MAAM,EAAE,IAAI,MAAM,QAAQ;CAC1B,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;;;;;;CAMtC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,MAAM,SAAS,QAAQ,KAAgB;CACvC,MAAM,YAAY,MAAM,QAAQ,KAAK,IAAK,MAAmB,KAAK,GAAG,IAAI;CAIzE,MAAM,CAAC,OAAO,YAAY,SAAgC,MAAM;CAChE,MAAM,CAAC,SAAS,cAAc,SAAS,SAAS;CAChD,IAAI,YAAY,WAAW;EAWzB,WAAW,SAAS;EACpB,SAAS,MAAM;CACjB;CAEA,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,QAAQ,SAAS;CAIvB,MAAM,YAAY,OAAO,OACrB,MAAM,KACJ,GAAG,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAChC,EAAE,MAAM,IAAI,IACd;CAEJ,MAAM,gBAAgB,SAAgC;EACpD,SAAS,IAAI;EACb,IAAI,CAAC,MAAM,MAAM;GACf,WAAW,KAAK;GAChB;EACF;EACA,IAAI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D,EACE,eAAe;KACb,SAAS,KAAA,CAAS;KAClB,SAAS,KAAA,CAAS;IACpB,EACD,CAAA,CAEA;GACL,CAAA,GAAA,oBAAC,gBAAD;IAAgB,WAAU;IAAa,OAAM;IAK3C,UAAA,oBAAC,cAAD;KAAc,MAAK;KAAQ,UAAU;KAAO,UAAU;IAAe,CAAA;GACvD,CAAA,CACT;;CACA,CAAA;AAEf;;;;;;;;AASA,MAAM,WAAW,UAA0C;CACzD,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,OAAO,KAAA;CACxD,MAAM,CAAC,MAAM,MAAM;CACnB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,EAAE,GAC7D;CAEF,OAAO;EAAE,MAAM,cAAc,IAAI;EAAG,IAAI,cAAc,EAAE;CAAE;AAC5D"}
|
|
1
|
+
{"version":3,"file":"ControlDateRange.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlDateRange.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n Calendar as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n} from \"lucide-react\";\nimport { type ReactElement, type ReactNode, useState } from \"react\";\nimport type { DateRange } from \"react-day-picker\";\n\nimport { LazyCalendar, preloadCalendar } from \"../calendar/LazyCalendar.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DATE_ONLY, formatDateOnly, parseDateOnly } from \"./dateOnly.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\n\nexport interface ControlDateRangeProps {\n /**\n * Bound `InputField` from `useForm`. Stores `[start, end]`, two date-only\n * strings, or nothing at all.\n */\n input: BaseInputField;\n label?: string;\n description?: string;\n disabled?: boolean;\n /**\n * Offer a way back to empty once a range is picked.\n *\n * A calendar has no \"none\" cell, so without this an optional range field is\n * one-way. Spelled `clearable` like every other control in the kit, and\n * drawn like one: the kit's `x` on the trigger, not a button beside it.\n */\n clearable?: boolean;\n /**\n * Shown on the trigger while the field is empty. Defaults to the\n * catalogue's `controlDateRange.placeholder`.\n */\n placeholder?: string;\n /**\n * Extra classes on the trigger button. A filter bar sizes its slots, and a\n * range trigger holds two dates rather than one, so it usually wants to be\n * wider than its neighbours.\n */\n triggerClassName?: string;\n /**\n * Drawn on the trigger just before the range, muted: the filter's name on a\n * filter bar, so a set range reads \"Created 1 Jan - 31 Jan\" the way a set\n * list reads \"Status Active\". Absent while the field is empty, because the\n * placeholder already names it. Same contract as `ControlSelect`'s.\n */\n triggerPrefix?: ReactNode;\n /**\n * An element drawn INSTEAD of the field, as the button that opens the\n * calendar. Same contract as `ControlSelect`'s.\n */\n trigger?: ReactElement<{ children?: ReactNode }>;\n /**\n * The calendar opened or closed. Same contract as `ControlSelect`'s.\n */\n onPopupOpenChange?: (open: boolean) => void;\n}\n\n/**\n * A closed range of calendar days, as one field.\n *\n * `z.dateRange()` makes both ends mandatory, so this control never writes a\n * half-range: `.optional()` on the schema is the only way to say \"no filter\",\n * and there is nothing in between.\n *\n * ⚠️ **The field is written on the second CLICK, not on the first complete\n * range**, and the difference is measured rather than assumed. The trap this\n * was written for is DayPicker handing back `{ from }` with no `to`\n * mid-gesture; react-day-picker ^10 does something else, which is worse for a\n * naive control: the first click answers `{ from: d, to: d }`, a complete\n * one-day range. A control that wrote whenever both ends existed would\n * therefore take the start date as the whole range and slam the popover shut\n * before the reader picked an end.\n *\n * So `pending` counts the gesture instead of reading its shape, and it\n * handles both behaviours: a genuinely half range holds, and a\n * DayPicker-completed first click holds too. `control-date-range.browser\n * .spec.tsx` drives two real clicks, which is what found this.\n *\n * ⚠️ **Local parts, never `new Date(value)`.** A date-only string is a\n * calendar day; parsing it as an instant shifts it by one west of Greenwich.\n * The two helpers are `control-date`'s own, shared rather than copied.\n */\nexport const ControlDateRange = (props: ControlDateRangeProps) => {\n const { tr, l } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const [open, setOpen] = useState(false);\n /**\n * Whether a selection gesture is half-made: one click in, waiting for the\n * other end. Reset whenever the popover opens, so an abandoned gesture\n * cannot make the next popover's first click look like a second one.\n */\n const [pending, setPending] = useState(false);\n\n const stored = toRange(value as unknown);\n const storedKey = Array.isArray(value) ? (value as string[]).join(\",\") : \"\";\n // The gesture in progress. Seeded from the field, and re-seeded whenever\n // the field moves underneath it - a form reset, or a value arriving from\n // the URL after the first paint.\n const [draft, setDraft] = useState<DateRange | undefined>(stored);\n const [seenKey, setSeenKey] = useState(storedKey);\n if (seenKey !== storedKey) {\n // ⚠️ Adjusted DURING render, not in an effect. React documents this as\n // the way to reset state when an input changes, and the effect version is\n // a lint error here (`react(set-state-in-effect)`) for the reason the\n // rule gives: it renders once with the stale draft and again with the new\n // one, so a value arriving from the URL is visibly wrong for a frame.\n //\n // Keyed on the joined VALUE, never on `stored`: `toRange` builds a new\n // object every render, so comparing objects would reset the draft on\n // every keystroke elsewhere in the form and discard a half-made\n // selection.\n setSeenKey(storedKey);\n setDraft(stored);\n }\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const shown = draft ?? stored;\n // Each end in the page's language, like `ControlDatePopover`: the\n // browser's own `toLocaleDateString()` turned 10 to 12 September into\n // \"9/10/2026 - 9/12/2026\" on a French page (#Q2392).\n const formatted = shown?.from\n ? shown.to\n ? `${l(shown.from)} - ${l(shown.to)}`\n : l(shown.from)\n : \"\";\n\n const handleSelect = (next: DateRange | undefined) => {\n setDraft(next);\n if (!next?.from) {\n setPending(false);\n return;\n }\n if (!next.to || !pending) {\n // The first click of a gesture, whichever shape DayPicker gave it. The\n // field keeps whatever it had: writing now would either fail the schema\n // (half a range) or record the start day as the whole range, and\n // clearing would destroy the old range before the new one exists.\n setPending(true);\n return;\n }\n setPending(false);\n setValue([formatDateOnly(next.from), formatDateOnly(next.to)]);\n setOpen(false);\n // Closed by hand, not through the popover, so its own callback is not\n // called for this one.\n props.onPopupOpenChange?.(false);\n };\n\n const showClear = Boolean(props.clearable && stored?.from && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Popover\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (next) setPending(false);\n props.onPopupOpenChange?.(next);\n }}\n >\n {/* The kit's field trigger, and the kit's clear button positioned on\n it - `control-base/field-trigger`, the same two the selects on the\n filter bar beside this one draw (feedback #2197). The clear sits\n BESIDE the trigger rather than inside it because a button nested\n in a button is invalid, and Base UI's popover trigger would\n swallow its click anyway.\n\n A caller's own `trigger` replaces both, children handed over for\n the reason `ControlSelectCombobox` gives. */}\n {props.trigger ? (\n <PopoverTrigger\n id={meta.id}\n disabled={props.disabled}\n onPointerEnter={preloadCalendar}\n onFocus={preloadCalendar}\n render={props.trigger}\n >\n {props.trigger.props.children}\n </PopoverTrigger>\n ) : (\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n id={meta.id}\n // `date-trigger`, the same slot `ControlDate` claims: `styles.css`\n // gives the `--border-hover` border to a list of `data-slot`s, and\n // this is how the two calendars are on it.\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n // The calendar is a chunk of its own (`LazyCalendar`), fetched as\n // the pointer arrives or focus lands rather than on the click.\n onPointerEnter={preloadCalendar}\n onFocus={preloadCalendar}\n // `name` only, never the whole `input.props` spread: those\n // are an `<input>`'s props and this is a button, so their\n // `onChange` signature is genuinely incompatible. The name is\n // what `AutoForm`'s scroll-to-first-error looks a field up by.\n name={props.input.props.name}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n // Muted means \"nothing picked yet\", exactly as on a select.\n !formatted && \"text-muted-foreground\",\n props.triggerClassName,\n )}\n >\n {/* The room for the clear button - see `clearGap` in\n TRIGGER_SIZES for why it is a margin here and not padding on\n the trigger, and `ControlSelectCombobox` for `trigger-label`. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n {/*\n Muted whatever the field holds, matching every other leading\n icon in the kit. Without the class it inherits the trigger's\n own `color`, which swaps between muted and foreground to grey\n the PLACEHOLDER - so the icon brightened when a range was\n picked. An icon says what kind of field this is, which does\n not change when you fill it.\n */}\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n {/* The prefix rides in the same text run as the range, for the\n reason `ControlSelectCombobox` gives: one run, one space. */}\n <span className=\"truncate\">\n {props.triggerPrefix && formatted && (\n <span className=\"text-muted-foreground\">\n {props.triggerPrefix}{\" \"}\n </span>\n )}\n {formatted ||\n props.placeholder ||\n tr(\"controlDateRange.placeholder\", {\n default: \"Pick a date range\",\n })}\n </span>\n </span>\n {/* The same trailing caret a select trigger carries, appended by\n `ComboboxTrigger` there and written out here: this opens a\n popover, and without it the control reads as a text field that\n happens to have a calendar glyph. */}\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton\n onClick={() => {\n setDraft(undefined);\n setValue(undefined);\n }}\n />\n )}\n </div>\n )}\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n {/* The range visuals were built and unused: `calendar.tsx` passes\n `...props` straight to DayPicker and already defines\n `range_start` / `range_middle` / `range_end`, which its custom\n `DayButton` reads into styled data attributes. */}\n <LazyCalendar mode=\"range\" selected={shown} onSelect={handleSelect} />\n </PopoverContent>\n </Popover>\n </FormField>\n );\n};\n\n/**\n * The stored pair as DayPicker's own shape, or nothing.\n *\n * Anything that is not two parseable date-only strings reads as empty rather\n * than as half a range: the value comes off a URL as often as off a form, and\n * a malformed one is the schema's to reject, not this control's to render.\n */\nconst toRange = (value: unknown): DateRange | undefined => {\n if (!Array.isArray(value) || value.length !== 2) return undefined;\n const [from, to] = value as string[];\n if (!from || !to || !DATE_ONLY.test(from) || !DATE_ONLY.test(to)) {\n return undefined;\n }\n return { from: parseDateOnly(from), to: parseDateOnly(to) };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,oBAAoB,UAAiC;CAChE,MAAM,EAAE,IAAI,MAAM,QAAQ;CAC1B,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;;;;;;CAMtC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,MAAM,SAAS,QAAQ,KAAgB;CACvC,MAAM,YAAY,MAAM,QAAQ,KAAK,IAAK,MAAmB,KAAK,GAAG,IAAI;CAIzE,MAAM,CAAC,OAAO,YAAY,SAAgC,MAAM;CAChE,MAAM,CAAC,SAAS,cAAc,SAAS,SAAS;CAChD,IAAI,YAAY,WAAW;EAWzB,WAAW,SAAS;EACpB,SAAS,MAAM;CACjB;CAEA,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,QAAQ,SAAS;CAIvB,MAAM,YAAY,OAAO,OACrB,MAAM,KACJ,GAAG,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAChC,EAAE,MAAM,IAAI,IACd;CAEJ,MAAM,gBAAgB,SAAgC;EACpD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IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,UAAW,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ControlNumber.d.ts","sourceRoot":"","sources":["../../src/form/ControlNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAO3B,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,UAAW,kBAAkB,6BAyFtD,CAAC"}
|
|
@@ -21,6 +21,7 @@ const ControlNumber = (props) => {
|
|
|
21
21
|
const lo = min ?? 0;
|
|
22
22
|
const hi = max ?? 100;
|
|
23
23
|
return /* @__PURE__ */ jsx(FormField, {
|
|
24
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
24
25
|
id: meta.id,
|
|
25
26
|
label: meta.label,
|
|
26
27
|
description: meta.description,
|
|
@@ -46,6 +47,7 @@ const ControlNumber = (props) => {
|
|
|
46
47
|
}
|
|
47
48
|
const Icon = iconFor(meta.iconHint);
|
|
48
49
|
return /* @__PURE__ */ jsx(FormField, {
|
|
50
|
+
onBlur: () => props.input.form?.blur(props.input.path),
|
|
49
51
|
id: meta.id,
|
|
50
52
|
label: meta.label,
|
|
51
53
|
description: meta.description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlNumber.js","names":[],"sources":["../../src/form/ControlNumber.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Slider } from \"../core/Slider.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport { iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlNumberProps {\n /**\n * Bound numeric `InputField` from `useForm`.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a slider instead of a number input.\n */\n slider?: boolean;\n /**\n * Minimum allowed value. Falls back to schema `minimum`.\n */\n min?: number;\n /**\n * Maximum allowed value. Falls back to schema `maximum`.\n */\n max?: number;\n /**\n * Step size. Defaults to 1.\n */\n step?: number;\n /**\n * Disable the input.\n */\n disabled?: boolean;\n /**\n * Autofocus the input on mount. Ignored by the slider variant, which is not\n * a text field and has nothing to type into.\n */\n autoFocus?: boolean;\n}\n\nexport const ControlNumber = (props: ControlNumberProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const min = props.min ?? meta.constraints.minimum;\n const max = props.max ?? meta.constraints.maximum;\n\n if (props.slider) {\n const lo = min ?? 0;\n const hi = max ?? 100;\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"flex items-center gap-3 py-2\">\n <Slider\n id={meta.id}\n min={lo}\n max={hi}\n step={props.step ?? 1}\n disabled={props.disabled}\n value={[Number(value ?? lo)]}\n onValueChange={(v) => setValue(Array.isArray(v) ? v[0] : v)}\n className=\"flex-1\"\n />\n <span className=\"text-muted-foreground w-10 text-right text-sm tabular-nums\">\n {value ?? lo}\n </span>\n </div>\n </FormField>\n );\n }\n\n const Icon = iconFor(meta.iconHint);\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n id={meta.id}\n /*\n * Text controls carry the field name; numeric ones did not, so a number\n * rendered as `<input type=\"number\">` with no `name` at all. Two things\n * depended on it: `AutoForm`'s scroll-to-first-error looks the field up\n * with `document.querySelector('[name=\"…\"]')`, so it silently gave up on\n * numeric fields, and the browser cannot label an unnamed field for\n * autofill. Found while writing e2e tests against a price field that no\n * selector could reach.\n */\n name={props.input.props.name}\n type=\"number\"\n min={min}\n max={max}\n step={props.step}\n disabled={props.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- a caller-requested autofocus, see `autoFocus` in form/Control.tsx\n autoFocus={props.autoFocus}\n value={value ?? \"\"}\n onChange={(e) => {\n const v = e.target.value;\n setValue(v === \"\" ? undefined : Number(v));\n }}\n className={Icon ? \"pl-9\" : undefined}\n />\n </div>\n </FormField>\n );\n};\n"],"mappings":";;;;;;;;AAwDA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAA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M,IAAI,EAAE,OAAO;KACnB,SAAS,MAAM,KAAK,KAAA,IAAY,OAAO,CAAC,CAAC;IAC3C;IACA,WAAW,OAAO,SAAS,KAAA;GAC5B,CAAA,CACE;;CACI,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"ControlNumber.js","names":[],"sources":["../../src/form/ControlNumber.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Slider } from \"../core/Slider.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport { iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlNumberProps {\n /**\n * Bound numeric `InputField` from `useForm`.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a slider instead of a number input.\n */\n slider?: boolean;\n /**\n * Minimum allowed value. Falls back to schema `minimum`.\n */\n min?: number;\n /**\n * Maximum allowed value. Falls back to schema `maximum`.\n */\n max?: number;\n /**\n * Step size. Defaults to 1.\n */\n step?: number;\n /**\n * Disable the input.\n */\n disabled?: boolean;\n /**\n * Autofocus the input on mount. Ignored by the slider variant, which is not\n * a text field and has nothing to type into.\n */\n autoFocus?: boolean;\n}\n\nexport const ControlNumber = (props: ControlNumberProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n if (!props.input?.props) return null;\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const min = props.min ?? meta.constraints.minimum;\n const max = props.max ?? meta.constraints.maximum;\n\n if (props.slider) {\n const lo = min ?? 0;\n const hi = max ?? 100;\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"flex items-center gap-3 py-2\">\n <Slider\n id={meta.id}\n min={lo}\n max={hi}\n step={props.step ?? 1}\n disabled={props.disabled}\n value={[Number(value ?? lo)]}\n onValueChange={(v) => setValue(Array.isArray(v) ? v[0] : v)}\n className=\"flex-1\"\n />\n <span className=\"text-muted-foreground w-10 text-right text-sm tabular-nums\">\n {value ?? lo}\n </span>\n </div>\n </FormField>\n );\n }\n\n const Icon = iconFor(meta.iconHint);\n return (\n <FormField\n onBlur={() => props.input.form?.blur(props.input.path)}\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n id={meta.id}\n /*\n * Text controls carry the field name; numeric ones did not, so a number\n * rendered as `<input type=\"number\">` with no `name` at all. Two things\n * depended on it: `AutoForm`'s scroll-to-first-error looks the field up\n * with `document.querySelector('[name=\"…\"]')`, so it silently gave up on\n * numeric fields, and the browser cannot label an unnamed field for\n * autofill. Found while writing e2e tests against a price field that no\n * selector could reach.\n */\n name={props.input.props.name}\n type=\"number\"\n min={min}\n max={max}\n step={props.step}\n disabled={props.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- a caller-requested autofocus, see `autoFocus` in form/Control.tsx\n autoFocus={props.autoFocus}\n value={value ?? \"\"}\n onChange={(e) => {\n const v = e.target.value;\n setValue(v === \"\" ? undefined : Number(v));\n }}\n className={Icon ? \"pl-9\" : undefined}\n />\n </div>\n </FormField>\n );\n};\n"],"mappings":";;;;;;;;AAwDA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,O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AS,MAAM,KAAK,KAAA,IAAY,OAAO,CAAC,CAAC;IAC3C;IACA,WAAW,OAAO,SAAS,KAAA;GAC5B,CAAA,CACE;;CACI,CAAA;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlObject.d.ts","sourceRoot":"","sources":["../../src/form/ControlObject.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ControlObject.d.ts","sourceRoot":"","sources":["../../src/form/ControlObject.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAI3D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,UAAW,kBAAkB,6BA8JtD,CAAC"}
|