@dloizides/ui-forms 1.26.0 → 1.27.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.27.0
4
+
5
+ DATE-INPUT-1 "Every date or date-time field uses the shared input".
6
+
7
+ - New `DateField` (`YYYY-MM-DD`) and `DateTimeField` (`YYYY-MM-DDTHH:mm`), rendered through `Field`; a real `<input type>` on web.
8
+
3
9
  ## 1.26.0
4
10
 
5
11
  INVOICE-3 "Invoice interface over a user-chosen folder": owner picks.
package/dist/index.d.mts CHANGED
@@ -871,6 +871,31 @@ interface DateRangeControlProps {
871
871
  }
872
872
  declare function DateRangeControl({ value, onChange, onSubmit, fromLabel, toLabel, fromPlaceholder, toPlaceholder, accessibilityHint, style, testID, }: DateRangeControlProps): React.ReactElement;
873
873
 
874
+ interface DateFieldProps {
875
+ /** PRE-LOCALIZED label; also the accessible name. */
876
+ label: string;
877
+ /** `YYYY-MM-DD` for `DateField`, `YYYY-MM-DDTHH:mm` for `DateTimeField`; empty is `''`. */
878
+ value: string;
879
+ onChange: (value: string) => void;
880
+ /** Runs on Enter. */
881
+ onSubmit?: () => void;
882
+ accessibilityHint: string;
883
+ testID: string;
884
+ required?: boolean;
885
+ hint?: string;
886
+ error?: string;
887
+ disabled?: boolean;
888
+ min?: string;
889
+ max?: string;
890
+ }
891
+ type DateTimeFieldProps = DateFieldProps;
892
+
893
+ /** A labelled calendar date: takes and emits `YYYY-MM-DD`, empty is `''`. */
894
+ declare function DateField(props: DateFieldProps): React.ReactElement;
895
+
896
+ /** A labelled local date and time: takes and emits `YYYY-MM-DDTHH:mm`, empty is `''`. */
897
+ declare function DateTimeField(props: DateTimeFieldProps): React.ReactElement;
898
+
874
899
  /**
875
900
  * `AnchoredMenu` — the floating option list shared by `SelectControl` and `TypeaheadControl`.
876
901
  *
@@ -1185,4 +1210,4 @@ interface UploadWithLinkFieldProps {
1185
1210
  /** An image field: preview, an upload control, and a link input revealed on request. */
1186
1211
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1187
1212
 
1188
- export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, type DateRangeControlProps, type DateRangeValue, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
1213
+ export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
package/dist/index.d.ts CHANGED
@@ -871,6 +871,31 @@ interface DateRangeControlProps {
871
871
  }
872
872
  declare function DateRangeControl({ value, onChange, onSubmit, fromLabel, toLabel, fromPlaceholder, toPlaceholder, accessibilityHint, style, testID, }: DateRangeControlProps): React.ReactElement;
873
873
 
874
+ interface DateFieldProps {
875
+ /** PRE-LOCALIZED label; also the accessible name. */
876
+ label: string;
877
+ /** `YYYY-MM-DD` for `DateField`, `YYYY-MM-DDTHH:mm` for `DateTimeField`; empty is `''`. */
878
+ value: string;
879
+ onChange: (value: string) => void;
880
+ /** Runs on Enter. */
881
+ onSubmit?: () => void;
882
+ accessibilityHint: string;
883
+ testID: string;
884
+ required?: boolean;
885
+ hint?: string;
886
+ error?: string;
887
+ disabled?: boolean;
888
+ min?: string;
889
+ max?: string;
890
+ }
891
+ type DateTimeFieldProps = DateFieldProps;
892
+
893
+ /** A labelled calendar date: takes and emits `YYYY-MM-DD`, empty is `''`. */
894
+ declare function DateField(props: DateFieldProps): React.ReactElement;
895
+
896
+ /** A labelled local date and time: takes and emits `YYYY-MM-DDTHH:mm`, empty is `''`. */
897
+ declare function DateTimeField(props: DateTimeFieldProps): React.ReactElement;
898
+
874
899
  /**
875
900
  * `AnchoredMenu` — the floating option list shared by `SelectControl` and `TypeaheadControl`.
876
901
  *
@@ -1185,4 +1210,4 @@ interface UploadWithLinkFieldProps {
1185
1210
  /** An image field: preview, an upload control, and a link input revealed on request. */
1186
1211
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1187
1212
 
