@jobber/components 8.21.1 → 8.23.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/Dialog.d.ts +1 -0
- package/Dialog.js +17 -0
- package/dist/BottomSheet-cjs.js +34 -7
- package/dist/BottomSheet-es.js +34 -8
- package/dist/CSPContext-cjs.js +69 -0
- package/dist/CSPContext-es.js +46 -0
- package/dist/Card/index.cjs +3 -0
- package/dist/Card/index.mjs +3 -0
- package/dist/ComboboxChipRemove-cjs.js +54 -211
- package/dist/ComboboxChipRemove-es.js +8 -164
- package/dist/DataDump/index.cjs +3 -0
- package/dist/DataDump/index.mjs +3 -0
- package/dist/Dialog/Dialog.d.ts +3 -0
- package/dist/Dialog/Dialog.types.d.ts +205 -0
- package/dist/Dialog/DialogBottomSheet.d.ts +28 -0
- package/dist/Dialog/DialogModal.d.ts +20 -0
- package/dist/Dialog/constants.d.ts +1 -0
- package/dist/Dialog/dialogComposableShared.d.ts +53 -0
- package/dist/Dialog/dialogReturnFocus.d.ts +43 -0
- package/dist/Dialog/index.cjs +33 -0
- package/dist/Dialog/index.d.ts +4 -0
- package/dist/Dialog/index.mjs +25 -0
- package/dist/DrawerDescription-cjs.js +410 -0
- package/dist/DrawerDescription-es.js +383 -0
- package/dist/DrawerTitle-cjs.js +116 -0
- package/dist/DrawerTitle-es.js +92 -0
- package/dist/InputNumberExperimental-cjs.js +24 -23
- package/dist/InputNumberExperimental-es.js +3 -2
- package/dist/InternalBackdrop-es.js +3 -3
- package/dist/Menu/index.cjs +3 -0
- package/dist/Menu/index.mjs +3 -0
- package/dist/Menu-cjs.js +6 -4
- package/dist/Menu-es.js +6 -4
- package/dist/MenuSubmenuTrigger-cjs.js +53 -103
- package/dist/MenuSubmenuTrigger-es.js +55 -103
- package/dist/NumberFieldInput-cjs.js +9 -9
- package/dist/NumberFieldInput-es.js +3 -3
- package/dist/Page/index.cjs +3 -0
- package/dist/Page/index.mjs +3 -0
- package/dist/ScrollAreaViewport-cjs.js +921 -960
- package/dist/ScrollAreaViewport-es.js +917 -958
- package/dist/SelectGroupLabel-cjs.js +1924 -0
- package/dist/SelectGroupLabel-es.js +1888 -0
- package/dist/SelectPrimitive-cjs.js +112 -0
- package/dist/SelectPrimitive-es.js +110 -0
- package/dist/ToolbarRootContext-cjs.js +35 -0
- package/dist/ToolbarRootContext-es.js +14 -0
- package/dist/dialogReturnFocus-cjs.js +427 -0
- package/dist/dialogReturnFocus-es.js +423 -0
- package/dist/docs/SelectPrimitive/SelectPrimitive.md +326 -0
- package/dist/docs/index.md +1 -0
- package/dist/floating-ui.react-dom-cjs.js +1 -0
- package/dist/floating-ui.react-dom-es.js +2 -2
- package/dist/floating-ui.utils.dom-es.js +1 -1
- package/dist/index.cjs +15 -7
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +12 -7
- package/dist/primitives/BottomSheet/BottomSheet.d.ts +19 -1
- package/dist/primitives/BottomSheet/BottomSheet.types.d.ts +8 -0
- package/dist/primitives/BottomSheet/index.cjs +2 -0
- package/dist/primitives/BottomSheet/index.d.ts +1 -1
- package/dist/primitives/BottomSheet/index.mjs +2 -1
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -1
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -1
- package/dist/primitives/InputNumberExperimental/index.cjs +2 -1
- package/dist/primitives/InputNumberExperimental/index.mjs +2 -1
- package/dist/primitives/SelectPrimitive/SelectPrimitive.d.ts +63 -0
- package/dist/primitives/SelectPrimitive/index.cjs +29 -0
- package/dist/primitives/SelectPrimitive/index.d.ts +2 -0
- package/dist/primitives/SelectPrimitive/index.mjs +23 -0
- package/dist/primitives/SelectPrimitive/types.d.ts +16 -0
- package/dist/primitives/index.cjs +9 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.mjs +8 -2
- package/dist/primitives/mergeClassName.d.ts +12 -0
- package/dist/resolveAriaLabelledBy-cjs.js +195 -0
- package/dist/resolveAriaLabelledBy-es.js +162 -0
- package/dist/styles.css +685 -0
- package/dist/unstyledPrimitives/index.cjs +434 -259
- package/dist/unstyledPrimitives/index.d.ts +2 -0
- package/dist/unstyledPrimitives/index.mjs +425 -252
- package/dist/useButton-cjs.js +2 -0
- package/dist/useButton-es.js +3 -2
- package/dist/useCompositeListItem-es.js +4 -4
- package/dist/useLabel-cjs.js +3 -329
- package/dist/useLabel-es.js +4 -299
- package/dist/useLabelableId-cjs.js +332 -0
- package/dist/useLabelableId-es.js +300 -0
- package/dist/useRenderElement-cjs.js +3 -0
- package/dist/useRenderElement-es.js +4 -1
- package/dist/utils/meta/meta.json +11 -1
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Select } from "../../unstyledPrimitives";
|
|
3
|
+
import { OverlaySeparator } from "../OverlaySeparator";
|
|
4
|
+
declare function SelectPrimitiveTrigger({ className, children, ...props }: React.ComponentPropsWithoutRef<typeof Select.Trigger>): React.JSX.Element;
|
|
5
|
+
declare namespace SelectPrimitiveTrigger {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
declare function SelectPrimitiveValue({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.Value>): React.JSX.Element;
|
|
9
|
+
declare namespace SelectPrimitiveValue {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
declare function SelectPrimitivePositioner({ className, sideOffset, alignItemWithTrigger, ...props }: React.ComponentPropsWithoutRef<typeof Select.Positioner>): React.JSX.Element;
|
|
13
|
+
declare namespace SelectPrimitivePositioner {
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
16
|
+
declare function SelectPrimitivePopup({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.Popup>): React.JSX.Element;
|
|
17
|
+
declare namespace SelectPrimitivePopup {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
declare function SelectPrimitiveList({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.List>): React.JSX.Element;
|
|
21
|
+
declare namespace SelectPrimitiveList {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
declare function SelectPrimitiveItem({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.Item>): React.JSX.Element;
|
|
25
|
+
declare namespace SelectPrimitiveItem {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
declare function SelectPrimitiveItemText({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.ItemText>): React.JSX.Element;
|
|
29
|
+
declare namespace SelectPrimitiveItemText {
|
|
30
|
+
var displayName: string;
|
|
31
|
+
}
|
|
32
|
+
declare function SelectPrimitiveItemIndicator({ className, children, ...props }: React.ComponentPropsWithoutRef<typeof Select.ItemIndicator>): React.JSX.Element;
|
|
33
|
+
declare namespace SelectPrimitiveItemIndicator {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
declare function SelectPrimitiveGroup({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.Group>): React.JSX.Element;
|
|
37
|
+
declare namespace SelectPrimitiveGroup {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
declare function SelectPrimitiveGroupLabel({ className, ...props }: React.ComponentPropsWithoutRef<typeof Select.GroupLabel>): React.JSX.Element;
|
|
41
|
+
declare namespace SelectPrimitiveGroupLabel {
|
|
42
|
+
var displayName: string;
|
|
43
|
+
}
|
|
44
|
+
declare function SelectPrimitiveSeparator({ className, ...props }: React.ComponentPropsWithoutRef<typeof OverlaySeparator>): React.JSX.Element;
|
|
45
|
+
declare namespace SelectPrimitiveSeparator {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const SelectPrimitive: {
|
|
49
|
+
Root: typeof Select.Root;
|
|
50
|
+
Trigger: typeof SelectPrimitiveTrigger;
|
|
51
|
+
Value: typeof SelectPrimitiveValue;
|
|
52
|
+
Portal: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectPortalProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
53
|
+
Positioner: typeof SelectPrimitivePositioner;
|
|
54
|
+
Popup: typeof SelectPrimitivePopup;
|
|
55
|
+
List: typeof SelectPrimitiveList;
|
|
56
|
+
Item: typeof SelectPrimitiveItem;
|
|
57
|
+
ItemText: typeof SelectPrimitiveItemText;
|
|
58
|
+
ItemIndicator: typeof SelectPrimitiveItemIndicator;
|
|
59
|
+
Group: typeof SelectPrimitiveGroup;
|
|
60
|
+
GroupLabel: typeof SelectPrimitiveGroupLabel;
|
|
61
|
+
Separator: typeof SelectPrimitiveSeparator;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var SelectPrimitive = require('../../SelectPrimitive-cjs.js');
|
|
4
|
+
require('../../tslib.es6-cjs.js');
|
|
5
|
+
require('react');
|
|
6
|
+
require('classnames');
|
|
7
|
+
require('../../Icon-cjs.js');
|
|
8
|
+
require('@jobber/design');
|
|
9
|
+
require('../../OverlaySeparator-cjs.js');
|
|
10
|
+
require('../../Separator-cjs.js');
|
|
11
|
+
require('../../useRenderElement-cjs.js');
|
|
12
|
+
require('../../SelectGroupLabel-cjs.js');
|
|
13
|
+
require('../../useButton-cjs.js');
|
|
14
|
+
require('../../floating-ui.utils.dom-cjs.js');
|
|
15
|
+
require('react-dom');
|
|
16
|
+
require('../../InternalBackdrop-cjs.js');
|
|
17
|
+
require('../../index.esm-cjs.js');
|
|
18
|
+
require('react/jsx-runtime');
|
|
19
|
+
require('../../useLabelableId-cjs.js');
|
|
20
|
+
require('../../resolveAriaLabelledBy-cjs.js');
|
|
21
|
+
require('../../useCompositeListItem-cjs.js');
|
|
22
|
+
require('../../floating-ui.react-dom-cjs.js');
|
|
23
|
+
require('../../CSPContext-cjs.js');
|
|
24
|
+
require('../../ToolbarRootContext-cjs.js');
|
|
25
|
+
require('../../clamp-cjs.js');
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.SelectPrimitive = SelectPrimitive.SelectPrimitive;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SelectPrimitive } from "./SelectPrimitive";
|
|
2
|
+
export type { SelectPrimitiveRootProps, SelectPrimitiveTriggerProps, SelectPrimitiveValueProps, SelectPrimitivePortalProps, SelectPrimitivePositionerProps, SelectPrimitivePopupProps, SelectPrimitiveListProps, SelectPrimitiveItemProps, SelectPrimitiveItemTextProps, SelectPrimitiveItemIndicatorProps, SelectPrimitiveGroupProps, SelectPrimitiveGroupLabelProps, SelectPrimitiveSeparatorProps, } from "./types";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { S as SelectPrimitive } from '../../SelectPrimitive-es.js';
|
|
2
|
+
import '../../tslib.es6-es.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'classnames';
|
|
5
|
+
import '../../Icon-es.js';
|
|
6
|
+
import '@jobber/design';
|
|
7
|
+
import '../../OverlaySeparator-es.js';
|
|
8
|
+
import '../../Separator-es.js';
|
|
9
|
+
import '../../useRenderElement-es.js';
|
|
10
|
+
import '../../SelectGroupLabel-es.js';
|
|
11
|
+
import '../../useButton-es.js';
|
|
12
|
+
import '../../floating-ui.utils.dom-es.js';
|
|
13
|
+
import 'react-dom';
|
|
14
|
+
import '../../InternalBackdrop-es.js';
|
|
15
|
+
import '../../index.esm-es.js';
|
|
16
|
+
import 'react/jsx-runtime';
|
|
17
|
+
import '../../useLabelableId-es.js';
|
|
18
|
+
import '../../resolveAriaLabelledBy-es.js';
|
|
19
|
+
import '../../useCompositeListItem-es.js';
|
|
20
|
+
import '../../floating-ui.react-dom-es.js';
|
|
21
|
+
import '../../CSPContext-es.js';
|
|
22
|
+
import '../../ToolbarRootContext-es.js';
|
|
23
|
+
import '../../clamp-es.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { Select } from "../../unstyledPrimitives";
|
|
3
|
+
import type { OverlaySeparator } from "../OverlaySeparator";
|
|
4
|
+
export type SelectPrimitiveRootProps = React.ComponentPropsWithoutRef<typeof Select.Root>;
|
|
5
|
+
export type SelectPrimitiveTriggerProps = React.ComponentPropsWithoutRef<typeof Select.Trigger>;
|
|
6
|
+
export type SelectPrimitiveValueProps = React.ComponentPropsWithoutRef<typeof Select.Value>;
|
|
7
|
+
export type SelectPrimitivePortalProps = React.ComponentPropsWithoutRef<typeof Select.Portal>;
|
|
8
|
+
export type SelectPrimitivePositionerProps = React.ComponentPropsWithoutRef<typeof Select.Positioner>;
|
|
9
|
+
export type SelectPrimitivePopupProps = React.ComponentPropsWithoutRef<typeof Select.Popup>;
|
|
10
|
+
export type SelectPrimitiveListProps = React.ComponentPropsWithoutRef<typeof Select.List>;
|
|
11
|
+
export type SelectPrimitiveItemProps = React.ComponentPropsWithoutRef<typeof Select.Item>;
|
|
12
|
+
export type SelectPrimitiveItemTextProps = React.ComponentPropsWithoutRef<typeof Select.ItemText>;
|
|
13
|
+
export type SelectPrimitiveItemIndicatorProps = React.ComponentPropsWithoutRef<typeof Select.ItemIndicator>;
|
|
14
|
+
export type SelectPrimitiveGroupProps = React.ComponentPropsWithoutRef<typeof Select.Group>;
|
|
15
|
+
export type SelectPrimitiveGroupLabelProps = React.ComponentPropsWithoutRef<typeof Select.GroupLabel>;
|
|
16
|
+
export type SelectPrimitiveSeparatorProps = React.ComponentPropsWithoutRef<typeof OverlaySeparator>;
|
|
@@ -5,6 +5,7 @@ var BottomSheet = require('../BottomSheet-cjs.js');
|
|
|
5
5
|
var HelperText = require('../HelperText-cjs.js');
|
|
6
6
|
var ComboboxPrimitive = require('../ComboboxPrimitive-cjs.js');
|
|
7
7
|
var InputNumberExperimental = require('../InputNumberExperimental-cjs.js');
|
|
8
|
+
var SelectPrimitive = require('../SelectPrimitive-cjs.js');
|
|
8
9
|
require('../tslib.es6-cjs.js');
|
|
9
10
|
require('react');
|
|
10
11
|
require('classnames');
|
|
@@ -23,19 +24,26 @@ require('../floating-ui.utils.dom-cjs.js');
|
|
|
23
24
|
require('../useButton-cjs.js');
|
|
24
25
|
require('react-dom');
|
|
25
26
|
require('react/jsx-runtime');
|
|
27
|
+
require('../CSPContext-cjs.js');
|
|
26
28
|
require('../clamp-cjs.js');
|
|
27
29
|
require('../Text-cjs.js');
|
|
28
30
|
require('../ComboboxChipRemove-cjs.js');
|
|
29
|
-
require('../
|
|
31
|
+
require('../useLabelableId-cjs.js');
|
|
30
32
|
require('../useCompositeListItem-cjs.js');
|
|
31
33
|
require('../floating-ui.react-dom-cjs.js');
|
|
34
|
+
require('../resolveAriaLabelledBy-cjs.js');
|
|
35
|
+
require('../useLabel-cjs.js');
|
|
32
36
|
require('../ActivityIndicator-cjs.js');
|
|
33
37
|
require('../NumberFieldInput-cjs.js');
|
|
38
|
+
require('../SelectGroupLabel-cjs.js');
|
|
39
|
+
require('../ToolbarRootContext-cjs.js');
|
|
34
40
|
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
exports.OverlaySeparator = OverlaySeparator.OverlaySeparator;
|
|
38
44
|
exports.BottomSheet = BottomSheet.BottomSheet;
|
|
45
|
+
exports.BottomSheetScrollAreaContext = BottomSheet.BottomSheetScrollAreaContext;
|
|
39
46
|
exports.HelperText = HelperText.HelperText;
|
|
40
47
|
exports.ComboboxPrimitive = ComboboxPrimitive.ComboboxPrimitive;
|
|
41
48
|
exports.InputNumberExperimental = InputNumberExperimental.InputNumberExperimental;
|
|
49
|
+
exports.SelectPrimitive = SelectPrimitive.SelectPrimitive;
|
|
@@ -11,3 +11,4 @@ export * from "./HelperText/index";
|
|
|
11
11
|
export * from "./ComboboxPrimitive/index";
|
|
12
12
|
export { InputNumberExperimental } from "./InputNumberExperimental";
|
|
13
13
|
export type { InputNumberExperimentalAffix, InputNumberExperimentalProps, InputNumberExperimentalRef, } from "./InputNumberExperimental";
|
|
14
|
+
export * from "./SelectPrimitive";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { O as OverlaySeparator } from '../OverlaySeparator-es.js';
|
|
2
|
-
export {
|
|
2
|
+
export { a as BottomSheet, B as BottomSheetScrollAreaContext } from '../BottomSheet-es.js';
|
|
3
3
|
export { H as HelperText } from '../HelperText-es.js';
|
|
4
4
|
export { C as ComboboxPrimitive } from '../ComboboxPrimitive-es.js';
|
|
5
5
|
export { I as InputNumberExperimental } from '../InputNumberExperimental-es.js';
|
|
6
|
+
export { S as SelectPrimitive } from '../SelectPrimitive-es.js';
|
|
6
7
|
import '../tslib.es6-es.js';
|
|
7
8
|
import 'react';
|
|
8
9
|
import 'classnames';
|
|
@@ -21,11 +22,16 @@ import '../floating-ui.utils.dom-es.js';
|
|
|
21
22
|
import '../useButton-es.js';
|
|
22
23
|
import 'react-dom';
|
|
23
24
|
import 'react/jsx-runtime';
|
|
25
|
+
import '../CSPContext-es.js';
|
|
24
26
|
import '../clamp-es.js';
|
|
25
27
|
import '../Text-es.js';
|
|
26
28
|
import '../ComboboxChipRemove-es.js';
|
|
27
|
-
import '../
|
|
29
|
+
import '../useLabelableId-es.js';
|
|
28
30
|
import '../useCompositeListItem-es.js';
|
|
29
31
|
import '../floating-ui.react-dom-es.js';
|
|
32
|
+
import '../resolveAriaLabelledBy-es.js';
|
|
33
|
+
import '../useLabel-es.js';
|
|
30
34
|
import '../ActivityIndicator-es.js';
|
|
31
35
|
import '../NumberFieldInput-es.js';
|
|
36
|
+
import '../SelectGroupLabel-es.js';
|
|
37
|
+
import '../ToolbarRootContext-es.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility for styled BaseUI primitive wrappers.
|
|
3
|
+
*
|
|
4
|
+
* Merges an Atlantis base class with a consumer-supplied className that may be
|
|
5
|
+
* either a plain string or a BaseUI state-based function
|
|
6
|
+
* (e.g. `className={(state) => state.open ? "open" : ""}`).
|
|
7
|
+
*
|
|
8
|
+
* All styled primitives should import from here rather than defining their own
|
|
9
|
+
* copy, so the type is consistent across the package.
|
|
10
|
+
*/
|
|
11
|
+
export type PrimitiveClassName<State = void> = string | ((state: State) => string | undefined) | undefined;
|
|
12
|
+
export declare function mergeClassName<State>(baseClassName: string, className: PrimitiveClassName<State>): PrimitiveClassName<State>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
|
+
|
|
25
|
+
const defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
|
|
26
|
+
function compareItemEquality(itemValue, selectedValue, comparer) {
|
|
27
|
+
if (itemValue == null || selectedValue == null) {
|
|
28
|
+
return Object.is(itemValue, selectedValue);
|
|
29
|
+
}
|
|
30
|
+
return comparer(itemValue, selectedValue);
|
|
31
|
+
}
|
|
32
|
+
function selectedValueIncludes(selectedValues, itemValue, comparer) {
|
|
33
|
+
if (!selectedValues || selectedValues.length === 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return selectedValues.some(selectedValue => {
|
|
37
|
+
if (selectedValue === undefined) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function findItemIndex(itemValues, selectedValue, comparer) {
|
|
44
|
+
if (!itemValues || itemValues.length === 0) {
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
return itemValues.findIndex(itemValue => {
|
|
48
|
+
if (itemValue === undefined) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function removeItem(selectedValues, itemValue, comparer) {
|
|
55
|
+
return selectedValues.filter(selectedValue => !compareItemEquality(itemValue, selectedValue, comparer));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function serializeValue(value) {
|
|
59
|
+
if (value == null) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === 'string') {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return JSON.stringify(value);
|
|
67
|
+
} catch {
|
|
68
|
+
return String(value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isGroupedItems(items) {
|
|
73
|
+
return items != null && items.length > 0 && typeof items[0] === 'object' && items[0] != null && 'items' in items[0];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Checks if the items array contains an item with a null value that has a non-null label.
|
|
78
|
+
*/
|
|
79
|
+
function hasNullItemLabel(items) {
|
|
80
|
+
if (!Array.isArray(items)) {
|
|
81
|
+
return items != null && 'null' in items;
|
|
82
|
+
}
|
|
83
|
+
const arrayItems = items;
|
|
84
|
+
if (isGroupedItems(arrayItems)) {
|
|
85
|
+
for (const group of arrayItems) {
|
|
86
|
+
for (const item of group.items) {
|
|
87
|
+
if (item && item.value == null && item.label != null) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
for (const item of arrayItems) {
|
|
95
|
+
if (item && item.value == null && item.label != null) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
function stringifyAsLabel(item, itemToStringLabel) {
|
|
102
|
+
if (itemToStringLabel && item != null) {
|
|
103
|
+
return itemToStringLabel(item) ?? '';
|
|
104
|
+
}
|
|
105
|
+
if (item && typeof item === 'object') {
|
|
106
|
+
if ('label' in item && item.label != null) {
|
|
107
|
+
return String(item.label);
|
|
108
|
+
}
|
|
109
|
+
if ('value' in item) {
|
|
110
|
+
return String(item.value);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return serializeValue(item);
|
|
114
|
+
}
|
|
115
|
+
function stringifyAsValue(item, itemToStringValue) {
|
|
116
|
+
if (itemToStringValue && item != null) {
|
|
117
|
+
return itemToStringValue(item) ?? '';
|
|
118
|
+
}
|
|
119
|
+
if (item && typeof item === 'object' && 'value' in item && 'label' in item) {
|
|
120
|
+
return serializeValue(item.value);
|
|
121
|
+
}
|
|
122
|
+
return serializeValue(item);
|
|
123
|
+
}
|
|
124
|
+
function resolveSelectedLabel(value, items, itemToStringLabel) {
|
|
125
|
+
function fallback() {
|
|
126
|
+
return stringifyAsLabel(value, itemToStringLabel);
|
|
127
|
+
}
|
|
128
|
+
if (itemToStringLabel && value != null) {
|
|
129
|
+
return itemToStringLabel(value);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Custom object with explicit label takes precedence
|
|
133
|
+
if (value && typeof value === 'object' && 'label' in value && value.label != null) {
|
|
134
|
+
return value.label;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Items provided as plain record map
|
|
138
|
+
if (items && !Array.isArray(items)) {
|
|
139
|
+
return items[value] ?? fallback();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Items provided as array (flat or grouped)
|
|
143
|
+
if (Array.isArray(items)) {
|
|
144
|
+
const arrayItems = items;
|
|
145
|
+
const flatItems = isGroupedItems(arrayItems) ? arrayItems.flatMap(group => group.items) : arrayItems;
|
|
146
|
+
if (value == null || typeof value !== 'object') {
|
|
147
|
+
const match = flatItems.find(item => item.value === value);
|
|
148
|
+
if (match && match.label != null) {
|
|
149
|
+
return match.label;
|
|
150
|
+
}
|
|
151
|
+
return fallback();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Object without explicit label: try matching by its `value` property
|
|
155
|
+
if ('value' in value) {
|
|
156
|
+
const match = flatItems.find(item => item && item.value === value.value);
|
|
157
|
+
if (match && match.label != null) {
|
|
158
|
+
return match.label;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return fallback();
|
|
163
|
+
}
|
|
164
|
+
function resolveMultipleLabels(values, items, itemToStringLabel) {
|
|
165
|
+
return values.reduce((acc, value, index) => {
|
|
166
|
+
if (index > 0) {
|
|
167
|
+
acc.push(', ');
|
|
168
|
+
}
|
|
169
|
+
acc.push(/*#__PURE__*/jsxRuntime.jsx(React__namespace.Fragment, {
|
|
170
|
+
children: resolveSelectedLabel(value, items, itemToStringLabel)
|
|
171
|
+
}, index));
|
|
172
|
+
return acc;
|
|
173
|
+
}, []);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getDefaultLabelId(id) {
|
|
177
|
+
return id == null ? undefined : `${id}-label`;
|
|
178
|
+
}
|
|
179
|
+
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
180
|
+
return fieldLabelId ?? localLabelId;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
exports.compareItemEquality = compareItemEquality;
|
|
184
|
+
exports.defaultItemEquality = defaultItemEquality;
|
|
185
|
+
exports.findItemIndex = findItemIndex;
|
|
186
|
+
exports.getDefaultLabelId = getDefaultLabelId;
|
|
187
|
+
exports.hasNullItemLabel = hasNullItemLabel;
|
|
188
|
+
exports.isGroupedItems = isGroupedItems;
|
|
189
|
+
exports.removeItem = removeItem;
|
|
190
|
+
exports.resolveAriaLabelledBy = resolveAriaLabelledBy;
|
|
191
|
+
exports.resolveMultipleLabels = resolveMultipleLabels;
|
|
192
|
+
exports.resolveSelectedLabel = resolveSelectedLabel;
|
|
193
|
+
exports.selectedValueIncludes = selectedValueIncludes;
|
|
194
|
+
exports.stringifyAsLabel = stringifyAsLabel;
|
|
195
|
+
exports.stringifyAsValue = stringifyAsValue;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
const defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
|
|
5
|
+
function compareItemEquality(itemValue, selectedValue, comparer) {
|
|
6
|
+
if (itemValue == null || selectedValue == null) {
|
|
7
|
+
return Object.is(itemValue, selectedValue);
|
|
8
|
+
}
|
|
9
|
+
return comparer(itemValue, selectedValue);
|
|
10
|
+
}
|
|
11
|
+
function selectedValueIncludes(selectedValues, itemValue, comparer) {
|
|
12
|
+
if (!selectedValues || selectedValues.length === 0) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return selectedValues.some(selectedValue => {
|
|
16
|
+
if (selectedValue === undefined) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function findItemIndex(itemValues, selectedValue, comparer) {
|
|
23
|
+
if (!itemValues || itemValues.length === 0) {
|
|
24
|
+
return -1;
|
|
25
|
+
}
|
|
26
|
+
return itemValues.findIndex(itemValue => {
|
|
27
|
+
if (itemValue === undefined) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return compareItemEquality(itemValue, selectedValue, comparer);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function removeItem(selectedValues, itemValue, comparer) {
|
|
34
|
+
return selectedValues.filter(selectedValue => !compareItemEquality(itemValue, selectedValue, comparer));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function serializeValue(value) {
|
|
38
|
+
if (value == null) {
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return JSON.stringify(value);
|
|
46
|
+
} catch {
|
|
47
|
+
return String(value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isGroupedItems(items) {
|
|
52
|
+
return items != null && items.length > 0 && typeof items[0] === 'object' && items[0] != null && 'items' in items[0];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Checks if the items array contains an item with a null value that has a non-null label.
|
|
57
|
+
*/
|
|
58
|
+
function hasNullItemLabel(items) {
|
|
59
|
+
if (!Array.isArray(items)) {
|
|
60
|
+
return items != null && 'null' in items;
|
|
61
|
+
}
|
|
62
|
+
const arrayItems = items;
|
|
63
|
+
if (isGroupedItems(arrayItems)) {
|
|
64
|
+
for (const group of arrayItems) {
|
|
65
|
+
for (const item of group.items) {
|
|
66
|
+
if (item && item.value == null && item.label != null) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
for (const item of arrayItems) {
|
|
74
|
+
if (item && item.value == null && item.label != null) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
function stringifyAsLabel(item, itemToStringLabel) {
|
|
81
|
+
if (itemToStringLabel && item != null) {
|
|
82
|
+
return itemToStringLabel(item) ?? '';
|
|
83
|
+
}
|
|
84
|
+
if (item && typeof item === 'object') {
|
|
85
|
+
if ('label' in item && item.label != null) {
|
|
86
|
+
return String(item.label);
|
|
87
|
+
}
|
|
88
|
+
if ('value' in item) {
|
|
89
|
+
return String(item.value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return serializeValue(item);
|
|
93
|
+
}
|
|
94
|
+
function stringifyAsValue(item, itemToStringValue) {
|
|
95
|
+
if (itemToStringValue && item != null) {
|
|
96
|
+
return itemToStringValue(item) ?? '';
|
|
97
|
+
}
|
|
98
|
+
if (item && typeof item === 'object' && 'value' in item && 'label' in item) {
|
|
99
|
+
return serializeValue(item.value);
|
|
100
|
+
}
|
|
101
|
+
return serializeValue(item);
|
|
102
|
+
}
|
|
103
|
+
function resolveSelectedLabel(value, items, itemToStringLabel) {
|
|
104
|
+
function fallback() {
|
|
105
|
+
return stringifyAsLabel(value, itemToStringLabel);
|
|
106
|
+
}
|
|
107
|
+
if (itemToStringLabel && value != null) {
|
|
108
|
+
return itemToStringLabel(value);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Custom object with explicit label takes precedence
|
|
112
|
+
if (value && typeof value === 'object' && 'label' in value && value.label != null) {
|
|
113
|
+
return value.label;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Items provided as plain record map
|
|
117
|
+
if (items && !Array.isArray(items)) {
|
|
118
|
+
return items[value] ?? fallback();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Items provided as array (flat or grouped)
|
|
122
|
+
if (Array.isArray(items)) {
|
|
123
|
+
const arrayItems = items;
|
|
124
|
+
const flatItems = isGroupedItems(arrayItems) ? arrayItems.flatMap(group => group.items) : arrayItems;
|
|
125
|
+
if (value == null || typeof value !== 'object') {
|
|
126
|
+
const match = flatItems.find(item => item.value === value);
|
|
127
|
+
if (match && match.label != null) {
|
|
128
|
+
return match.label;
|
|
129
|
+
}
|
|
130
|
+
return fallback();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Object without explicit label: try matching by its `value` property
|
|
134
|
+
if ('value' in value) {
|
|
135
|
+
const match = flatItems.find(item => item && item.value === value.value);
|
|
136
|
+
if (match && match.label != null) {
|
|
137
|
+
return match.label;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return fallback();
|
|
142
|
+
}
|
|
143
|
+
function resolveMultipleLabels(values, items, itemToStringLabel) {
|
|
144
|
+
return values.reduce((acc, value, index) => {
|
|
145
|
+
if (index > 0) {
|
|
146
|
+
acc.push(', ');
|
|
147
|
+
}
|
|
148
|
+
acc.push(/*#__PURE__*/jsx(React.Fragment, {
|
|
149
|
+
children: resolveSelectedLabel(value, items, itemToStringLabel)
|
|
150
|
+
}, index));
|
|
151
|
+
return acc;
|
|
152
|
+
}, []);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getDefaultLabelId(id) {
|
|
156
|
+
return id == null ? undefined : `${id}-label`;
|
|
157
|
+
}
|
|
158
|
+
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
159
|
+
return fieldLabelId ?? localLabelId;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export { resolveMultipleLabels as a, resolveSelectedLabel as b, compareItemEquality as c, defaultItemEquality as d, selectedValueIncludes as e, findItemIndex as f, removeItem as g, hasNullItemLabel as h, stringifyAsLabel as i, isGroupedItems as j, getDefaultLabelId as k, resolveAriaLabelledBy as r, stringifyAsValue as s };
|