@dloizides/ui-forms 1.44.0 → 1.45.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
@@ -1805,7 +1805,10 @@ var ACTIVATION_KEYS = ["Enter", " ", "Spacebar"];
1805
1805
  var HINT_FONT_SIZE2 = 12;
1806
1806
  var BOX_SIZE = 20;
1807
1807
  var BOX_RADIUS = 5;
1808
- var CHECK_FONT_SIZE = 14;
1808
+ var TICK_WIDTH = 6;
1809
+ var TICK_HEIGHT = 10;
1810
+ var TICK_STROKE = 2;
1811
+ var TICK_LIFT = -2;
1809
1812
  var DISABLED_OPACITY = 0.5;
1810
1813
  var FOCUS_RING_WIDTH = 2;
1811
1814
  var WEB_NO_DEFAULT_OUTLINE = { outlineStyle: "none" };
@@ -1843,10 +1846,13 @@ var styles15 = StyleSheet.create({
1843
1846
  borderWidth: FOCUS_RING_WIDTH,
1844
1847
  borderRadius: BOX_RADIUS - FOCUS_RING_INSET
1845
1848
  },
1846
- check: {
1847
- fontSize: CHECK_FONT_SIZE,
1848
- fontWeight: "700",
1849
- lineHeight: CHECK_FONT_SIZE
1849
+ tick: {
1850
+ width: TICK_WIDTH,
1851
+ height: TICK_HEIGHT,
1852
+ marginTop: TICK_LIFT,
1853
+ borderRightWidth: TICK_STROKE,
1854
+ borderBottomWidth: TICK_STROKE,
1855
+ transform: [{ rotate: "45deg" }]
1850
1856
  },
1851
1857
  textColumn: {
1852
1858
  flex: 1
@@ -1926,7 +1932,7 @@ var FormCheckbox = ({
1926
1932
  children: [
1927
1933
  /* @__PURE__ */ jsxs(View, { style: [styles15.box, value ? themeStyles.boxOn : themeStyles.boxOff], testID: `${testID}-box`, children: [
1928
1934
  focused ? /* @__PURE__ */ jsx(View, { pointerEvents: "none", style: [styles15.focusRing, themeStyles.ring], testID: `${testID}-focus-ring` }) : null,
1929
- value ? /* @__PURE__ */ jsx(Text, { style: [styles15.check, { color: colors.surface }], accessibilityElementsHidden: true, children: "\u2713" }) : null
1935
+ value ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, pointerEvents: "none", style: [styles15.tick, { borderColor: colors.surface }], testID: `${testID}-tick` }) : null
1930
1936
  ] }),
1931
1937
  /* @__PURE__ */ jsxs(View, { style: styles15.textColumn, children: [
1932
1938
  /* @__PURE__ */ jsx(Text, { style: [styles15.label, themeStyles.label], children: label }),
@@ -2688,8 +2694,86 @@ function monthStart(iso) {
2688
2694
  return `${iso.slice(0, MONTH_PREFIX)}-01`;
2689
2695
  }
2690
2696
 
2691
- // src/DatePicker/utils/weekStart.ts
2697
+ // src/DatePicker/utils/formatDate.ts
2698
+ var SAMPLE_UTC = Date.UTC(2027, 5, 12);
2699
+ var TWO_DIGIT_YEAR = 100;
2700
+ var CENTURY = 2e3;
2701
+ var PART_COUNT = 3;
2702
+ var PAD3 = 2;
2692
2703
  var MONDAY2 = 1;
2704
+ var ISO_LIKE = /^\d{4}-\d{1,2}-\d{1,2}$/;
2705
+ var MONTH_INDEXES = Array.from({ length: 12 }, (_unused, index) => index);
2706
+ var WEEK_OFFSETS = Array.from({ length: 7 }, (_unused, index) => index);
2707
+ var UTC = "UTC";
2708
+ var PART_OF = { day: "day" /* Day */, month: "month" /* Month */, year: "year" /* Year */ };
2709
+ function utcOf(iso) {
2710
+ const parts = parseIso(iso);
2711
+ return parts === null ? null : new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
2712
+ }
2713
+ function formatWith(iso, locale, options) {
2714
+ const date = utcOf(iso);
2715
+ if (date === null) return iso;
2716
+ return new Intl.DateTimeFormat(locale, { ...options, timeZone: UTC }).format(date).replace(/,/g, "");
2717
+ }
2718
+ function formatDisplay(iso, locale) {
2719
+ return formatWith(iso, locale, { weekday: "short", day: "numeric", month: "short", year: "numeric" });
2720
+ }
2721
+ function formatShort(iso, locale, withYear = true) {
2722
+ return formatWith(iso, locale, withYear ? { day: "numeric", month: "short", year: "numeric" } : { day: "numeric", month: "short" });
2723
+ }
2724
+ function formatMonthYear(iso, locale) {
2725
+ return formatWith(iso, locale, { month: "long", year: "numeric" });
2726
+ }
2727
+ function monthNames(locale) {
2728
+ const format = new Intl.DateTimeFormat(locale, { month: "long", timeZone: UTC });
2729
+ return MONTH_INDEXES.map((month) => format.format(new Date(Date.UTC(2024, month, 1))));
2730
+ }
2731
+ function weekdayNames(locale, firstDay = MONDAY2) {
2732
+ const format = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: UTC });
2733
+ return WEEK_OFFSETS.map((offset) => format.format(new Date(Date.UTC(2024, 0, firstDay + offset))));
2734
+ }
2735
+ function typedOrder(locale) {
2736
+ const parts = new Intl.DateTimeFormat(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone: UTC }).formatToParts(new Date(SAMPLE_UTC));
2737
+ return parts.map((part) => PART_OF[part.type]).filter((part) => part !== void 0);
2738
+ }
2739
+ function formatTyped(iso, locale) {
2740
+ const parts = parseIso(iso);
2741
+ if (parts === null) return iso;
2742
+ const text = {
2743
+ ["day" /* Day */]: String(parts.day).padStart(PAD3, "0"),
2744
+ ["month" /* Month */]: String(parts.month).padStart(PAD3, "0"),
2745
+ ["year" /* Year */]: String(parts.year)
2746
+ };
2747
+ return typedOrder(locale).map((part) => text[part]).join("/");
2748
+ }
2749
+ function parseTyped(text, locale) {
2750
+ const trimmed = text.trim();
2751
+ if (ISO_LIKE.test(trimmed)) {
2752
+ const [year = 0, month = 0, day = 0] = trimmed.split("-").map(Number);
2753
+ const parts2 = { year, month, day };
2754
+ return isValidParts(parts2) ? toIso(parts2) : null;
2755
+ }
2756
+ const numbers2 = trimmed.split(/\D+/).filter((piece) => piece !== "").map(Number);
2757
+ if (numbers2.length !== PART_COUNT) return null;
2758
+ const order = typedOrder(locale);
2759
+ const read = (part) => numbers2[order.indexOf(part)] ?? 0;
2760
+ const rawYear = read("year" /* Year */);
2761
+ const parts = { year: rawYear < TWO_DIGIT_YEAR ? CENTURY + rawYear : rawYear, month: read("month" /* Month */), day: read("day" /* Day */) };
2762
+ return isValidParts(parts) ? toIso(parts) : null;
2763
+ }
2764
+
2765
+ // src/DatePicker/utils/DateDisplay.ts
2766
+ var DateDisplay = /* @__PURE__ */ ((DateDisplay2) => {
2767
+ DateDisplay2["Long"] = "long";
2768
+ DateDisplay2["Numeric"] = "numeric";
2769
+ return DateDisplay2;
2770
+ })(DateDisplay || {});
2771
+ function displayFormatter(display) {
2772
+ return display === "numeric" /* Numeric */ ? formatTyped : formatDisplay;
2773
+ }
2774
+
2775
+ // src/DatePicker/utils/weekStart.ts
2776
+ var MONDAY3 = 1;
2693
2777
  var SUNDAY2 = 7;
2694
2778
  var SUNDAY_REGIONS = /* @__PURE__ */ new Set(["US", "CA", "MX", "BR", "JP", "KR", "TW", "HK", "IL", "PH", "IN", "ZA", "SA", "PE", "CO", "VE", "GT", "HN", "PA", "PR", "DO", "SV", "TH", "ID"]);
2695
2779
  function weekFirstDay(locale) {
@@ -2698,20 +2782,20 @@ function weekFirstDay(locale) {
2698
2782
  const info = resolved;
2699
2783
  const first = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay;
2700
2784
  if (first !== void 0) return first;
2701
- return SUNDAY_REGIONS.has(resolved.maximize().region ?? "") ? SUNDAY2 : MONDAY2;
2785
+ return SUNDAY_REGIONS.has(resolved.maximize().region ?? "") ? SUNDAY2 : MONDAY3;
2702
2786
  } catch {
2703
- return MONDAY2;
2787
+ return MONDAY3;
2704
2788
  }
2705
2789
  }
2706
2790
  var DatePickerContext = createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
2707
- function DatePickerProvider({ labels, locale, today, children }) {
2708
- const value = useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today }), [labels, locale, today]);
2791
+ function DatePickerProvider({ labels, locale, today, display, children }) {
2792
+ const value = useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today, display }), [labels, locale, today, display]);
2709
2793
  return /* @__PURE__ */ jsx(DatePickerContext.Provider, { value, children });
