@dloizides/ui-forms 1.35.0 → 1.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/CHANGELOG.md +536 -533
- package/dist/index.d.mts +29 -16
- package/dist/index.d.ts +29 -16
- package/dist/index.js +58 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1196,14 +1196,22 @@ var CHIP_HIT_SLOP = { top: 10, bottom: 10, left: 4, right: 4 };
|
|
|
1196
1196
|
var CHIP_GUTTER = 8;
|
|
1197
1197
|
var DEFAULT_CHIP_TESTID_PREFIX = "chip-selector-chip";
|
|
1198
1198
|
|
|
1199
|
+
// src/ChipSelector/ChipLabelWrap.ts
|
|
1200
|
+
var ChipLabelWrap = /* @__PURE__ */ ((ChipLabelWrap2) => {
|
|
1201
|
+
ChipLabelWrap2["None"] = "none";
|
|
1202
|
+
ChipLabelWrap2["Wrap"] = "wrap";
|
|
1203
|
+
ChipLabelWrap2["Truncate"] = "truncate";
|
|
1204
|
+
return ChipLabelWrap2;
|
|
1205
|
+
})(ChipLabelWrap || {});
|
|
1206
|
+
|
|
1199
1207
|
// src/ChipSelector/utils/chipLabelLayout.ts
|
|
1200
1208
|
var CAPPED_BOX = { maxWidth: "100%", flexShrink: 1 };
|
|
1201
1209
|
var SHRINKING_TEXT = { flexShrink: 1 };
|
|
1202
1210
|
var SINGLE_LINE = 1;
|
|
1203
1211
|
function chipLabelLayout(labelWrap) {
|
|
1204
|
-
if (labelWrap === "wrap")
|
|
1212
|
+
if (labelWrap === "wrap" /* Wrap */)
|
|
1205
1213
|
return { boxStyle: CAPPED_BOX, textStyle: SHRINKING_TEXT, numberOfLines: void 0 };
|
|
1206
|
-
if (labelWrap === "truncate")
|
|
1214
|
+
if (labelWrap === "truncate" /* Truncate */)
|
|
1207
1215
|
return { boxStyle: CAPPED_BOX, textStyle: SHRINKING_TEXT, numberOfLines: SINGLE_LINE };
|
|
1208
1216
|
return { boxStyle: void 0, textStyle: void 0, numberOfLines: void 0 };
|
|
1209
1217
|
}
|
|
@@ -2602,6 +2610,8 @@ var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
|
|
|
2602
2610
|
})(DropdownPlacement || {});
|
|
2603
2611
|
|
|
2604
2612
|
// src/SearchSelect/utils/dropdownFrame.ts
|
|
2613
|
+
var MIN_PANEL_WIDTH = 240;
|
|
2614
|
+
var EDGE = 8;
|
|
2605
2615
|
function placeDropdown(anchor, panelHeight, viewportHeight) {
|
|
2606
2616
|
const roomBelow = viewportHeight - (anchor.y + anchor.height);
|
|
2607
2617
|
if (roomBelow >= panelHeight) return "below" /* Below */;
|
|
@@ -2613,12 +2623,17 @@ function dropdownFrame(anchor, panelHeight, viewportHeight) {
|
|
|
2613
2623
|
if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - anchor.y };
|
|
2614
2624
|
return { ...base, top: anchor.y + anchor.height };
|
|
2615
2625
|
}
|
|
2626
|
+
function fitDropdownWidth(frame, viewportWidth) {
|
|
2627
|
+
const width = Math.max(frame.width, Math.min(MIN_PANEL_WIDTH, viewportWidth - EDGE - EDGE));
|
|
2628
|
+
const left = Math.max(EDGE, Math.min(frame.left, viewportWidth - width - EDGE));
|
|
2629
|
+
return { ...frame, width, left: frame.width >= width ? frame.left : left };
|
|
2630
|
+
}
|
|
2616
2631
|
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2617
|
-
const { height: viewportHeight } = useWindowDimensions();
|
|
2632
|
+
const { height: viewportHeight, width: viewportWidth } = useWindowDimensions();
|
|
2618
2633
|
const anchor = useAnchorRect2(anchorRef);
|
|
2619
2634
|
const [panelHeight, setPanelHeight] = useState(0);
|
|
2620
2635
|
const onLayout = useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2621
|
-
const frame = anchor === null ? null : dropdownFrame(anchor, panelHeight, viewportHeight);
|
|
2636
|
+
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight), viewportWidth);
|
|
2622
2637
|
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2623
2638
|
return /* @__PURE__ */ jsxs(Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: [
|
|
2624
2639
|
/* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
@@ -2847,9 +2862,10 @@ function resolveSelectMotion(width, reducedMotion) {
|
|
|
2847
2862
|
}
|
|
2848
2863
|
var CHEVRON = "\u25BE";
|
|
2849
2864
|
var VALUE_GAP = 8;
|
|
2865
|
+
var MIN_TOUCH = 44;
|
|
2850
2866
|
var NOTHING_ON_CLOSE = () => void 0;
|
|
2851
2867
|
function SearchSelect(props) {
|
|
2852
|
-
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail } = props;
|
|
2868
|
+
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger } = props;
|
|
2853
2869
|
const { theme } = useUi();
|
|
2854
2870
|
const { colors } = theme;
|
|
2855
2871
|
const triggerRef = useRef(null);
|
|
@@ -2860,8 +2876,9 @@ function SearchSelect(props) {
|
|
|
2860
2876
|
const state = useSearchSelectState(options, recents, onChange, NOTHING_ON_CLOSE);
|
|
2861
2877
|
useRefocusOnClose(state.open, triggerRef);
|
|
2862
2878
|
const selected = findOption(options, value);
|
|
2879
|
+
const onPress = state.open ? state.close : state.openList;
|
|
2863
2880
|
return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: styles23.anchor, children: [
|
|
2864
|
-
/* @__PURE__ */
|
|
2881
|
+
/* @__PURE__ */ jsx(
|
|
2865
2882
|
Pressable,
|
|
2866
2883
|
{
|
|
2867
2884
|
ref: triggerRef,
|
|
@@ -2869,22 +2886,25 @@ function SearchSelect(props) {
|
|
|
2869
2886
|
accessibilityLabel,
|
|
2870
2887
|
accessibilityRole: "button",
|
|
2871
2888
|
accessibilityState: { expanded: state.open },
|
|
2872
|
-
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2889
|
+
style: renderTrigger === void 0 ? [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }] : styles23.customTrigger,
|
|
2873
2890
|
testID,
|
|
2874
|
-
onPress
|
|
2875
|
-
children:
|
|
2876
|
-
/* @__PURE__ */ jsxs(View, { style: styles23.value, children: [
|
|
2877
|
-
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
2878
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? labels.placeholder }),
|
|
2879
|
-
selected !== null ? /* @__PURE__ */ jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
2880
|
-
] }),
|
|
2881
|
-
/* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: CHEVRON })
|
|
2882
|
-
]
|
|
2891
|
+
onPress,
|
|
2892
|
+
children: renderTrigger !== void 0 ? renderTrigger({ open: state.open, selected, onPress, ref: triggerRef }) : /* @__PURE__ */ jsx(FieldBoxContent, { colors, placeholder: labels.placeholder, renderDetail, renderLeading, selected })
|
|
2883
2893
|
}
|
|
2884
2894
|
),
|
|
2885
2895
|
state.open ? /* @__PURE__ */ jsx(SearchSelectPanel, { anchorRef, labels, motion, renderDetail, renderLeading, selectedValue: value, state, testID }) : null
|
|
2886
2896
|
] });
|
|
2887
2897
|
}
|
|
2898
|
+
function FieldBoxContent({ selected, placeholder, colors, renderLeading, renderDetail }) {
|
|
2899
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2900
|
+
/* @__PURE__ */ jsxs(View, { style: styles23.value, children: [
|
|
2901
|
+
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
2902
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? placeholder }),
|
|
2903
|
+
selected !== null ? /* @__PURE__ */ jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
2904
|
+
] }),
|
|
2905
|
+
/* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: CHEVRON })
|
|
2906
|
+
] });
|
|
2907
|
+
}
|
|
2888
2908
|
function SelectedDetail({ option, colors, renderDetail }) {
|
|
2889
2909
|
if (renderDetail !== void 0) return /* @__PURE__ */ jsx(Fragment, { children: renderDetail(option) });
|
|
2890
2910
|
if (option.detail === void 0) return null;
|
|
@@ -2892,6 +2912,7 @@ function SelectedDetail({ option, colors, renderDetail }) {
|
|
|
2892
2912
|
}
|
|
2893
2913
|
var styles23 = StyleSheet.create({
|
|
2894
2914
|
anchor: { position: "relative" },
|
|
2915
|
+
customTrigger: { minHeight: MIN_TOUCH, minWidth: MIN_TOUCH, alignSelf: "flex-start", justifyContent: "center" },
|
|
2895
2916
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
2896
2917
|
});
|
|
2897
2918
|
function isContainer(node) {
|
|
@@ -3644,6 +3665,12 @@ var KNOWN_CODES = new Set(COUNTRIES.map((country) => country.code));
|
|
|
3644
3665
|
function countryOptions(list = COUNTRIES) {
|
|
3645
3666
|
return list.map((country) => ({ label: country.name, value: country.code, detail: country.code }));
|
|
3646
3667
|
}
|
|
3668
|
+
var DEFAULT_OPTIONS = countryOptions();
|
|
3669
|
+
var NO_COUNTRY = "";
|
|
3670
|
+
function countryFieldOptions(countries, noneLabel) {
|
|
3671
|
+
const list = countries === void 0 ? DEFAULT_OPTIONS : countryOptions(countries);
|
|
3672
|
+
return noneLabel === void 0 ? list : [{ label: noneLabel, value: NO_COUNTRY }, ...list];
|
|
3673
|
+
}
|
|
3647
3674
|
function countryFlag(code) {
|
|
3648
3675
|
const upper = code.toUpperCase();
|
|
3649
3676
|
if (!TWO_LETTERS.test(upper)) return "";
|
|
@@ -3654,12 +3681,12 @@ function toCountryValue(input) {
|
|
|
3654
3681
|
return KNOWN_CODES.has(upper) ? upper : "";
|
|
3655
3682
|
}
|
|
3656
3683
|
var CODE_FONT = 12;
|
|
3657
|
-
var
|
|
3658
|
-
var renderFlag = (option) => /* @__PURE__ */ jsx(CountryFlag, { code: option.value });
|
|
3659
|
-
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries }) {
|
|
3684
|
+
var NO_COUNTRY2 = "";
|
|
3685
|
+
var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__ */ jsx(CountryFlag, { code: option.value });
|
|
3686
|
+
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel }) {
|
|
3660
3687
|
const { theme } = useUi();
|
|
3661
3688
|
const { textSecondary } = theme.colors;
|
|
3662
|
-
const options = useMemo(() => countries
|
|
3689
|
+
const options = useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
|
|
3663
3690
|
const renderCode = useCallback((option) => /* @__PURE__ */ jsx(Text, { style: [styles24.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
3664
3691
|
return /* @__PURE__ */ jsx(
|
|
3665
3692
|
SearchSelect,
|
|
@@ -3942,7 +3969,7 @@ function rejectionMessage(rejection, none, labels) {
|
|
|
3942
3969
|
if (labels === void 0 || rejection === null || rejection === none) return null;
|
|
3943
3970
|
return labels[rejection];
|
|
3944
3971
|
}
|
|
3945
|
-
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder }) {
|
|
3972
|
+
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
3946
3973
|
const { theme } = useUi();
|
|
3947
3974
|
const { colors } = theme;
|
|
3948
3975
|
const draft = useMemo(() => draftIban(value), [value]);
|
|
@@ -3960,7 +3987,8 @@ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibili
|
|
|
3960
3987
|
const onBlur = useCallback(() => {
|
|
3961
3988
|
const verdict2 = onLeave();
|
|
3962
3989
|
onVerdict?.(value === "" ? null : verdict2);
|
|
3963
|
-
|
|
3990
|
+
onLeft?.();
|
|
3991
|
+
}, [onLeave, onVerdict, value, onLeft]);
|
|
3964
3992
|
return /* @__PURE__ */ jsxs(View, { children: [
|
|
3965
3993
|
/* @__PURE__ */ jsxs(View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: [
|
|
3966
3994
|
/* @__PURE__ */ jsxs(View, { style: ghostStyles.field, children: [
|
|
@@ -4028,7 +4056,7 @@ function validateBic(raw) {
|
|
|
4028
4056
|
if (RESERVED_LOCATION.includes(bic.charAt(LOCATION_INDEX))) return refused2("MalformedLocation" /* MalformedLocation */);
|
|
4029
4057
|
return { rejection: "None" /* None */, electronic: bic };
|
|
4030
4058
|
}
|
|
4031
|
-
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }) {
|
|
4059
|
+
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
|
|
4032
4060
|
const { theme } = useUi();
|
|
4033
4061
|
const { colors } = theme;
|
|
4034
4062
|
const draft = useMemo(() => draftBic(value), [value]);
|
|
@@ -4043,7 +4071,8 @@ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilit
|
|
|
4043
4071
|
const onBlur = useCallback(() => {
|
|
4044
4072
|
const verdict2 = onLeave();
|
|
4045
4073
|
onVerdict?.(value === "" ? null : verdict2);
|
|
4046
|
-
|
|
4074
|
+
onLeft?.();
|
|
4075
|
+
}, [onLeave, onVerdict, value, onLeft]);
|
|
4047
4076
|
return /* @__PURE__ */ jsxs(View, { children: [
|
|
4048
4077
|
/* @__PURE__ */ jsx(View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: /* @__PURE__ */ jsxs(View, { style: ghostStyles.field, children: [
|
|
4049
4078
|
/* @__PURE__ */ jsxs(Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
|
|
@@ -4059,6 +4088,8 @@ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilit
|
|
|
4059
4088
|
autoCapitalize: "characters",
|
|
4060
4089
|
autoComplete: "off",
|
|
4061
4090
|
autoCorrect: false,
|
|
4091
|
+
placeholder: draft.value === "" ? placeholder : void 0,
|
|
4092
|
+
placeholderTextColor: colors.textSecondary,
|
|
4062
4093
|
spellCheck: false,
|
|
4063
4094
|
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
4064
4095
|
testID,
|
|
@@ -4072,6 +4103,6 @@ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilit
|
|
|
4072
4103
|
] });
|
|
4073
4104
|
}
|
|
4074
4105
|
|
|
4075
|
-
export { AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipSelector, CountryField, CountryFlag, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DateRangeControl, DateTimeField, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, ResponsiveFormLayout, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, buildSearchSelectSections,
|
|
4106
|
+
export { AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DateRangeControl, DateTimeField, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, ResponsiveFormLayout, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, buildSearchSelectSections, controlStyles, countryFieldOptions, countryFlag, countryOptions, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isFallbackFlag, isFixBarVisible, isOutside, isUnmatched, isWideFormLayout, moveHighlight, nextHighlight, placeDropdown, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateIban };
|
|
4076
4107
|
//# sourceMappingURL=index.mjs.map
|
|
4077
4108
|
//# sourceMappingURL=index.mjs.map
|