@jobber/components 9.3.0 → 9.5.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/Autocomplete/index.cjs +0 -1
- package/dist/Autocomplete/index.mjs +0 -1
- package/dist/Card/index.cjs +7 -7
- package/dist/Card/index.mjs +7 -7
- package/dist/Chip/index.cjs +0 -1
- package/dist/Chip/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.mjs +0 -1
- package/dist/Chips/index.cjs +0 -1
- package/dist/Chips/index.mjs +0 -1
- package/dist/ComboboxChipRemove-cjs.js +181 -184
- package/dist/ComboboxChipRemove-es.js +4 -7
- package/dist/ConfirmationModal/index.cjs +0 -1
- package/dist/ConfirmationModal/index.mjs +0 -1
- package/dist/DataDump/DataDump.d.ts +1 -1
- package/dist/DataDump/DataDump.messages.d.ts +6 -0
- package/dist/DataDump/index.cjs +9 -9
- package/dist/DataDump/index.mjs +9 -9
- package/dist/DataDump-cjs.js +11 -1
- package/dist/DataDump-es.js +11 -1
- package/dist/DataList/components/DataListActions/index.cjs +0 -1
- package/dist/DataList/components/DataListActions/index.mjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.cjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/index.mjs +0 -1
- package/dist/DataList/components/DataListHeader/index.cjs +0 -1
- package/dist/DataList/components/DataListHeader/index.mjs +0 -1
- package/dist/DataList/components/DataListItem/index.cjs +0 -1
- package/dist/DataList/components/DataListItem/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +0 -1
- package/dist/DataList/components/DataListItems/index.cjs +0 -1
- package/dist/DataList/components/DataListItems/index.mjs +0 -1
- package/dist/DataList/components/DataListLayout/index.cjs +0 -1
- package/dist/DataList/components/DataListLayout/index.mjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.cjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.mjs +0 -1
- package/dist/DataList/index.cjs +0 -1
- package/dist/DataList/index.mjs +0 -1
- package/dist/DataTable/DataTable.messages.d.ts +22 -0
- package/dist/DataTable/index.cjs +2 -2
- package/dist/DataTable/index.mjs +2 -2
- package/dist/DataTable-cjs.js +34 -5
- package/dist/DataTable-es.js +34 -5
- package/dist/DatePicker/index.cjs +0 -2
- package/dist/DatePicker/index.mjs +0 -2
- package/dist/DatePicker-cjs.js +19 -18
- package/dist/DatePicker-es.js +2 -1
- package/dist/Dialog/index.cjs +11 -6
- package/dist/Dialog/index.mjs +11 -6
- package/dist/DrawerDescription-cjs.js +7 -8
- package/dist/DrawerDescription-es.js +1 -2
- package/dist/DrawerTitle-cjs.js +4 -4
- package/dist/DrawerTitle-es.js +1 -1
- package/dist/FeatureSwitch/FeatureSwitch.messages.d.ts +10 -0
- package/dist/FeatureSwitch/index.cjs +2 -0
- package/dist/FeatureSwitch/index.mjs +2 -0
- package/dist/FeatureSwitch-cjs.js +15 -2
- package/dist/FeatureSwitch-es.js +15 -2
- package/dist/FieldDescription-cjs.js +49 -49
- package/dist/FieldDescription-es.js +2 -2
- package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +0 -1
- package/dist/FilterPicker/index.cjs +0 -1
- package/dist/FilterPicker/index.mjs +0 -1
- package/dist/FormatFile/FormatFile.messages.d.ts +18 -0
- package/dist/FormatFile/index.cjs +2 -3
- package/dist/FormatFile/index.mjs +2 -3
- package/dist/FormatFile-cjs.js +24 -2
- package/dist/FormatFile-es.js +24 -2
- package/dist/Gallery/index.cjs +0 -1
- package/dist/Gallery/index.mjs +0 -1
- package/dist/HelperText-cjs.js +3 -2
- package/dist/HelperText-es.js +3 -2
- package/dist/InputDate/index.cjs +0 -2
- package/dist/InputDate/index.mjs +0 -2
- package/dist/InputNumber/InputNumber.d.ts +75 -5
- package/dist/InputNumber/index.cjs +27 -3
- package/dist/InputNumber/index.d.ts +2 -2
- package/dist/InputNumber/index.mjs +27 -3
- package/dist/{primitives/InputNumberExperimental → InputNumber}/types.d.ts +48 -35
- package/dist/InputNumber-cjs.js +267 -4986
- package/dist/InputNumber-es.js +268 -4987
- package/dist/LightBox/index.cjs +0 -1
- package/dist/LightBox/index.mjs +0 -1
- package/dist/Menu/index.cjs +7 -7
- package/dist/Menu/index.mjs +7 -7
- package/dist/Menu-cjs.js +5 -1
- package/dist/Menu-es.js +5 -2
- package/dist/MenuSubmenuTrigger-cjs.js +142 -143
- package/dist/MenuSubmenuTrigger-es.js +5 -6
- package/dist/Modal/index.cjs +0 -1
- package/dist/Modal/index.mjs +0 -1
- package/dist/NumberFieldInput-cjs.js +63 -63
- package/dist/NumberFieldInput-es.js +5 -5
- package/dist/Page/index.cjs +18 -19
- package/dist/Page/index.mjs +18 -19
- package/dist/Page-cjs.js +6 -3
- package/dist/Page-es.js +6 -3
- package/dist/Popover/index.cjs +0 -1
- package/dist/Popover/index.mjs +0 -1
- package/dist/ProgressBar/ProgressBar.messages.d.ts +6 -0
- package/dist/ProgressBar/index.cjs +2 -0
- package/dist/ProgressBar/index.mjs +2 -0
- package/dist/ProgressBar-cjs.js +13 -1
- package/dist/ProgressBar-es.js +13 -1
- package/dist/ScrollAreaViewport-cjs.js +119 -121
- package/dist/ScrollAreaViewport-es.js +3 -5
- package/dist/Select/index.cjs +3 -9
- package/dist/Select/index.mjs +3 -9
- package/dist/SelectGroupLabel-cjs.js +117 -107
- package/dist/SelectGroupLabel-es.js +20 -12
- package/dist/Toast/Toast.messages.d.ts +6 -0
- package/dist/Toast/index.cjs +3 -1
- package/dist/Toast/index.mjs +3 -1
- package/dist/Toast/showToast.d.ts +12 -1
- package/dist/Tooltip/index.cjs +0 -1
- package/dist/Tooltip/index.mjs +0 -1
- package/dist/dialogReturnFocus-cjs.js +4 -1
- package/dist/dialogReturnFocus-es.js +4 -1
- package/dist/docs/DataDump/DataDump.md +1 -1
- package/dist/docs/InputNumber/InputNumber.md +564 -56
- package/dist/docs/Page/Page.md +1 -1
- package/dist/docs/index.md +0 -1
- package/dist/floating-ui.react-cjs.js +34 -35
- package/dist/floating-ui.react-dom-cjs.js +64 -65
- package/dist/floating-ui.react-dom-es.js +1 -2
- package/dist/floating-ui.react-es.js +1 -2
- package/dist/floating-ui.utils-cjs.js +183 -0
- package/dist/floating-ui.utils-es.js +165 -1
- package/dist/index.cjs +10 -15
- package/dist/index.mjs +10 -15
- package/dist/primitives/BottomSheet/index.cjs +2 -5
- package/dist/primitives/BottomSheet/index.mjs +2 -5
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -7
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -7
- package/dist/primitives/HelperText/HelperText.d.ts +4 -1
- package/dist/primitives/HelperText/index.cjs +1 -1
- package/dist/primitives/HelperText/index.mjs +1 -1
- package/dist/primitives/SelectPrimitive/index.cjs +3 -9
- package/dist/primitives/SelectPrimitive/index.mjs +3 -9
- package/dist/primitives/index.cjs +2 -16
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.mjs +2 -15
- package/dist/scrollEdges-cjs.js +6 -2
- package/dist/scrollEdges-es.js +5 -2
- package/dist/sharedHelpers/i18n/renderWithLocale.d.ts +11 -0
- package/dist/showToast-cjs.js +20 -6
- package/dist/showToast-es.js +20 -6
- package/dist/styles.css +573 -902
- package/dist/unstyledPrimitives/index.cjs +105 -111
- package/dist/unstyledPrimitives/index.mjs +5 -11
- package/dist/useCompositeListItem-cjs.js +516 -90
- package/dist/useCompositeListItem-es.js +407 -6
- package/dist/useLabel-cjs.js +10 -10
- package/dist/useLabel-es.js +3 -3
- package/dist/useRenderElement-es.js +1 -1
- package/dist/useScrollLock-cjs.js +1332 -203
- package/dist/useScrollLock-es.js +1068 -5
- package/dist/utils/meta/meta.json +12 -0
- package/package.json +2 -3
- package/dist/InputNumber/InputNumber.types.d.ts +0 -20
- package/dist/InputNumberExperimental-cjs.js +0 -277
- package/dist/InputNumberExperimental-es.js +0 -275
- package/dist/clamp-cjs.js +0 -7
- package/dist/clamp-es.js +0 -5
- package/dist/clsx-cjs.js +0 -5
- package/dist/clsx-es.js +0 -3
- package/dist/docs/InputNumberExperimental/InputNumberExperimental.md +0 -578
- package/dist/floating-ui.utils.dom-cjs.js +0 -185
- package/dist/floating-ui.utils.dom-es.js +0 -165
- package/dist/isElementDisabled-cjs.js +0 -40
- package/dist/isElementDisabled-es.js +0 -18
- package/dist/primitives/InputNumberExperimental/InputNumberExperimental.d.ts +0 -77
- package/dist/primitives/InputNumberExperimental/index.cjs +0 -30
- package/dist/primitives/InputNumberExperimental/index.d.ts +0 -2
- package/dist/primitives/InputNumberExperimental/index.mjs +0 -24
- package/dist/resolveAriaLabelledBy-cjs.js +0 -200
- package/dist/resolveAriaLabelledBy-es.js +0 -166
- package/dist/useButton-cjs.js +0 -1164
- package/dist/useButton-es.js +0 -1071
- package/dist/useLabelableId-cjs.js +0 -278
- package/dist/useLabelableId-es.js +0 -247
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { b as isElement, i as isHTMLElement,
|
|
4
|
-
import {
|
|
5
|
-
import { a as useRefWithInit, b as EMPTY_ARRAY, E as EMPTY_OBJECT, u as useRenderElement } from './useRenderElement-es.js';
|
|
2
|
+
import { aa as useId, ab as useFloatingParentNodeId, ac as FloatingRootStore, ad as PopupTriggerMap, a as useIsoLayoutEffect, ae as useFloatingTree, Z as getFloatingFocusElement, af as isTypeableCombobox, q as useValueAsRef, b as useStableCallback, a5 as useAnimationFrame, ag as isIndexOutOfListBounds, ah as getMinListIndex, ai as getMaxListIndex, D as activeElement, o as ownerDocument, _ as contains, L as stopEvent, d as createChangeEventDetails, aj as listNavigation, ak as findNonDisabledListIndex, g as getTarget, W as focusOut, al as enqueueFocus, a8 as isVirtualClick, am as isVirtualPointerEvent, an as ARROW_UP, ao as ARROW_DOWN, ap as ARROW_LEFT, aq as ARROW_RIGHT, k as useTimeout, ar as isListIndexDisabled, as as isElementVisible, u as useBaseUiId, at as jsdom, a4 as useDirection, au as DISABLED_TRANSITIONS_STYLE, p as popupStateMapping, av as useScrollLock } from './useScrollLock-es.js';
|
|
3
|
+
import { b as isElement, i as isHTMLElement, K as getWindow, p as evaluate, q as getPaddingObject, m as getAlignmentAxis, o as getAlignment, z as getAxisLength, w as clamp, n as getSide, l as getSideAxis } from './floating-ui.utils-es.js';
|
|
4
|
+
import { a as useRefWithInit, c as EMPTY_ARRAY, N as NOOP, E as EMPTY_OBJECT, f as formatErrorMessage, u as useRenderElement } from './useRenderElement-es.js';
|
|
6
5
|
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
import { e as evaluate, d as getPaddingObject, a as getAlignmentAxis, c as getAlignment, o as getAxisLength, l as clamp, b as getSide, g as getSideAxis } from './floating-ui.utils-es.js';
|
|
8
6
|
import { u as useFloating$1, h as hide$1, f as flip, d as size, b as autoUpdate, o as offset, s as shift, l as limitShift } from './floating-ui.react-dom-es.js';
|
|
9
7
|
|
|
10
8
|
function useFloatingRootContext(options) {
|
|
@@ -894,6 +892,402 @@ function useTypeahead(context, props) {
|
|
|
894
892
|
} : {}, [enabled, sharedProps]);
|
|
895
893
|
}
|
|
896
894
|
|
|
895
|
+
const defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
|
|
896
|
+
function compareItemEquality(itemValue, selectedValue, comparer) {
|
|
897
|
+
if (itemValue == null || selectedValue == null) {
|
|
898
|
+
return Object.is(itemValue, selectedValue);
|
|
899
|
+
}
|
|
900
|
+
return comparer(itemValue, selectedValue);
|
|
901
|
+
}
|
|
902
|
+
function selectedValueIncludes(selectedValues, itemValue, comparer) {
|
|
903
|
+
if (!selectedValues || selectedValues.length === 0) {
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
return selectedValues.some(selectedValue => {
|
|
907
|
+
if (selectedValue === undefined) {
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
function findItemIndex(itemValues, selectedValue, comparer) {
|
|
914
|
+
if (!itemValues || itemValues.length === 0) {
|
|
915
|
+
return -1;
|
|
916
|
+
}
|
|
917
|
+
return itemValues.findIndex(itemValue => {
|
|
918
|
+
if (itemValue === undefined) {
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
function removeItem(selectedValues, itemValue, comparer) {
|
|
925
|
+
return selectedValues.filter(selectedValue => !compareItemEquality(itemValue, selectedValue, comparer));
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function serializeValue(value) {
|
|
929
|
+
if (value == null) {
|
|
930
|
+
return '';
|
|
931
|
+
}
|
|
932
|
+
if (typeof value === 'string') {
|
|
933
|
+
return value;
|
|
934
|
+
}
|
|
935
|
+
try {
|
|
936
|
+
return JSON.stringify(value);
|
|
937
|
+
} catch {
|
|
938
|
+
return String(value);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function isGroupedItems(items) {
|
|
943
|
+
return items != null && items.length > 0 && typeof items[0] === 'object' && items[0] != null && 'items' in items[0];
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Checks if the items array contains an item with a null value that has a non-null label.
|
|
948
|
+
*/
|
|
949
|
+
function hasNullItemLabel(items) {
|
|
950
|
+
if (!Array.isArray(items)) {
|
|
951
|
+
return items != null && 'null' in items;
|
|
952
|
+
}
|
|
953
|
+
const arrayItems = items;
|
|
954
|
+
if (isGroupedItems(arrayItems)) {
|
|
955
|
+
for (const group of arrayItems) {
|
|
956
|
+
for (const item of group.items) {
|
|
957
|
+
if (item && item.value == null && item.label != null) {
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return false;
|
|
963
|
+
}
|
|
964
|
+
for (const item of arrayItems) {
|
|
965
|
+
if (item && item.value == null && item.label != null) {
|
|
966
|
+
return true;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
function stringifyAsLabel(item, itemToStringLabel) {
|
|
972
|
+
if (itemToStringLabel && item != null) {
|
|
973
|
+
return itemToStringLabel(item) ?? '';
|
|
974
|
+
}
|
|
975
|
+
if (item && typeof item === 'object') {
|
|
976
|
+
if ('label' in item && item.label != null) {
|
|
977
|
+
return String(item.label);
|
|
978
|
+
}
|
|
979
|
+
if ('value' in item) {
|
|
980
|
+
return String(item.value);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return serializeValue(item);
|
|
984
|
+
}
|
|
985
|
+
function stringifyAsValue(item, itemToStringValue) {
|
|
986
|
+
if (itemToStringValue && item != null) {
|
|
987
|
+
return itemToStringValue(item) ?? '';
|
|
988
|
+
}
|
|
989
|
+
if (item && typeof item === 'object' && 'value' in item && 'label' in item) {
|
|
990
|
+
return serializeValue(item.value);
|
|
991
|
+
}
|
|
992
|
+
return serializeValue(item);
|
|
993
|
+
}
|
|
994
|
+
function resolveSelectedLabel(value, items, itemToStringLabel) {
|
|
995
|
+
function fallback() {
|
|
996
|
+
return stringifyAsLabel(value, itemToStringLabel);
|
|
997
|
+
}
|
|
998
|
+
if (itemToStringLabel && value != null) {
|
|
999
|
+
return itemToStringLabel(value);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// Custom object with explicit label takes precedence
|
|
1003
|
+
if (value && typeof value === 'object' && 'label' in value && value.label != null) {
|
|
1004
|
+
return value.label;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// Items provided as plain record map
|
|
1008
|
+
if (items && !Array.isArray(items)) {
|
|
1009
|
+
return items[value] ?? fallback();
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// Items provided as array (flat or grouped)
|
|
1013
|
+
if (Array.isArray(items)) {
|
|
1014
|
+
const arrayItems = items;
|
|
1015
|
+
const flatItems = isGroupedItems(arrayItems) ? arrayItems.flatMap(group => group.items) : arrayItems;
|
|
1016
|
+
if (value == null || typeof value !== 'object') {
|
|
1017
|
+
const match = flatItems.find(item => item.value === value);
|
|
1018
|
+
if (match && match.label != null) {
|
|
1019
|
+
return match.label;
|
|
1020
|
+
}
|
|
1021
|
+
return fallback();
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// Object without explicit label: try matching by its `value` property
|
|
1025
|
+
if ('value' in value) {
|
|
1026
|
+
const match = flatItems.find(item => item && item.value === value.value);
|
|
1027
|
+
if (match && match.label != null) {
|
|
1028
|
+
return match.label;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
return fallback();
|
|
1033
|
+
}
|
|
1034
|
+
function resolveMultipleLabels(values, items, itemToStringLabel) {
|
|
1035
|
+
return values.reduce((acc, value, index) => {
|
|
1036
|
+
if (index > 0) {
|
|
1037
|
+
acc.push(', ');
|
|
1038
|
+
}
|
|
1039
|
+
acc.push(/*#__PURE__*/jsx(React.Fragment, {
|
|
1040
|
+
children: resolveSelectedLabel(value, items, itemToStringLabel)
|
|
1041
|
+
}, index));
|
|
1042
|
+
return acc;
|
|
1043
|
+
}, []);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
let FieldControlDataAttributes = /*#__PURE__*/function (FieldControlDataAttributes) {
|
|
1047
|
+
/**
|
|
1048
|
+
* Present when the field is disabled.
|
|
1049
|
+
*/
|
|
1050
|
+
FieldControlDataAttributes["disabled"] = "data-disabled";
|
|
1051
|
+
/**
|
|
1052
|
+
* Present when the field is in a valid state.
|
|
1053
|
+
*/
|
|
1054
|
+
FieldControlDataAttributes["valid"] = "data-valid";
|
|
1055
|
+
/**
|
|
1056
|
+
* Present when the field is in an invalid state.
|
|
1057
|
+
*/
|
|
1058
|
+
FieldControlDataAttributes["invalid"] = "data-invalid";
|
|
1059
|
+
/**
|
|
1060
|
+
* Present when the field has been touched.
|
|
1061
|
+
*/
|
|
1062
|
+
FieldControlDataAttributes["touched"] = "data-touched";
|
|
1063
|
+
/**
|
|
1064
|
+
* Present when the field's value has changed.
|
|
1065
|
+
*/
|
|
1066
|
+
FieldControlDataAttributes["dirty"] = "data-dirty";
|
|
1067
|
+
/**
|
|
1068
|
+
* Present when the field is filled.
|
|
1069
|
+
*/
|
|
1070
|
+
FieldControlDataAttributes["filled"] = "data-filled";
|
|
1071
|
+
/**
|
|
1072
|
+
* Present when the field control is focused.
|
|
1073
|
+
*/
|
|
1074
|
+
FieldControlDataAttributes["focused"] = "data-focused";
|
|
1075
|
+
return FieldControlDataAttributes;
|
|
1076
|
+
}({});
|
|
1077
|
+
|
|
1078
|
+
const DEFAULT_VALIDITY_STATE = {
|
|
1079
|
+
badInput: false,
|
|
1080
|
+
customError: false,
|
|
1081
|
+
patternMismatch: false,
|
|
1082
|
+
rangeOverflow: false,
|
|
1083
|
+
rangeUnderflow: false,
|
|
1084
|
+
stepMismatch: false,
|
|
1085
|
+
tooLong: false,
|
|
1086
|
+
tooShort: false,
|
|
1087
|
+
typeMismatch: false,
|
|
1088
|
+
valid: null,
|
|
1089
|
+
valueMissing: false
|
|
1090
|
+
};
|
|
1091
|
+
const DEFAULT_FIELD_STATE_ATTRIBUTES = {
|
|
1092
|
+
valid: null,
|
|
1093
|
+
touched: false,
|
|
1094
|
+
dirty: false,
|
|
1095
|
+
filled: false,
|
|
1096
|
+
focused: false
|
|
1097
|
+
};
|
|
1098
|
+
const DEFAULT_FIELD_ROOT_STATE = {
|
|
1099
|
+
disabled: false,
|
|
1100
|
+
...DEFAULT_FIELD_STATE_ATTRIBUTES
|
|
1101
|
+
};
|
|
1102
|
+
const fieldValidityMapping = {
|
|
1103
|
+
valid(value) {
|
|
1104
|
+
if (value === null) {
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
if (value) {
|
|
1108
|
+
return {
|
|
1109
|
+
[FieldControlDataAttributes.valid]: ''
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
return {
|
|
1113
|
+
[FieldControlDataAttributes.invalid]: ''
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const DEFAULT_FIELD_ROOT_CONTEXT = {
|
|
1119
|
+
invalid: undefined,
|
|
1120
|
+
name: undefined,
|
|
1121
|
+
validityData: {
|
|
1122
|
+
state: DEFAULT_VALIDITY_STATE,
|
|
1123
|
+
errors: [],
|
|
1124
|
+
error: '',
|
|
1125
|
+
value: '',
|
|
1126
|
+
initialValue: null
|
|
1127
|
+
},
|
|
1128
|
+
setValidityData: NOOP,
|
|
1129
|
+
disabled: undefined,
|
|
1130
|
+
touched: DEFAULT_FIELD_STATE_ATTRIBUTES.touched,
|
|
1131
|
+
setTouched: NOOP,
|
|
1132
|
+
dirty: DEFAULT_FIELD_STATE_ATTRIBUTES.dirty,
|
|
1133
|
+
setDirty: NOOP,
|
|
1134
|
+
filled: DEFAULT_FIELD_STATE_ATTRIBUTES.filled,
|
|
1135
|
+
setFilled: NOOP,
|
|
1136
|
+
focused: DEFAULT_FIELD_STATE_ATTRIBUTES.focused,
|
|
1137
|
+
setFocused: NOOP,
|
|
1138
|
+
validate: () => null,
|
|
1139
|
+
validationMode: 'onSubmit',
|
|
1140
|
+
validationDebounceTime: 0,
|
|
1141
|
+
shouldValidateOnChange: () => false,
|
|
1142
|
+
state: DEFAULT_FIELD_ROOT_STATE,
|
|
1143
|
+
markedDirtyRef: {
|
|
1144
|
+
current: false
|
|
1145
|
+
},
|
|
1146
|
+
registerFieldControl: NOOP,
|
|
1147
|
+
validation: {
|
|
1148
|
+
getValidationProps: (_disabled, props = EMPTY_OBJECT) => props,
|
|
1149
|
+
inputRef: {
|
|
1150
|
+
current: null
|
|
1151
|
+
},
|
|
1152
|
+
registerInput: NOOP,
|
|
1153
|
+
commit: async () => {},
|
|
1154
|
+
change: NOOP
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
const FieldRootContext = /*#__PURE__*/React.createContext(DEFAULT_FIELD_ROOT_CONTEXT);
|
|
1158
|
+
if (process.env.NODE_ENV !== "production") FieldRootContext.displayName = "FieldRootContext";
|
|
1159
|
+
function useFieldRootContext(optional = true) {
|
|
1160
|
+
const context = React.useContext(FieldRootContext);
|
|
1161
|
+
if (context.setValidityData === NOOP && !optional) {
|
|
1162
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>.' : formatErrorMessage(28));
|
|
1163
|
+
}
|
|
1164
|
+
return context;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
function useRegisterFieldControl(controlRef, id, value, getFormValueOverride, enabled = true, name) {
|
|
1168
|
+
const {
|
|
1169
|
+
registerFieldControl
|
|
1170
|
+
} = useFieldRootContext();
|
|
1171
|
+
const sourceRef = React.useRef(null);
|
|
1172
|
+
if (!sourceRef.current) {
|
|
1173
|
+
sourceRef.current = Symbol();
|
|
1174
|
+
}
|
|
1175
|
+
useIsoLayoutEffect(() => {
|
|
1176
|
+
const source = sourceRef.current;
|
|
1177
|
+
if (!source || !enabled) {
|
|
1178
|
+
return undefined;
|
|
1179
|
+
}
|
|
1180
|
+
const registration = {
|
|
1181
|
+
controlRef,
|
|
1182
|
+
getValue: getFormValueOverride,
|
|
1183
|
+
id,
|
|
1184
|
+
name,
|
|
1185
|
+
value
|
|
1186
|
+
};
|
|
1187
|
+
registerFieldControl(source, registration);
|
|
1188
|
+
return () => {
|
|
1189
|
+
registerFieldControl(source, undefined);
|
|
1190
|
+
};
|
|
1191
|
+
}, [controlRef, enabled, getFormValueOverride, id, name, registerFieldControl, value]);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const FormContext = /*#__PURE__*/React.createContext({
|
|
1195
|
+
formRef: {
|
|
1196
|
+
current: {
|
|
1197
|
+
fields: new Map()
|
|
1198
|
+
}
|
|
1199
|
+
},
|
|
1200
|
+
errors: {},
|
|
1201
|
+
clearErrors: NOOP,
|
|
1202
|
+
validationMode: 'onSubmit',
|
|
1203
|
+
submitAttemptedRef: {
|
|
1204
|
+
current: false
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
if (process.env.NODE_ENV !== "production") FormContext.displayName = "FormContext";
|
|
1208
|
+
function useFormContext() {
|
|
1209
|
+
return React.useContext(FormContext);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* A context for providing [labelable elements](https://html.spec.whatwg.org/multipage/forms.html#category-label)\
|
|
1214
|
+
* with an accessible name (label) and description.
|
|
1215
|
+
*/
|
|
1216
|
+
const LabelableContext = /*#__PURE__*/React.createContext({
|
|
1217
|
+
controlId: undefined,
|
|
1218
|
+
registerControlId: NOOP,
|
|
1219
|
+
labelId: undefined,
|
|
1220
|
+
setLabelId: NOOP,
|
|
1221
|
+
messageIds: [],
|
|
1222
|
+
setMessageIds: NOOP,
|
|
1223
|
+
getDescriptionProps: externalProps => externalProps
|
|
1224
|
+
});
|
|
1225
|
+
if (process.env.NODE_ENV !== "production") LabelableContext.displayName = "LabelableContext";
|
|
1226
|
+
function useLabelableContext() {
|
|
1227
|
+
return React.useContext(LabelableContext);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
function useLabelableId(params = {}) {
|
|
1231
|
+
const {
|
|
1232
|
+
id,
|
|
1233
|
+
implicit = false,
|
|
1234
|
+
controlRef
|
|
1235
|
+
} = params;
|
|
1236
|
+
const {
|
|
1237
|
+
controlId,
|
|
1238
|
+
registerControlId
|
|
1239
|
+
} = useLabelableContext();
|
|
1240
|
+
const defaultId = useBaseUiId(id);
|
|
1241
|
+
const controlIdForEffect = implicit ? controlId : undefined;
|
|
1242
|
+
const controlSourceRef = useRefWithInit(() => Symbol('labelable-control'));
|
|
1243
|
+
const hasRegisteredRef = React.useRef(false);
|
|
1244
|
+
const hadExplicitIdRef = React.useRef(id != null);
|
|
1245
|
+
const unregisterControlId = useStableCallback(() => {
|
|
1246
|
+
if (!hasRegisteredRef.current || registerControlId === NOOP) {
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
hasRegisteredRef.current = false;
|
|
1250
|
+
registerControlId(controlSourceRef.current, undefined);
|
|
1251
|
+
});
|
|
1252
|
+
useIsoLayoutEffect(() => {
|
|
1253
|
+
if (registerControlId === NOOP) {
|
|
1254
|
+
return undefined;
|
|
1255
|
+
}
|
|
1256
|
+
let nextId;
|
|
1257
|
+
if (implicit) {
|
|
1258
|
+
const elem = controlRef?.current;
|
|
1259
|
+
if (isElement(elem) && elem.closest('label') != null) {
|
|
1260
|
+
nextId = id ?? null;
|
|
1261
|
+
} else {
|
|
1262
|
+
nextId = controlIdForEffect ?? defaultId;
|
|
1263
|
+
}
|
|
1264
|
+
} else if (id != null) {
|
|
1265
|
+
hadExplicitIdRef.current = true;
|
|
1266
|
+
nextId = id;
|
|
1267
|
+
} else if (hadExplicitIdRef.current) {
|
|
1268
|
+
nextId = defaultId;
|
|
1269
|
+
} else {
|
|
1270
|
+
unregisterControlId();
|
|
1271
|
+
return undefined;
|
|
1272
|
+
}
|
|
1273
|
+
if (nextId === undefined) {
|
|
1274
|
+
unregisterControlId();
|
|
1275
|
+
return undefined;
|
|
1276
|
+
}
|
|
1277
|
+
hasRegisteredRef.current = true;
|
|
1278
|
+
registerControlId(controlSourceRef.current, nextId);
|
|
1279
|
+
return undefined;
|
|
1280
|
+
}, [id, controlRef, controlIdForEffect, registerControlId, implicit, defaultId, controlSourceRef, unregisterControlId]);
|
|
1281
|
+
React.useEffect(() => {
|
|
1282
|
+
return unregisterControlId;
|
|
1283
|
+
}, [unregisterControlId]);
|
|
1284
|
+
return controlId ?? defaultId;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
1288
|
+
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
1289
|
+
}
|
|
1290
|
+
|
|
897
1291
|
function getPseudoElementBounds(element) {
|
|
898
1292
|
const elementRect = element.getBoundingClientRect();
|
|
899
1293
|
const win = getWindow(element);
|
|
@@ -930,6 +1324,13 @@ function getPseudoElementBounds(element) {
|
|
|
930
1324
|
};
|
|
931
1325
|
}
|
|
932
1326
|
|
|
1327
|
+
function getDefaultLabelId(id) {
|
|
1328
|
+
return id == null ? undefined : `${id}-label`;
|
|
1329
|
+
}
|
|
1330
|
+
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
1331
|
+
return fieldLabelId ?? localLabelId;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
933
1334
|
const CompositeListContext = /*#__PURE__*/React.createContext({
|
|
934
1335
|
register: () => {},
|
|
935
1336
|
unregister: () => {},
|
|
@@ -1806,4 +2207,4 @@ function useCompositeListItem(params = {}) {
|
|
|
1806
2207
|
};
|
|
1807
2208
|
}
|
|
1808
2209
|
|
|
1809
|
-
export { CompositeList as C, IndexGuessBehavior as I,
|
|
2210
|
+
export { removeItem as A, adaptiveOrigin as B, CompositeList as C, DEFAULT_VALIDITY_STATE as D, isGroupedItems as E, FieldRootContext as F, DEFAULT_FIELD_ROOT_CONTEXT as G, DEFAULT_FIELD_STATE_ATTRIBUTES as H, IndexGuessBehavior as I, getDefaultLabelId as J, LabelableContext as L, useFormContext as a, useFieldRootContext as b, useLabelableId as c, useRegisterFieldControl as d, compareItemEquality as e, fieldValidityMapping as f, findItemIndex as g, hasNullItemLabel as h, useFloatingRootContext as i, useListNavigation as j, useTypeahead as k, defaultItemEquality as l, stringifyAsLabel as m, areArraysEqual as n, getPseudoElementBounds as o, resolveMultipleLabels as p, resolveSelectedLabel as q, resolveAriaLabelledBy as r, stringifyAsValue as s, useAnchoredPopupScrollLock as t, useLabelableContext as u, useAnchorPositioning as v, usePositioner as w, selectedValueIncludes as x, getDisabledMountTransitionStyles as y, useCompositeListItem as z };
|
package/dist/useLabel-cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var floatingUi_utils = require('./floating-ui.utils-cjs.js');
|
|
4
|
+
var useScrollLock = require('./useScrollLock-cjs.js');
|
|
5
|
+
var useCompositeListItem = require('./useCompositeListItem-cjs.js');
|
|
6
6
|
|
|
7
7
|
function useRegisteredLabelId(idProp, setLabelId) {
|
|
8
|
-
const id =
|
|
9
|
-
|
|
8
|
+
const id = useScrollLock.useBaseUiId(idProp);
|
|
9
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
10
10
|
setLabelId(id);
|
|
11
11
|
return () => {
|
|
12
12
|
setLabelId(undefined);
|
|
@@ -26,8 +26,8 @@ function useLabel(params = {}) {
|
|
|
26
26
|
const {
|
|
27
27
|
controlId: contextControlId,
|
|
28
28
|
setLabelId: setContextLabelId
|
|
29
|
-
} =
|
|
30
|
-
const syncLabelId =
|
|
29
|
+
} = useCompositeListItem.useLabelableContext();
|
|
30
|
+
const syncLabelId = useScrollLock.useStableCallback(nextLabelId => {
|
|
31
31
|
setContextLabelId(nextLabelId);
|
|
32
32
|
setLabelIdProp?.(nextLabelId);
|
|
33
33
|
});
|
|
@@ -41,13 +41,13 @@ function useLabel(params = {}) {
|
|
|
41
41
|
if (!resolvedControlId) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
const controlElement =
|
|
45
|
-
if (
|
|
44
|
+
const controlElement = useScrollLock.ownerDocument(event.currentTarget).getElementById(resolvedControlId);
|
|
45
|
+
if (floatingUi_utils.isHTMLElement(controlElement)) {
|
|
46
46
|
focusElementWithVisible(controlElement);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
function handleInteraction(event) {
|
|
50
|
-
const target =
|
|
50
|
+
const target = useScrollLock.getTarget(event.nativeEvent);
|
|
51
51
|
if (target?.closest('button,input,select,textarea')) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
package/dist/useLabel-es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as isHTMLElement } from './floating-ui.utils
|
|
2
|
-
import { u as useBaseUiId, a as useIsoLayoutEffect, b as useStableCallback, g as getTarget, o as ownerDocument } from './
|
|
3
|
-
import { u as useLabelableContext } from './
|
|
1
|
+
import { i as isHTMLElement } from './floating-ui.utils-es.js';
|
|
2
|
+
import { u as useBaseUiId, a as useIsoLayoutEffect, b as useStableCallback, g as getTarget, o as ownerDocument } from './useScrollLock-es.js';
|
|
3
|
+
import { u as useLabelableContext } from './useCompositeListItem-es.js';
|
|
4
4
|
|
|
5
5
|
function useRegisteredLabelId(idProp, setLabelId) {
|
|
6
6
|
const id = useBaseUiId(idProp);
|
|
@@ -623,4 +623,4 @@ function renderTag(Tag, props) {
|
|
|
623
623
|
return /*#__PURE__*/React.createElement(Tag, props);
|
|
624
624
|
}
|
|
625
625
|
|
|
626
|
-
export { EMPTY_OBJECT as E, NOOP as N, useRefWithInit as a,
|
|
626
|
+
export { EMPTY_OBJECT as E, NOOP as N, useRefWithInit as a, useMergedRefs as b, EMPTY_ARRAY as c, makeEventPreventable as d, formatErrorMessage as f, isReactVersionAtLeast as i, mergeProps as m, useRenderElement as u, warn as w };
|