2710
2794
  }
2711
2795
  function useDatePickerConfig() {
2712
2796
  const config = useContext(DatePickerContext);
2713
2797
  const firstDay = useMemo(() => weekFirstDay(config.locale), [config.locale]);
2714
- return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay };
2798
+ return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay, display: config.display ?? "long" /* Long */ };
2715
2799
  }
2716
2800
 
2717
2801
  // src/DatePicker/utils/motionStyles.ts
@@ -2756,14 +2840,14 @@ function PickerSurface({ anchorRef, phone, minWidth, label, testID, onDismiss, c
2756
2840
  // src/DatePicker/utils/calendarKeys.ts
2757
2841
  var DAYS_IN_WEEK2 = 7;
2758
2842
  var MONTHS_IN_YEAR2 = 12;
2759
- var MONDAY3 = 1;
2843
+ var MONDAY4 = 1;
2760
2844
  var DAY_STEPS = {
2761
2845
  ArrowLeft: -1,
2762
2846
  ArrowRight: 1,
2763
2847
  ArrowUp: -DAYS_IN_WEEK2,
2764
2848
  ArrowDown: DAYS_IN_WEEK2
2765
2849
  };
2766
- function nextFocusDay(iso, key, shiftKey = false, firstDay = MONDAY3) {
2850
+ function nextFocusDay(iso, key, shiftKey = false, firstDay = MONDAY4) {
2767
2851
  const step = DAY_STEPS[key];
2768
2852
  if (step !== void 0) return addDays(iso, step);
2769
2853
  const monthStep = shiftKey ? MONTHS_IN_YEAR2 : 1;
@@ -2851,74 +2935,6 @@ function DayCell({ iso, state, testID, label, hint, onPick, onKey }) {
2851
2935
  ) });
2852
2936
  }
2853
2937
 
2854
- // src/DatePicker/utils/formatDate.ts
2855
- var SAMPLE_UTC = Date.UTC(2027, 5, 12);
2856
- var TWO_DIGIT_YEAR = 100;
2857
- var CENTURY = 2e3;
2858
- var PART_COUNT = 3;
2859
- var PAD3 = 2;
2860
- var MONDAY4 = 1;
2861
- var ISO_LIKE = /^\d{4}-\d{1,2}-\d{1,2}$/;
2862
- var MONTH_INDEXES = Array.from({ length: 12 }, (_unused, index) => index);
2863
- var WEEK_OFFSETS = Array.from({ length: 7 }, (_unused, index) => index);
2864
- var UTC = "UTC";
2865
- var PART_OF = { day: "day" /* Day */, month: "month" /* Month */, year: "year" /* Year */ };
2866
- function utcOf(iso) {
2867
- const parts = parseIso(iso);
2868
- return parts === null ? null : new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
2869
- }
2870
- function formatWith(iso, locale, options) {
2871
- const date = utcOf(iso);
2872
- if (date === null) return iso;
2873
- return new Intl.DateTimeFormat(locale, { ...options, timeZone: UTC }).format(date).replace(/,/g, "");
2874
- }
2875
- function formatDisplay(iso, locale) {
2876
- return formatWith(iso, locale, { weekday: "short", day: "numeric", month: "short", year: "numeric" });
2877
- }
2878
- function formatShort(iso, locale, withYear = true) {
2879
- return formatWith(iso, locale, withYear ? { day: "numeric", month: "short", year: "numeric" } : { day: "numeric", month: "short" });
2880
- }
2881
- function formatMonthYear(iso, locale) {
2882
- return formatWith(iso, locale, { month: "long", year: "numeric" });
2883
- }
2884
- function monthNames(locale) {
2885
- const format = new Intl.DateTimeFormat(locale, { month: "long", timeZone: UTC });
2886
- return MONTH_INDEXES.map((month) => format.format(new Date(Date.UTC(2024, month, 1))));
2887
- }
2888
- function weekdayNames(locale, firstDay = MONDAY4) {
2889
- const format = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: UTC });
2890
- return WEEK_OFFSETS.map((offset) => format.format(new Date(Date.UTC(2024, 0, firstDay + offset))));
2891
- }
2892
- function typedOrder(locale) {
2893
- const parts = new Intl.DateTimeFormat(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone: UTC }).formatToParts(new Date(SAMPLE_UTC));
2894
- return parts.map((part) => PART_OF[part.type]).filter((part) => part !== void 0);
2895
- }
2896
- function formatTyped(iso, locale) {
2897
- const parts = parseIso(iso);
2898
- if (parts === null) return iso;
2899
- const text = {
2900
- ["day" /* Day */]: String(parts.day).padStart(PAD3, "0"),
2901
- ["month" /* Month */]: String(parts.month).padStart(PAD3, "0"),
2902
- ["year" /* Year */]: String(parts.year)
2903
- };
2904
- return typedOrder(locale).map((part) => text[part]).join("/");
2905
- }
2906
- function parseTyped(text, locale) {
2907
- const trimmed = text.trim();
2908
- if (ISO_LIKE.test(trimmed)) {
2909
- const [year = 0, month = 0, day = 0] = trimmed.split("-").map(Number);
2910
- const parts2 = { year, month, day };
2911
- return isValidParts(parts2) ? toIso(parts2) : null;
2912
- }
2913
- const numbers2 = trimmed.split(/\D+/).filter((piece) => piece !== "").map(Number);
2914
- if (numbers2.length !== PART_COUNT) return null;
2915
- const order = typedOrder(locale);
2916
- const read = (part) => numbers2[order.indexOf(part)] ?? 0;
2917
- const rawYear = read("year" /* Year */);
2918
- const parts = { year: rawYear < TWO_DIGIT_YEAR ? CENTURY + rawYear : rawYear, month: read("month" /* Month */), day: read("day" /* Day */) };
2919
- return isValidParts(parts) ? toIso(parts) : null;
2920
- }
2921
-
2922
2938
  // src/DatePicker/utils/monthGrid.ts
