@dloizides/ui-forms 1.42.2 → 1.42.3
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.js +70 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2840,17 +2840,17 @@ var BOLD2 = 700;
|
|
|
2840
2840
|
var ROW = { display: "flex" };
|
|
2841
2841
|
var EMPTY = { width: DAY_CELL_PX, height: DAY_CELL_PX, flexShrink: 0 };
|
|
2842
2842
|
var FALLBACK = { year: 1970, month: 1};
|
|
2843
|
-
function MonthGrid({ month, selection, focusedDay, bounds, testID, onPick, onKey, showCaption = false, motion }) {
|
|
2843
|
+
function MonthGrid({ month, selection: selection2, focusedDay, bounds, testID, onPick, onKey, showCaption = false, motion }) {
|
|
2844
2844
|
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
2845
2845
|
const colors = usePickerColors();
|
|
2846
2846
|
const parts = parseIso(month) ?? FALLBACK;
|
|
2847
2847
|
const weeks = React37.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
2848
2848
|
const weekdays = React37.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
2849
2849
|
const title = formatMonthYear(month, locale);
|
|
2850
|
-
const end =
|
|
2850
|
+
const end = selection2.to === "" ? selection2.from : selection2.to;
|
|
2851
2851
|
const stateOf = (iso) => ({
|
|
2852
|
-
inRange:
|
|
2853
|
-
isEnd: iso ===
|
|
2852
|
+
inRange: selection2.from !== "" && iso >= selection2.from && iso <= end,
|
|
2853
|
+
isEnd: iso === selection2.from || iso === selection2.to,
|
|
2854
2854
|
isToday: iso === today,
|
|
2855
2855
|
enabled: isWithinBounds(iso, bounds.min, bounds.max),
|
|
2856
2856
|
focusable: iso === focusedDay
|
|
@@ -3036,16 +3036,32 @@ function closedFieldMinWidth(text, iconRoom) {
|
|
|
3036
3036
|
|
|
3037
3037
|
// src/DatePicker/utils/typedEdit.ts
|
|
3038
3038
|
var DELETE_KEYS = /* @__PURE__ */ new Set(["Backspace", "Delete"]);
|
|
3039
|
-
function coversAll(input) {
|
|
3040
|
-
const { selectionStart, selectionEnd, value } = input;
|
|
3041
|
-
return value !== "" && selectionStart === 0 && selectionEnd === value.length;
|
|
3042
|
-
}
|
|
3043
3039
|
function isPrintable(event) {
|
|
3044
3040
|
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
|
|
3045
3041
|
}
|
|
3042
|
+
function selection(input) {
|
|
3043
|
+
const end = input.selectionEnd ?? input.value.length;
|
|
3044
|
+
return [input.selectionStart ?? end, end];
|
|
3045
|
+
}
|
|
3046
|
+
function editedText(input, insert) {
|
|
3047
|
+
const [start, end] = selection(input);
|
|
3048
|
+
return { text: input.value.slice(0, start) + insert + input.value.slice(end), caret: start + insert.length };
|
|
3049
|
+
}
|
|
3050
|
+
function placeCaret(input, caret) {
|
|
3051
|
+
requestAnimationFrame(() => input.setSelectionRange(caret, caret));
|
|
3052
|
+
}
|
|
3046
3053
|
function typedEditBind(typed) {
|
|
3047
|
-
const start = (event,
|
|
3048
|
-
|
|
3054
|
+
const start = (event, insert) => {
|
|
3055
|
+
const input = event.currentTarget;
|
|
3056
|
+
const [from, to] = selection(input);
|
|
3057
|
+
if (from === to) {
|
|
3058
|
+
typed.onEdit();
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
const edit = editedText(input, insert);
|
|
3062
|
+
if (!typed.onEdit(edit.text)) return;
|
|
3063
|
+
event.preventDefault();
|
|
3064
|
+
placeCaret(input, edit.caret);
|
|
3049
3065
|
};
|
|
3050
3066
|
return {
|
|
3051
3067
|
onEditKey: (event) => {
|
|
@@ -3054,7 +3070,11 @@ function typedEditBind(typed) {
|
|
|
3054
3070
|
},
|
|
3055
3071
|
onPaste: (event) => start(event, event.clipboardData.getData("text")),
|
|
3056
3072
|
onCut: (event) => {
|
|
3057
|
-
|
|
3073
|
+
const input = event.currentTarget;
|
|
3074
|
+
const [from, to] = selection(input);
|
|
3075
|
+
if (from === to) return;
|
|
3076
|
+
event.clipboardData.setData("text/plain", input.value.slice(from, to));
|
|
3077
|
+
start(event, "");
|
|
3058
3078
|
}
|
|
3059
3079
|
};
|
|
3060
3080
|
}
|
|
@@ -3363,36 +3383,39 @@ function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, tes
|
|
|
3363
3383
|
const ready = [from.isReady(), to.isReady()].every(Boolean);
|
|
3364
3384
|
if (ready) onSubmit();
|
|
3365
3385
|
};
|
|
3366
|
-
const segment = (side, typed) =>
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
onKeyDown(event)
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3386
|
+
const segment = (side, typed) => {
|
|
3387
|
+
const edit = typedEditBind(typed);
|
|
3388
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3389
|
+
"input",
|
|
3390
|
+
{
|
|
3391
|
+
...webA11y,
|
|
3392
|
+
ref: side === "from" /* From */ ? fromRef : void 0,
|
|
3393
|
+
"aria-label": side === "from" /* From */ ? fromLabel : toLabel,
|
|
3394
|
+
autoComplete: "off",
|
|
3395
|
+
"data-testid": `${testID}-${side}`,
|
|
3396
|
+
id: side === "from" /* From */ ? context.controlId : void 0,
|
|
3397
|
+
style: SEGMENT,
|
|
3398
|
+
title: hint,
|
|
3399
|
+
type: "text",
|
|
3400
|
+
value: typed.display,
|
|
3401
|
+
onBlur: (event) => {
|
|
3402
|
+
focus.onBlur?.(event);
|
|
3403
|
+
typed.onBlur();
|
|
3404
|
+
},
|
|
3405
|
+
onChange: (event) => typed.onText(event.target.value),
|
|
3406
|
+
onFocus: (event) => {
|
|
3407
|
+
focus.onFocus?.(event);
|
|
3408
|
+
typed.onFocus();
|
|
3409
|
+
},
|
|
3410
|
+
onCut: edit.onCut,
|
|
3411
|
+
onKeyDown: (event) => {
|
|
3412
|
+
edit.onEditKey(event);
|
|
3413
|
+
onKeyDown(event);
|
|
3414
|
+
},
|
|
3415
|
+
onPaste: edit.onPaste
|
|
3416
|
+
}
|
|
3417
|
+
);
|
|
3418
|
+
};
|
|
3396
3419
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyles.wrap, children: [
|
|
3397
3420
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { ...hoverBind, style: { ...buildNativeInputStyle(style), display: "flex", alignItems: "center", gap: GAP5, paddingInlineEnd: ICON_ROOM }, children: [
|
|
3398
3421
|
segment("from" /* From */, from),
|
|
@@ -4972,15 +4995,15 @@ function rawCaretAfterChange(previous, previousCaret, next) {
|
|
|
4972
4995
|
|
|
4973
4996
|
// src/IbanInput/hooks/useIbanCaret.ts
|
|
4974
4997
|
function useIbanCaret(display) {
|
|
4975
|
-
const [
|
|
4998
|
+
const [selection2, setSelection] = React37.useState({ start: display.length, end: display.length });
|
|
4976
4999
|
const onSelectionChange = React37.useCallback((event) => {
|
|
4977
5000
|
setSelection(event.nativeEvent.selection);
|
|
4978
5001
|
}, []);
|
|
4979
5002
|
const placeAfterEdit = React37.useCallback((text) => {
|
|
4980
|
-
const caret = caretAfterEdit(text, rawCaretAfterChange(display,
|
|
5003
|
+
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection2.end, text));
|
|
4981
5004
|
setSelection({ start: caret, end: caret });
|
|
4982
|
-
}, [display,
|
|
4983
|
-
const clamped = { start: Math.min(
|
|
5005
|
+
}, [display, selection2.end]);
|
|
5006
|
+
const clamped = { start: Math.min(selection2.start, display.length), end: Math.min(selection2.end, display.length) };
|
|
4984
5007
|
return { selection: clamped, onSelectionChange, placeAfterEdit };
|
|
4985
5008
|
}
|
|
4986
5009
|
var FONT_SIZE = 14;
|
|
@@ -5087,7 +5110,7 @@ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibili
|
|
|
5087
5110
|
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
5088
5111
|
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
5089
5112
|
const counter = ibanCounter(draft);
|
|
5090
|
-
const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5113
|
+
const { selection: selection2, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
5091
5114
|
const onChangeText = React37.useCallback((text) => {
|
|
5092
5115
|
onEdit();
|
|
5093
5116
|
onVerdict?.(null);
|
|
@@ -5116,7 +5139,7 @@ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibili
|
|
|
5116
5139
|
autoCorrect: false,
|
|
5117
5140
|
placeholder: draft.display === "" ? placeholder : void 0,
|
|
5118
5141
|
placeholderTextColor: colors.textSecondary,
|
|
5119
|
-
selection,
|
|
5142
|
+
selection: selection2,
|
|
5120
5143
|
spellCheck: false,
|
|
5121
5144
|
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
5122
5145
|
testID,
|