1188
- export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, type DateRangeControlProps, type DateRangeValue, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
1213
+ export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
package/dist/index.js CHANGED
@@ -2116,6 +2116,86 @@ function DateRangeControl({
2116
2116
  )
2117
2117
  ] });
2118
2118
  }
2119
+ var NATIVE_INPUT_BOX = {
2120
+ borderStyle: "solid",
2121
+ boxSizing: "border-box",
2122
+ fontFamily: "inherit",
2123
+ width: "100%"
2124
+ };
2125
+ function buildNativeInputStyle(themed) {
2126
+ const { paddingHorizontal, paddingVertical, ...box } = reactNative.StyleSheet.flatten(controlStyles.input);
2127
+ return {
2128
+ ...box,
2129
+ ...themed,
2130
+ ...NATIVE_INPUT_BOX,
2131
+ paddingBlock: paddingVertical,
2132
+ paddingInline: paddingHorizontal
2133
+ };
2134
+ }
2135
+ function WebDateInput({ fieldProps, context, webInputType }) {
2136
+ const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
2137
+ const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
2138
+ const webA11y = webFieldA11y({
2139
+ describedById: context.describedById,
2140
+ hasError: context.hasError,
2141
+ required
2142
+ });
2143
+ const handleChange = (event) => onChange(event.target.value);
2144
+ const handleKeyDown = (event) => {
2145
+ if (event.key !== "Enter" || onSubmit === void 0) return;
2146
+ event.preventDefault();
2147
+ onSubmit();
2148
+ };
2149
+ return /* @__PURE__ */ jsxRuntime.jsx(
2150
+ "input",
2151
+ {
2152
+ ...webA11y,
2153
+ ...hoverBind,
2154
+ ...focusBind,
2155
+ "aria-label": label,
2156
+ "data-testid": testID,
2157
+ disabled,
2158
+ id: context.controlId,
2159
+ max,
2160
+ min,
2161
+ style: buildNativeInputStyle(style),
2162
+ title: accessibilityHint,
2163
+ type: webInputType,
2164
+ value,
2165
+ onChange: handleChange,
2166
+ onKeyDown: handleKeyDown
2167
+ }
2168
+ );
2169
+ }
2170
+ var IS_WEB7 = reactNative.Platform.OS === "web";
2171
+ function renderNativeInput(fieldProps, context) {
2172
+ return /* @__PURE__ */ jsxRuntime.jsx(
2173
+ ThemedTextInput,
2174
+ {
2175
+ accessibilityHint: fieldProps.accessibilityHint,
2176
+ accessibilityLabel: fieldProps.label,
2177
+ describedById: context.describedById,
2178
+ editable: fieldProps.disabled !== true,
2179
+ hasError: context.hasError,
2180
+ id: context.controlId,
2181
+ requiredField: fieldProps.required,
2182
+ testID: fieldProps.testID,
2183
+ value: fieldProps.value,
2184
+ onChangeText: fieldProps.onChange,
2185
+ onSubmitEditing: fieldProps.onSubmit
2186
+ }
2187
+ );
2188
+ }
2189
+ function TemporalField({ fieldProps, webInputType }) {
2190
+ const { label, required, hint, error } = fieldProps;
2191
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label, required, children: (context) => IS_WEB7 ? /* @__PURE__ */ jsxRuntime.jsx(WebDateInput, { context, fieldProps, webInputType }) : renderNativeInput(fieldProps, context) });
2192
+ }
2193
+ function DateField(props) {
2194
+ return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "date" });
2195
+ }
2196
+ function DateTimeField(props) {
2197
+ return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "datetime-local" });
2198
+ }
2119
2199
 
2120
2200
  // src/groupSelection/groupSelection.ts
2121
2201
  var NONE = 0;
@@ -2363,7 +2443,9 @@ exports.DEFAULT_MAX_RECENTS = DEFAULT_MAX_RECENTS;
2363
2443
  exports.DEFAULT_OPTIONAL_LABEL = DEFAULT_OPTIONAL_LABEL;
2364
2444
  exports.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
2365
2445
  exports.DEFAULT_TYPEAHEAD_MIN_CHARS = DEFAULT_TYPEAHEAD_MIN_CHARS;
2446
+ exports.DateField = DateField;
2366
2447
  exports.DateRangeControl = DateRangeControl;
2448
+ exports.DateTimeField = DateTimeField;
2367
2449
  exports.Field = Field;
2368
2450
  exports.FormActions = FormActions;
2369
2451
  exports.FormCell = FormCell;