2923
2939
  var DAYS_IN_WEEK3 = 7;
2924
2940
  var MONDAY5 = 1;
@@ -3184,13 +3200,13 @@ var ICON_SLOT = { position: "absolute", right: 2, top: 0, bottom: 0, display: "f
3184
3200
  var anchorStyles = StyleSheet.create({ wrap: { position: "relative", width: "100%" } });
3185
3201
  function DatePickerInput({ fieldProps, context, onTypedError }) {
3186
3202
  const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
3187
- const { labels } = useDatePickerConfig();
3203
+ const { labels, display } = useDatePickerConfig();
3188
3204
  const phone = useIsPhone();
3189
3205
  const [open, setOpen] = useState(false);
3190
3206
  const anchorRef = useRef(null);
3191
3207
  const inputRef = useRef(null);
3192
3208
  const bounds = { min, max };
3193
- const typed = useTypedDate({ value, onChange, bounds, format: formatDisplay, onError: onTypedError, editOnType: true });
3209
+ const typed = useTypedDate({ value, onChange, bounds, format: displayFormatter(display), onError: onTypedError, editOnType: true });
3194
3210
  const edit = typedEditBind(typed);
3195
3211
  const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
3196
3212
  const focus = focusBind;
@@ -5730,6 +5746,6 @@ function DecisionPanel(props) {
5730
5746
  ] });
5731
5747
  }
5732
5748
 
5733
- export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, 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, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, buildSearchSelectSections, canRemoveLine, 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, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateDecision, validateIban };
5749
+ export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, 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, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, SEGMENT_BESIDE_FIELD, SEGMENT_BESIDE_TEXT_INPUT, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, buildSearchSelectSections, canRemoveLine, 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, suggestOptions, toCountryValue, toggleGroupSelection, useAutoGrowRows, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateDecision, validateIban };
5734
5750
  //# sourceMappingURL=index.mjs.map
5735
5751
  //# sourceMappingURL=index.mjs.map