@dloizides/ui-forms 1.58.0 → 1.60.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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import React41, { createContext, forwardRef, useRef, useImperativeHandle, useState, useCallback, useMemo, useEffect, useLayoutEffect, useContext } from 'react';
1
+ import React41, { createContext, forwardRef, useRef, useImperativeHandle, useState, useCallback, useMemo, useEffect, useContext, useLayoutEffect } from 'react';
2
2
  import { Platform, StyleSheet, TextInput, View, Text, Pressable, useWindowDimensions, ScrollView, Animated, Easing, AccessibilityInfo, Image, TouchableOpacity, Switch, Modal } from 'react-native';
3
3
  import { useUi } from '@dloizides/ui-feedback';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -2259,6 +2259,10 @@ function useSelectLookMetrics() {
2259
2259
  const { width } = useWindowDimensions();
2260
2260
  return selectLookMetrics(config, width);
2261
2261
  }
2262
+ function lookInputBox(m) {
2263
+ if (m === void 0) return void 0;
2264
+ return { minHeight: m.height, height: m.height, paddingHorizontal: m.paddingHorizontal, paddingVertical: m.paddingVertical, fontSize: m.fontSize, borderRadius: m.borderRadius };
2265
+ }
2262
2266
  function chevronDataUri(color) {
2263
2267
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="${color}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg>`;
2264
2268
  return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
@@ -2857,6 +2861,7 @@ function TypeaheadControlImpl(props, ref) {
2857
2861
  const options = "options" in props ? props.options : void 0;
2858
2862
  const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
2859
2863
  const { theme } = useUi();
2864
+ const look = useSelectLookMetrics();
2860
2865
  const { colors, palette } = theme;
2861
2866
  const anchorRef = useRef(null);
2862
2867
  const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
@@ -2888,7 +2893,7 @@ function TypeaheadControlImpl(props, ref) {
2888
2893
  onBlur: handleBlur,
2889
2894
  onKeyPress: state.handleKeyPress,
2890
2895
  onSubmitEditing: state.handleSubmit,
2891
- style: [controlStyles.input, { borderColor: hasError ? fieldErrorInk(theme) : colors.border, backgroundColor: colors.surface, color: colors.text }],
2896
+ style: [controlStyles.input, { borderColor: hasError ? fieldErrorInk(theme) : colors.border, backgroundColor: colors.surface, color: colors.text }, lookInputBox(look)],
2892
2897
  testID: search?.inputTestID ?? `${testID}-input`
2893
2898
  }
2894
2899
  ),
@@ -2918,8 +2923,8 @@ var NATIVE_INPUT_BOX = {
2918
2923
  fontFamily: "inherit",
2919
2924
  width: "100%"
2920
2925
  };
2921
- function buildNativeInputStyle(themed) {
2922
- const { paddingHorizontal, paddingVertical, ...box } = StyleSheet.flatten(controlStyles.input);
2926
+ function buildNativeInputStyle(themed, look) {
2927
+ const { paddingHorizontal, paddingVertical, ...box } = StyleSheet.flatten([controlStyles.input, look]);
2923
2928
  return {
2924
2929
  ...box,
2925
2930
  ...themed,
@@ -2931,6 +2936,7 @@ function buildNativeInputStyle(themed) {
2931
2936
  function WebDateInput({ fieldProps, context, webInputType }) {
2932
2937
  const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
2933
2938
  const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
2939
+ const look = lookInputBox(useSelectLookMetrics());
2934
2940
  const webA11y = webFieldA11y({
2935
2941
  describedById: context.describedById,
2936
2942
  hasError: context.hasError,
@@ -2954,7 +2960,7 @@ function WebDateInput({ fieldProps, context, webInputType }) {
2954
2960
  id: context.controlId,
2955
2961
  max,
2956
2962
  min,
2957
- style: buildNativeInputStyle(style),
2963
+ style: buildNativeInputStyle(style, look),
2958
2964
  title: accessibilityHint,
2959
2965
  type: webInputType,
2960
2966
  value,
@@ -3111,6 +3117,7 @@ var DEFAULT_DATE_PICKER_LABELS = {
3111
3117
  rangeDialog: "Choose a date range",
3112
3118
  openCalendar: "Open calendar",
3113
3119
  openCalendarHint: "Opens a calendar to pick the date",
3120
+ datePlaceholder: "",
3114
3121
  previousMonth: "Previous month",
3115
3122
  nextMonth: "Next month",
3116
3123
  monthHint: "Shows another month",
@@ -3665,6 +3672,14 @@ function closedFieldMinWidth(text, iconRoom) {
3665
3672
  return Math.ceil(chars * FONT_PX * GLYPH_EM) + PAD_INLINE + iconRoom + BORDER + BORDER;
3666
3673
  }
3667
3674
 
3675
+ // src/DatePicker/utils/datePattern.ts
3676
+ var SAMPLE = new Date(Date.UTC(2027, 5, 12));
3677
+ var PART_TOKEN = { day: "dd", month: "mm", year: "yyyy" };
3678
+ function datePattern(locale) {
3679
+ const parts = new Intl.DateTimeFormat(locale, { day: "2-digit", month: "2-digit", year: "numeric", timeZone: "UTC" }).formatToParts(SAMPLE);
3680
+ return parts.map((part) => PART_TOKEN[part.type] ?? part.value).join("");
3681
+ }
3682
+
3668
3683
  // src/DatePicker/utils/typedEdit.ts
3669
3684
  var DELETE_KEYS = /* @__PURE__ */ new Set(["Backspace", "Delete"]);
3670
3685
  function isPrintable(event) {
@@ -3715,7 +3730,7 @@ var ICON_SLOT = { position: "absolute", right: 2, top: 0, bottom: 0, display: "f
3715
3730
  var anchorStyles = StyleSheet.create({ wrap: { position: "relative", width: "100%" } });
3716
3731
  function DatePickerInput({ fieldProps, context, onTypedError }) {
3717
3732
  const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
3718
- const { labels, display } = useDatePickerConfig();
3733
+ const { labels, display, locale } = useDatePickerConfig();
3719
3734
  const phone = useIsPhone();
3720
3735
  const [open, setOpen] = useState(false);
3721
3736
  const anchorRef = useRef(null);
@@ -3724,6 +3739,7 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
3724
3739
  const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
3725
3740
  const edit = typedEditBind(typed);
3726
3741
  const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
3742
+ const look = lookInputBox(useSelectLookMetrics());
3727
3743
  const focus = focusBind;
3728
3744
  const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
3729
3745
  const close = useCallback(() => setOpen(false), []);
@@ -3756,7 +3772,8 @@ function DatePickerInput({ fieldProps, context, onTypedError }) {
3756
3772
  "data-testid": testID,
3757
3773
  disabled,
3758
3774
  id: context.controlId,
3759
- style: { ...buildNativeInputStyle(style), paddingInlineEnd: ICON_ROOM },
3775
+ placeholder: labels.datePlaceholder !== "" ? labels.datePlaceholder : datePattern(locale),
3776
+ style: { ...buildNativeInputStyle(style, look), paddingInlineEnd: ICON_ROOM },
3760
3777
  title: accessibilityHint,
3761
3778
  type: "text",
3762
3779
  value: typed.display,
@@ -6561,6 +6578,6 @@ var PasswordField = React41.forwardRef(function PasswordField2({ label, value, o
6561
6578
  ] }) });
6562
6579
  });
6563
6580
 
6564
- export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, CheckboxLookProvider, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateDisplay, DateField, DateInput, DatePickerProvider, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FileInput, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, MultiSelectField, PHONE_MAX_WIDTH, PasswordField, PasswordRules, PasswordRulesDisplay, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, RevealToggle, RuleTone, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectLookProvider, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, assignServerErrors, buildSearchSelectSections, canRemoveLine, changedRules, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, rowsForText, ruleAnnouncement, ruleColorsFrom, ruleTone, selectLookMetrics, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useServerFieldErrors, useThemedInput, validateBic, validateDecision, validateIban };
6581
+ export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, CheckboxLookProvider, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateDisplay, DateField, DateInput, DatePickerProvider, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FileInput, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, MultiSelectField, PHONE_MAX_WIDTH, PasswordField, PasswordRules, PasswordRulesDisplay, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, RevealToggle, RuleTone, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectLookProvider, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, assignServerErrors, buildSearchSelectSections, canRemoveLine, changedRules, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, lookInputBox, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, rowsForText, ruleAnnouncement, ruleColorsFrom, ruleTone, selectLookMetrics, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useSelectLookMetrics, useServerFieldErrors, useThemedInput, validateBic, validateDecision, validateIban };
6565
6582
  //# sourceMappingURL=index.mjs.map
6566
6583
  //# sourceMappingURL=index.mjs.map