wimui 0.79.0 → 0.80.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/components/_internal/HiddenFormValue.cjs +2 -0
- package/dist/components/_internal/HiddenFormValue.d.ts +36 -0
- package/dist/components/_internal/HiddenFormValue.js +25 -0
- package/dist/components/ai/AILabel/AILabel.d.ts +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +4 -4
- package/dist/components/data-display/Barcode/Barcode.cjs +1 -1
- package/dist/components/data-display/Barcode/Barcode.js +4 -4
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +128 -124
- package/dist/components/data-display/ScheduleView/ScheduleView.cjs +1 -1
- package/dist/components/data-display/ScheduleView/ScheduleView.js +3 -3
- package/dist/components/data-display/TreeView/tree-view.module.cjs +1 -1
- package/dist/components/data-display/TreeView/tree-view.module.js +1 -1
- package/dist/components/feedback/ErrorBoundary/ErrorBoundary.cjs +1 -1
- package/dist/components/feedback/ErrorBoundary/ErrorBoundary.js +5 -5
- package/dist/components/form/Button/Button.cjs +1 -1
- package/dist/components/form/Button/Button.js +7 -7
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.d.ts +5 -1
- package/dist/components/form/Cascader/Cascader.js +61 -53
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.js +4 -4
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.js +3 -3
- package/dist/components/form/LinkButton/LinkButton.d.ts +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.d.ts +5 -1
- package/dist/components/form/MultiSelect/MultiSelect.js +71 -63
- package/dist/components/form/OtpInput/OtpInput.cjs +1 -1
- package/dist/components/form/OtpInput/OtpInput.d.ts +4 -0
- package/dist/components/form/OtpInput/OtpInput.js +76 -68
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +109 -104
- package/dist/components/form/Rating/Rating.cjs +1 -1
- package/dist/components/form/Rating/Rating.d.ts +5 -1
- package/dist/components/form/Rating/Rating.js +78 -70
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.d.ts +4 -0
- package/dist/components/form/SegmentedControl/SegmentedControl.js +56 -51
- package/dist/components/form/Select/Select.cjs +1 -1
- package/dist/components/form/Select/Select.d.ts +4 -0
- package/dist/components/form/Select/Select.js +91 -84
- package/dist/components/form/Select/useSelect.cjs +1 -1
- package/dist/components/form/Select/useSelect.d.ts +1 -0
- package/dist/components/form/Select/useSelect.js +9 -6
- package/dist/components/form/Slider/Slider.cjs +1 -1
- package/dist/components/form/Slider/Slider.js +82 -77
- package/dist/components/form/TagInput/TagInput.cjs +1 -1
- package/dist/components/form/TagInput/TagInput.d.ts +4 -0
- package/dist/components/form/TagInput/TagInput.js +35 -27
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.d.ts +4 -0
- package/dist/components/form/TreeSelect/TreeSelect.js +91 -83
- package/dist/components/layout/AppShell/AppShell.cjs +1 -1
- package/dist/components/layout/AppShell/AppShell.d.ts +5 -0
- package/dist/components/layout/AppShell/AppShell.js +107 -89
- package/dist/components/layout/OverflowList/OverflowList.cjs +1 -1
- package/dist/components/layout/OverflowList/OverflowList.js +4 -4
- package/dist/components/navigation/Breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb/Breadcrumb.js +15 -15
- package/dist/components/navigation/HamburgerMenu/HamburgerMenu.cjs +1 -1
- package/dist/components/navigation/HamburgerMenu/HamburgerMenu.js +3 -3
- package/dist/components/navigation/SkipLink/SkipLink.cjs +2 -0
- package/dist/components/navigation/SkipLink/SkipLink.d.ts +39 -0
- package/dist/components/navigation/SkipLink/SkipLink.js +27 -0
- package/dist/components/navigation/SkipLink/skip-link.module.cjs +2 -0
- package/dist/components/navigation/SkipLink/skip-link.module.js +5 -0
- package/dist/components/overlay/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/overlay/ContextMenu/ContextMenu.js +92 -77
- package/dist/i18n/generated/components.d.ts +1 -1
- package/dist/i18n/generated/navigation.cjs +1 -1
- package/dist/i18n/generated/navigation.d.ts +1 -1
- package/dist/i18n/generated/navigation.js +12 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +300 -299
- package/dist/llms/AIResponseFeedback.md +2 -0
- package/dist/llms/Accordion.md +1 -1
- package/dist/llms/Alert.md +1 -1
- package/dist/llms/AppShell.md +2 -1
- package/dist/llms/Audio.md +2 -0
- package/dist/llms/AvatarGroup.md +1 -1
- package/dist/llms/BackTop.md +1 -1
- package/dist/llms/Badge.md +1 -1
- package/dist/llms/ButtonGroup.md +1 -1
- package/dist/llms/Cascader.md +2 -1
- package/dist/llms/Charts.md +2 -0
- package/dist/llms/ChatUI.md +2 -0
- package/dist/llms/Code.md +2 -0
- package/dist/llms/CodeBlock.md +1 -1
- package/dist/llms/ColorPicker.md +1 -1
- package/dist/llms/Confirm.md +2 -0
- package/dist/llms/DataGrid.md +1 -1
- package/dist/llms/DatePicker.md +1 -1
- package/dist/llms/DescriptionList.md +1 -1
- package/dist/llms/Drawer.md +1 -1
- package/dist/llms/Dropdown.md +1 -1
- package/dist/llms/EmptyState.md +1 -1
- package/dist/llms/FieldError.md +2 -0
- package/dist/llms/FieldTemplate.md +1 -1
- package/dist/llms/FileUpload.md +1 -1
- package/dist/llms/FloatButton.md +2 -0
- package/dist/llms/FocusTrap.md +2 -0
- package/dist/llms/Gallery.md +2 -0
- package/dist/llms/Grid.md +2 -0
- package/dist/llms/Group.md +1 -1
- package/dist/llms/Header.md +2 -0
- package/dist/llms/HoverCard.md +2 -0
- package/dist/llms/IconButton.md +2 -0
- package/dist/llms/Image.md +2 -0
- package/dist/llms/ImageCompare.md +2 -0
- package/dist/llms/ImageCropper.md +2 -0
- package/dist/llms/Indicator.md +1 -1
- package/dist/llms/InfiniteScroll.md +2 -0
- package/dist/llms/InlineEdit.md +1 -1
- package/dist/llms/Input.md +1 -1
- package/dist/llms/InputMask.md +2 -0
- package/dist/llms/Kbd.md +1 -1
- package/dist/llms/List.md +1 -1
- package/dist/llms/LoadingOverlay.md +2 -0
- package/dist/llms/MarkdownRenderer.md +2 -0
- package/dist/llms/Marquee.md +1 -1
- package/dist/llms/Mentions.md +2 -0
- package/dist/llms/Menu.md +2 -0
- package/dist/llms/MultiSelect.md +2 -1
- package/dist/llms/NumberInput.md +1 -1
- package/dist/llms/OtpInput.md +2 -1
- package/dist/llms/PageHeader.md +2 -0
- package/dist/llms/Pagination.md +1 -1
- package/dist/llms/PasswordInput.md +2 -0
- package/dist/llms/Popconfirm.md +2 -0
- package/dist/llms/Popover.md +1 -1
- package/dist/llms/Progress.md +1 -1
- package/dist/llms/ProgressRing.md +1 -1
- package/dist/llms/PromptInput.md +2 -0
- package/dist/llms/RadioGroup.md +1 -1
- package/dist/llms/RangeSlider.md +2 -0
- package/dist/llms/Rating.md +2 -1
- package/dist/llms/RichTextEditor.md +2 -0
- package/dist/llms/ScrollArea.md +2 -0
- package/dist/llms/SegmentedControl.md +2 -1
- package/dist/llms/Select.md +2 -1
- package/dist/llms/SelectionBar.md +1 -1
- package/dist/llms/Sidebar.md +1 -1
- package/dist/llms/SimpleGrid.md +2 -0
- package/dist/llms/Skeleton.md +1 -1
- package/dist/llms/SkipLink.md +24 -0
- package/dist/llms/Slider.md +2 -0
- package/dist/llms/SortableList.md +2 -0
- package/dist/llms/Spinner.md +1 -1
- package/dist/llms/Splitter.md +1 -1
- package/dist/llms/Stack.md +2 -0
- package/dist/llms/Stats.md +1 -1
- package/dist/llms/Stepper.md +1 -1
- package/dist/llms/Switch.md +1 -1
- package/dist/llms/TabNavigation.md +2 -0
- package/dist/llms/Tabs.md +1 -1
- package/dist/llms/Tag.md +1 -1
- package/dist/llms/TagInput.md +2 -1
- package/dist/llms/Text.md +1 -1
- package/dist/llms/Textarea.md +2 -0
- package/dist/llms/TimePicker.md +2 -0
- package/dist/llms/Toast.md +1 -1
- package/dist/llms/ToggleGroup.md +2 -0
- package/dist/llms/Toolbar.md +2 -0
- package/dist/llms/Tooltip.md +1 -1
- package/dist/llms/Tour.md +3 -1
- package/dist/llms/Transfer.md +2 -0
- package/dist/llms/TreeDiagram.md +1 -1
- package/dist/llms/TreeSelect.md +1 -0
- package/dist/llms/TreeView.md +2 -2
- package/dist/llms/Treemap.md +2 -0
- package/dist/llms/Video.md +2 -0
- package/dist/llms/VirtualList.md +2 -0
- package/dist/llms-full.txt +154 -104
- package/dist/llms.txt +141 -104
- package/dist/locales/en/components.json +2 -1
- package/dist/locales/ja/components.json +2 -1
- package/dist/locales/pt/components.json +2 -1
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +1 -0
- package/dist/navigation.js +17 -16
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +3 -3
|
@@ -4,82 +4,87 @@ import { useMergedRef as n } from "../../../hooks/useMergedRef.js";
|
|
|
4
4
|
import { Icon as r } from "../../media/Icon/Icon.js";
|
|
5
5
|
import { getRovingIndex as i } from "../../_internal/rovingIndex.js";
|
|
6
6
|
import { FieldTemplate as a } from "../FieldTemplate/FieldTemplate.js";
|
|
7
|
-
import {
|
|
8
|
-
import s from "
|
|
9
|
-
import
|
|
10
|
-
import d from "
|
|
11
|
-
import
|
|
7
|
+
import { HiddenFormValue as o } from "../../_internal/HiddenFormValue.js";
|
|
8
|
+
import { useIndicator as s } from "../../_internal/useIndicator.js";
|
|
9
|
+
import c from "./segmented-control.module.js";
|
|
10
|
+
import { forwardRef as l, useId as u, useRef as d } from "react";
|
|
11
|
+
import f from "classnames";
|
|
12
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
12
13
|
//#region src/components/form/SegmentedControl/SegmentedControl.tsx
|
|
13
|
-
var
|
|
14
|
-
let
|
|
15
|
-
activeSelector: `.${
|
|
16
|
-
dependence:
|
|
17
|
-
}),
|
|
14
|
+
var h = l(({ options: l, value: h, onChange: g, size: _ = "md", fullWidth: v = !1, className: y, label: b, error: x, required: S, name: C, layout: w = "vertical", disabled: T = !1, asChild: E = !1, children: D, id: O, styles: k, "aria-label": A, "aria-labelledby": j, "aria-describedby": M }, N) => {
|
|
15
|
+
let P = d([]), F = u(), I = O || `wim-segmented-${F}`, L = `${I}-label`, R = `${I}-error`, { containerRef: z, sliderStyle: B, isReady: V } = s({
|
|
16
|
+
activeSelector: `.${c.active}`,
|
|
17
|
+
dependence: l.length
|
|
18
|
+
}), H = l.findIndex((e) => e.value === h), U = (e, t) => {
|
|
18
19
|
let n = i({
|
|
19
20
|
key: e.key,
|
|
20
21
|
current: t,
|
|
21
|
-
count:
|
|
22
|
+
count: l.length
|
|
22
23
|
});
|
|
23
|
-
n !== null && (e.preventDefault(),
|
|
24
|
-
},
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
label:
|
|
27
|
-
error:
|
|
28
|
-
required:
|
|
29
|
-
layout:
|
|
30
|
-
labelId:
|
|
31
|
-
htmlFor:
|
|
32
|
-
errorId:
|
|
33
|
-
className:
|
|
34
|
-
children: /* @__PURE__ */
|
|
35
|
-
ref: n(
|
|
36
|
-
id:
|
|
37
|
-
className:
|
|
24
|
+
n !== null && (e.preventDefault(), g(l[n].value), P.current[n]?.focus());
|
|
25
|
+
}, W = `${I}-item-0`;
|
|
26
|
+
return /* @__PURE__ */ m(a, {
|
|
27
|
+
label: b,
|
|
28
|
+
error: x,
|
|
29
|
+
required: S,
|
|
30
|
+
layout: w,
|
|
31
|
+
labelId: L,
|
|
32
|
+
htmlFor: W,
|
|
33
|
+
errorId: R,
|
|
34
|
+
className: y,
|
|
35
|
+
children: [/* @__PURE__ */ m(E ? e : "div", {
|
|
36
|
+
ref: n(z, N),
|
|
37
|
+
id: I,
|
|
38
|
+
className: f("wim-segmented-control", c.root, c[_], v && c.fullWidth, V && c.ready, x && c.danger, k?.root),
|
|
38
39
|
role: "radiogroup",
|
|
39
|
-
"aria-labelledby":
|
|
40
|
-
"aria-label":
|
|
41
|
-
"aria-required":
|
|
42
|
-
"aria-invalid":
|
|
43
|
-
"aria-describedby": [
|
|
40
|
+
"aria-labelledby": b ? L : j,
|
|
41
|
+
"aria-label": b || j ? void 0 : A,
|
|
42
|
+
"aria-required": S,
|
|
43
|
+
"aria-invalid": x ? !0 : void 0,
|
|
44
|
+
"aria-describedby": [M, x ? R : void 0].filter(Boolean).join(" ") || void 0,
|
|
44
45
|
children: [
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
className:
|
|
47
|
-
style:
|
|
46
|
+
/* @__PURE__ */ p("div", {
|
|
47
|
+
className: f(c.slider, k?.slider),
|
|
48
|
+
style: B,
|
|
48
49
|
"aria-hidden": "true"
|
|
49
50
|
}),
|
|
50
|
-
|
|
51
|
-
let n = e.value ===
|
|
52
|
-
return /* @__PURE__ */
|
|
51
|
+
l.map((e, t) => {
|
|
52
|
+
let n = e.value === h, i = n || H === -1 && t === 0, a = `${I}-item-${t}`;
|
|
53
|
+
return /* @__PURE__ */ m("button", {
|
|
53
54
|
id: a,
|
|
54
55
|
ref: (e) => {
|
|
55
|
-
|
|
56
|
+
P.current[t] = e;
|
|
56
57
|
},
|
|
57
58
|
type: "button",
|
|
58
|
-
className:
|
|
59
|
-
onClick: () =>
|
|
60
|
-
onKeyDown: (e) =>
|
|
59
|
+
className: f(c.item, n && c.active, !e.label && e.iconName && c.iconOnly, k?.item),
|
|
60
|
+
onClick: () => g(e.value),
|
|
61
|
+
onKeyDown: (e) => U(e, t),
|
|
61
62
|
onFocus: () => {},
|
|
62
63
|
onBlur: () => {},
|
|
63
64
|
role: "radio",
|
|
64
65
|
"aria-checked": n,
|
|
65
66
|
tabIndex: i ? 0 : -1,
|
|
66
67
|
"aria-label": e.label ? void 0 : e.value,
|
|
67
|
-
disabled:
|
|
68
|
-
children: [e.iconName && /* @__PURE__ */
|
|
68
|
+
disabled: T,
|
|
69
|
+
children: [e.iconName && /* @__PURE__ */ p(r, {
|
|
69
70
|
name: e.iconName,
|
|
70
|
-
size:
|
|
71
|
-
className:
|
|
72
|
-
}), e.label && /* @__PURE__ */
|
|
73
|
-
className:
|
|
71
|
+
size: _,
|
|
72
|
+
className: c.icon
|
|
73
|
+
}), e.label && /* @__PURE__ */ p("span", {
|
|
74
|
+
className: f(c.label, k?.label),
|
|
74
75
|
children: e.label
|
|
75
76
|
})]
|
|
76
77
|
}, e.value);
|
|
77
78
|
}),
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ p(t, { children: D })
|
|
79
80
|
]
|
|
80
|
-
})
|
|
81
|
+
}), /* @__PURE__ */ p(o, {
|
|
82
|
+
name: C,
|
|
83
|
+
value: h,
|
|
84
|
+
disabled: T
|
|
85
|
+
})]
|
|
81
86
|
});
|
|
82
87
|
});
|
|
83
|
-
|
|
88
|
+
h.displayName = "SegmentedControl";
|
|
84
89
|
//#endregion
|
|
85
|
-
export {
|
|
90
|
+
export { h as SegmentedControl };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../_internal/useInlineFloating.cjs"),a=require("../../_internal/BaseListItem/BaseListItem.cjs"),o=require("../InputBase/InputBase.cjs"),s=require("../../../i18n/generated/form.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../_internal/useInlineFloating.cjs"),a=require("../../_internal/BaseListItem/BaseListItem.cjs"),o=require("../InputBase/InputBase.cjs"),s=require("../../../i18n/generated/form.cjs"),c=require("../FieldTemplate/FieldTemplate.cjs"),ee=require("../../_internal/HiddenFormValue.cjs"),te=require("../../_internal/mergeRefs.cjs"),l=require("./select.module.cjs"),u=require("./useSelect.cjs"),d=require("../../_internal/VisualUppercase.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("classnames");p=e.__toESM(p,1);let m=require("react/jsx-runtime");var h=(0,f.forwardRef)(({options:e=[],value:h,onChange:ne,placeholder:g,label:_,error:v,required:y,name:b,layout:re,className:ie,disabled:x=!1,defaultValue:ae,searchable:S=!1,searchPlaceholder:C,filterOption:w,grouped:T=!1,allowClear:E=!1,fullWidth:D=!1,intent:oe=`default`,id:se,noOptionsFoundLabel:ce,width:le,styles:O,asChild:ue=!1,children:de,...fe},k)=>{let{t:pe}=n.useWimTranslation(s.formNs),me=(0,f.useId)(),A=se||`wim-select-${me}`,j=_?`${A}-label`:void 0,M=v?`${A}-error`:void 0,N=`${A}-list`,P=`${A}-trigger`,F=v?`danger`:oe,{isOpen:I,searchValue:L,setSearchValue:R,focusedIndex:z,setFocusedIndex:B,isKeyboardNavigating:he,setIsKeyboardNavigating:ge,containerRef:V,triggerRef:_e,searchInputRef:ve,listItemsRef:H,currentValue:U,filteredOptions:W,selectedOption:G,focusedOption:K,handleToggle:ye,handleSelect:q,handleClear:be,handleKeyDown:J,resetToDefault:xe}=u.useSelect({options:e,value:h,onChange:ne,defaultValue:ae,searchable:S,grouped:T,disabled:x,filterOption:w}),{setReference:Y,setFloating:Se,floatingProps:Ce}=i.useInlineFloating({open:I&&!x}),X=(0,f.useMemo)(()=>te.mergeRefs(V,k,Y),[V,k,Y]),we=()=>{let t=0;return T&&e.length>0&&`options`in e[0]?e.map((e,n)=>{let r=e.options.filter(e=>e.type===`separator`||!L||(w||((e,t)=>(typeof e.label==`string`?e.label:``).toLowerCase().includes(t.toLowerCase())))(e,L));return r.length===0?null:(0,m.jsxs)(f.default.Fragment,{children:[(0,m.jsx)(`li`,{className:(0,p.default)(l.default.groupLabel,O?.groupLabel),"data-part":`group-label`,role:`presentation`,children:(0,m.jsx)(d.VisualUppercase,{children:e.label})}),r.map((e,r)=>{let i=t++;if(e.type===`separator`)return(0,m.jsx)(`li`,{className:(0,p.default)(l.default.separator,O?.separator),"data-part":`separator`,role:`presentation`},`sep-${n}-${r}`);let o=i===z,s=U===e.value,c=`wim-select-option-${A}-${e.value}`;return(0,m.jsx)(a.BaseListItem,{asChild:!0,id:c,ref:e=>{H.current[i]=e},active:o,disabled:e.disabled,className:(0,p.default)(l.default.option,s&&l.default.selected,O?.option),onClick:t=>{t.stopPropagation(),q(e)},onMouseEnter:()=>B(i),role:`option`,"data-part":`option`,"aria-selected":s,children:(0,m.jsx)(`li`,{children:e.label})},e.value)})]},n)}):W.map((e,n)=>{let r=t++;if(e.type===`separator`)return(0,m.jsx)(`li`,{className:(0,p.default)(l.default.separator,O?.separator),"data-part":`separator`,role:`presentation`},`sep-${n}`);let i=r===z,o=U===e.value,s=`wim-select-option-${A}-${e.value}`;return(0,m.jsx)(a.BaseListItem,{asChild:!0,id:s,ref:e=>{H.current[r]=e},active:i,disabled:e.disabled,className:(0,p.default)(l.default.option,o&&l.default.selected,O?.option),onClick:t=>{t.stopPropagation(),q(e)},onMouseEnter:()=>B(r),role:`option`,"data-part":`option`,"aria-selected":o,children:(0,m.jsx)(`li`,{children:e.label})},e.value)})},Z=K&&K.type!==`separator`?`wim-select-option-${A}-${K.value}`:void 0,{"aria-label":Q,"aria-labelledby":$,"aria-describedby":Te,...Ee}=fe;return(0,m.jsx)(c.FieldTemplate,{label:_,error:v,required:y,layout:re,labelId:j,htmlFor:P,errorId:M,className:ie,children:(0,m.jsxs)(ue?t.Root:`div`,{className:(0,p.default)(`wim-select`,l.default.root,D&&l.default.fullWidth,O?.root),ref:X,onMouseMove:()=>ge(!1),"data-keyboard-nav":he,...Ee,children:[(0,m.jsx)(o.InputBase,{disabled:x,allowClear:E,hasValue:!!U,onClear:be,intent:F,rightIcons:[{name:`ChevronDownIcon`,rotated:I}],width:le,fullWidth:D,styles:O?.inputBase,children:(0,m.jsx)(`div`,{id:P,className:(0,p.default)(l.default.trigger,I&&l.default.open,x&&l.default.disabled,O?.trigger),onClick:ye,onKeyDown:J,tabIndex:x?-1:0,role:`combobox`,"data-part":`trigger`,"aria-expanded":I,"aria-haspopup":`listbox`,"aria-controls":I?N:void 0,"aria-disabled":x,"aria-labelledby":j||$,"aria-label":_?void 0:typeof Q==`string`?Q:typeof g==`string`?g:void 0,"aria-describedby":M||Te,"aria-required":y?`true`:void 0,"aria-invalid":F===`danger`?`true`:`false`,"aria-activedescendant":I?Z:void 0,ref:_e,children:(0,m.jsx)(`div`,{className:(0,p.default)(l.default.value,!G&&l.default.placeholder,O?.value),"data-part":`value`,children:G?G.label:g})})}),(0,m.jsxs)(r.Transition,{show:I&&!x,preset:`fade`,className:(0,p.default)(l.default.dropdown,O?.dropdown),"data-part":`dropdown`,ref:Se,...Ce,children:[S&&(0,m.jsx)(`div`,{className:(0,p.default)(l.default.search,O?.search),"data-part":`search`,children:(0,m.jsx)(`input`,{ref:ve,type:`text`,className:(0,p.default)(l.default.searchInput,O?.searchInput),"data-part":`search-input`,placeholder:C,value:L,onChange:e=>{R(e.target.value),B(-1)},onClick:e=>e.stopPropagation(),onKeyDown:J,"aria-label":C,"aria-controls":N,"aria-activedescendant":Z})}),(0,m.jsx)(`ul`,{id:N,className:(0,p.default)(l.default.list,O?.list),"data-part":`list`,role:`listbox`,"aria-labelledby":_?j:$||void 0,children:W.length===0?(0,m.jsx)(`li`,{className:(0,p.default)(l.default.empty,O?.empty),"data-part":`empty`,role:`option`,"aria-selected":`false`,children:ce??pe(`select.no_options`)}):we()})]}),(0,m.jsx)(ee.HiddenFormValue,{name:b,value:U,disabled:x,onReset:xe}),(0,m.jsx)(t.Slottable,{children:de})]})})});h.displayName=`Select`,exports.Select=h,exports.default=h;
|
|
@@ -47,6 +47,10 @@ export interface SelectProps extends Omit<React.ComponentPropsWithoutRef<"div">,
|
|
|
47
47
|
error?: string;
|
|
48
48
|
/** Whether to show the required indicator */
|
|
49
49
|
required?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Name submitted with a native `<form>`. The selected value is sent as a hidden input, and a form reset restores `defaultValue` when uncontrolled.
|
|
52
|
+
*/
|
|
53
|
+
name?: string;
|
|
50
54
|
/** Layout direction of label and field */
|
|
51
55
|
layout?: "vertical" | "horizontal";
|
|
52
56
|
/** Label shown when no options match the search */
|
|
@@ -7,189 +7,196 @@ import { BaseListItem as a } from "../../_internal/BaseListItem/BaseListItem.js"
|
|
|
7
7
|
import { InputBase as o } from "../InputBase/InputBase.js";
|
|
8
8
|
import { formNs as s } from "../../../i18n/generated/form.js";
|
|
9
9
|
import { FieldTemplate as c } from "../FieldTemplate/FieldTemplate.js";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import { HiddenFormValue as ee } from "../../_internal/HiddenFormValue.js";
|
|
11
|
+
import { mergeRefs as te } from "../../_internal/mergeRefs.js";
|
|
12
|
+
import l from "./select.module.js";
|
|
13
|
+
import { useSelect as u } from "./useSelect.js";
|
|
13
14
|
import { VisualUppercase as d } from "../../_internal/VisualUppercase.js";
|
|
14
|
-
import
|
|
15
|
+
import ne, { forwardRef as f, useId as re, useMemo as ie } from "react";
|
|
15
16
|
import p from "classnames";
|
|
16
17
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
17
18
|
//#region src/components/form/Select/Select.tsx
|
|
18
|
-
var g = f(({ options: f = [], value: g, onChange:
|
|
19
|
-
let { t:
|
|
19
|
+
var g = f(({ options: f = [], value: g, onChange: ae, placeholder: _, label: v, error: y, required: b, name: oe, layout: se, className: x, disabled: S = !1, defaultValue: C, searchable: w = !1, searchPlaceholder: T, filterOption: E, grouped: D = !1, allowClear: ce = !1, fullWidth: O = !1, intent: le = "default", id: ue, noOptionsFoundLabel: de, width: fe, styles: k, asChild: pe = !1, children: me, ...he }, A) => {
|
|
20
|
+
let { t: ge } = n(s), _e = re(), j = ue || `wim-select-${_e}`, M = v ? `${j}-label` : void 0, N = y ? `${j}-error` : void 0, P = `${j}-list`, F = `${j}-trigger`, I = y ? "danger" : le, { isOpen: L, searchValue: R, setSearchValue: ve, focusedIndex: z, setFocusedIndex: B, isKeyboardNavigating: ye, setIsKeyboardNavigating: be, containerRef: V, triggerRef: xe, searchInputRef: Se, listItemsRef: H, currentValue: U, filteredOptions: W, selectedOption: G, focusedOption: K, handleToggle: Ce, handleSelect: q, handleClear: we, handleKeyDown: J, resetToDefault: Y } = u({
|
|
20
21
|
options: f,
|
|
21
22
|
value: g,
|
|
22
|
-
onChange:
|
|
23
|
-
defaultValue:
|
|
23
|
+
onChange: ae,
|
|
24
|
+
defaultValue: C,
|
|
24
25
|
searchable: w,
|
|
25
26
|
grouped: D,
|
|
26
|
-
disabled:
|
|
27
|
+
disabled: S,
|
|
27
28
|
filterOption: E
|
|
28
|
-
}), { setReference: X, setFloating:
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
}), { setReference: X, setFloating: Te, floatingProps: Ee } = i({ open: L && !S }), De = ie(() => te(V, A, X), [
|
|
30
|
+
V,
|
|
31
|
+
A,
|
|
31
32
|
X
|
|
32
|
-
]),
|
|
33
|
+
]), Oe = () => {
|
|
33
34
|
let e = 0;
|
|
34
35
|
return D && f.length > 0 && "options" in f[0] ? f.map((t, n) => {
|
|
35
|
-
let r = t.options.filter((e) => e.type === "separator" || !
|
|
36
|
-
return r.length === 0 ? null : /* @__PURE__ */ h(
|
|
37
|
-
className: p(
|
|
36
|
+
let r = t.options.filter((e) => e.type === "separator" || !R || (E || ((e, t) => (typeof e.label == "string" ? e.label : "").toLowerCase().includes(t.toLowerCase())))(e, R));
|
|
37
|
+
return r.length === 0 ? null : /* @__PURE__ */ h(ne.Fragment, { children: [/* @__PURE__ */ m("li", {
|
|
38
|
+
className: p(l.groupLabel, k?.groupLabel),
|
|
38
39
|
"data-part": "group-label",
|
|
39
40
|
role: "presentation",
|
|
40
41
|
children: /* @__PURE__ */ m(d, { children: t.label })
|
|
41
42
|
}), r.map((t, r) => {
|
|
42
43
|
let i = e++;
|
|
43
44
|
if (t.type === "separator") return /* @__PURE__ */ m("li", {
|
|
44
|
-
className: p(
|
|
45
|
+
className: p(l.separator, k?.separator),
|
|
45
46
|
"data-part": "separator",
|
|
46
47
|
role: "presentation"
|
|
47
48
|
}, `sep-${n}-${r}`);
|
|
48
|
-
let o = i ===
|
|
49
|
+
let o = i === z, s = U === t.value, c = `wim-select-option-${j}-${t.value}`;
|
|
49
50
|
return /* @__PURE__ */ m(a, {
|
|
50
51
|
asChild: !0,
|
|
51
52
|
id: c,
|
|
52
53
|
ref: (e) => {
|
|
53
|
-
|
|
54
|
+
H.current[i] = e;
|
|
54
55
|
},
|
|
55
56
|
active: o,
|
|
56
57
|
disabled: t.disabled,
|
|
57
|
-
className: p(
|
|
58
|
+
className: p(l.option, s && l.selected, k?.option),
|
|
58
59
|
onClick: (e) => {
|
|
59
|
-
e.stopPropagation(),
|
|
60
|
+
e.stopPropagation(), q(t);
|
|
60
61
|
},
|
|
61
|
-
onMouseEnter: () =>
|
|
62
|
+
onMouseEnter: () => B(i),
|
|
62
63
|
role: "option",
|
|
63
64
|
"data-part": "option",
|
|
64
65
|
"aria-selected": s,
|
|
65
66
|
children: /* @__PURE__ */ m("li", { children: t.label })
|
|
66
67
|
}, t.value);
|
|
67
68
|
})] }, n);
|
|
68
|
-
}) :
|
|
69
|
+
}) : W.map((t, n) => {
|
|
69
70
|
let r = e++;
|
|
70
71
|
if (t.type === "separator") return /* @__PURE__ */ m("li", {
|
|
71
|
-
className: p(
|
|
72
|
+
className: p(l.separator, k?.separator),
|
|
72
73
|
"data-part": "separator",
|
|
73
74
|
role: "presentation"
|
|
74
75
|
}, `sep-${n}`);
|
|
75
|
-
let i = r ===
|
|
76
|
+
let i = r === z, o = U === t.value, s = `wim-select-option-${j}-${t.value}`;
|
|
76
77
|
return /* @__PURE__ */ m(a, {
|
|
77
78
|
asChild: !0,
|
|
78
79
|
id: s,
|
|
79
80
|
ref: (e) => {
|
|
80
|
-
|
|
81
|
+
H.current[r] = e;
|
|
81
82
|
},
|
|
82
83
|
active: i,
|
|
83
84
|
disabled: t.disabled,
|
|
84
|
-
className: p(
|
|
85
|
+
className: p(l.option, o && l.selected, k?.option),
|
|
85
86
|
onClick: (e) => {
|
|
86
|
-
e.stopPropagation(),
|
|
87
|
+
e.stopPropagation(), q(t);
|
|
87
88
|
},
|
|
88
|
-
onMouseEnter: () =>
|
|
89
|
+
onMouseEnter: () => B(r),
|
|
89
90
|
role: "option",
|
|
90
91
|
"data-part": "option",
|
|
91
92
|
"aria-selected": o,
|
|
92
93
|
children: /* @__PURE__ */ m("li", { children: t.label })
|
|
93
94
|
}, t.value);
|
|
94
95
|
});
|
|
95
|
-
}, Z =
|
|
96
|
+
}, Z = K && K.type !== "separator" ? `wim-select-option-${j}-${K.value}` : void 0, { "aria-label": Q, "aria-labelledby": $, "aria-describedby": ke, ...Ae } = he;
|
|
96
97
|
return /* @__PURE__ */ m(c, {
|
|
97
98
|
label: v,
|
|
98
99
|
error: y,
|
|
99
100
|
required: b,
|
|
100
|
-
layout:
|
|
101
|
-
labelId:
|
|
102
|
-
htmlFor:
|
|
103
|
-
errorId:
|
|
104
|
-
className:
|
|
105
|
-
children: /* @__PURE__ */ h(
|
|
106
|
-
className: p("wim-select",
|
|
107
|
-
ref:
|
|
108
|
-
onMouseMove: () =>
|
|
109
|
-
"data-keyboard-nav":
|
|
110
|
-
...
|
|
101
|
+
layout: se,
|
|
102
|
+
labelId: M,
|
|
103
|
+
htmlFor: F,
|
|
104
|
+
errorId: N,
|
|
105
|
+
className: x,
|
|
106
|
+
children: /* @__PURE__ */ h(pe ? e : "div", {
|
|
107
|
+
className: p("wim-select", l.root, O && l.fullWidth, k?.root),
|
|
108
|
+
ref: De,
|
|
109
|
+
onMouseMove: () => be(!1),
|
|
110
|
+
"data-keyboard-nav": ye,
|
|
111
|
+
...Ae,
|
|
111
112
|
children: [
|
|
112
113
|
/* @__PURE__ */ m(o, {
|
|
113
|
-
disabled:
|
|
114
|
-
allowClear:
|
|
115
|
-
hasValue: !!
|
|
116
|
-
onClear:
|
|
117
|
-
intent:
|
|
114
|
+
disabled: S,
|
|
115
|
+
allowClear: ce,
|
|
116
|
+
hasValue: !!U,
|
|
117
|
+
onClear: we,
|
|
118
|
+
intent: I,
|
|
118
119
|
rightIcons: [{
|
|
119
120
|
name: "ChevronDownIcon",
|
|
120
|
-
rotated:
|
|
121
|
+
rotated: L
|
|
121
122
|
}],
|
|
122
|
-
width:
|
|
123
|
-
fullWidth:
|
|
124
|
-
styles:
|
|
123
|
+
width: fe,
|
|
124
|
+
fullWidth: O,
|
|
125
|
+
styles: k?.inputBase,
|
|
125
126
|
children: /* @__PURE__ */ m("div", {
|
|
126
|
-
id:
|
|
127
|
-
className: p(
|
|
128
|
-
onClick:
|
|
129
|
-
onKeyDown:
|
|
130
|
-
tabIndex:
|
|
127
|
+
id: F,
|
|
128
|
+
className: p(l.trigger, L && l.open, S && l.disabled, k?.trigger),
|
|
129
|
+
onClick: Ce,
|
|
130
|
+
onKeyDown: J,
|
|
131
|
+
tabIndex: S ? -1 : 0,
|
|
131
132
|
role: "combobox",
|
|
132
133
|
"data-part": "trigger",
|
|
133
|
-
"aria-expanded":
|
|
134
|
+
"aria-expanded": L,
|
|
134
135
|
"aria-haspopup": "listbox",
|
|
135
|
-
"aria-controls":
|
|
136
|
-
"aria-disabled":
|
|
137
|
-
"aria-labelledby":
|
|
136
|
+
"aria-controls": L ? P : void 0,
|
|
137
|
+
"aria-disabled": S,
|
|
138
|
+
"aria-labelledby": M || $,
|
|
138
139
|
"aria-label": v ? void 0 : typeof Q == "string" ? Q : typeof _ == "string" ? _ : void 0,
|
|
139
|
-
"aria-describedby":
|
|
140
|
+
"aria-describedby": N || ke,
|
|
140
141
|
"aria-required": b ? "true" : void 0,
|
|
141
|
-
"aria-invalid":
|
|
142
|
-
"aria-activedescendant":
|
|
143
|
-
ref:
|
|
142
|
+
"aria-invalid": I === "danger" ? "true" : "false",
|
|
143
|
+
"aria-activedescendant": L ? Z : void 0,
|
|
144
|
+
ref: xe,
|
|
144
145
|
children: /* @__PURE__ */ m("div", {
|
|
145
|
-
className: p(
|
|
146
|
+
className: p(l.value, !G && l.placeholder, k?.value),
|
|
146
147
|
"data-part": "value",
|
|
147
|
-
children:
|
|
148
|
+
children: G ? G.label : _
|
|
148
149
|
})
|
|
149
150
|
})
|
|
150
151
|
}),
|
|
151
152
|
/* @__PURE__ */ h(r, {
|
|
152
|
-
show:
|
|
153
|
+
show: L && !S,
|
|
153
154
|
preset: "fade",
|
|
154
|
-
className: p(
|
|
155
|
+
className: p(l.dropdown, k?.dropdown),
|
|
155
156
|
"data-part": "dropdown",
|
|
156
|
-
ref:
|
|
157
|
-
...
|
|
157
|
+
ref: Te,
|
|
158
|
+
...Ee,
|
|
158
159
|
children: [w && /* @__PURE__ */ m("div", {
|
|
159
|
-
className: p(
|
|
160
|
+
className: p(l.search, k?.search),
|
|
160
161
|
"data-part": "search",
|
|
161
162
|
children: /* @__PURE__ */ m("input", {
|
|
162
|
-
ref:
|
|
163
|
+
ref: Se,
|
|
163
164
|
type: "text",
|
|
164
|
-
className: p(
|
|
165
|
+
className: p(l.searchInput, k?.searchInput),
|
|
165
166
|
"data-part": "search-input",
|
|
166
167
|
placeholder: T,
|
|
167
|
-
value:
|
|
168
|
+
value: R,
|
|
168
169
|
onChange: (e) => {
|
|
169
|
-
|
|
170
|
+
ve(e.target.value), B(-1);
|
|
170
171
|
},
|
|
171
172
|
onClick: (e) => e.stopPropagation(),
|
|
172
|
-
onKeyDown:
|
|
173
|
+
onKeyDown: J,
|
|
173
174
|
"aria-label": T,
|
|
174
|
-
"aria-controls":
|
|
175
|
+
"aria-controls": P,
|
|
175
176
|
"aria-activedescendant": Z
|
|
176
177
|
})
|
|
177
178
|
}), /* @__PURE__ */ m("ul", {
|
|
178
|
-
id:
|
|
179
|
-
className: p(
|
|
179
|
+
id: P,
|
|
180
|
+
className: p(l.list, k?.list),
|
|
180
181
|
"data-part": "list",
|
|
181
182
|
role: "listbox",
|
|
182
|
-
"aria-labelledby": v ?
|
|
183
|
-
children:
|
|
184
|
-
className: p(
|
|
183
|
+
"aria-labelledby": v ? M : $ || void 0,
|
|
184
|
+
children: W.length === 0 ? /* @__PURE__ */ m("li", {
|
|
185
|
+
className: p(l.empty, k?.empty),
|
|
185
186
|
"data-part": "empty",
|
|
186
187
|
role: "option",
|
|
187
188
|
"aria-selected": "false",
|
|
188
|
-
children:
|
|
189
|
-
}) :
|
|
189
|
+
children: de ?? ge("select.no_options")
|
|
190
|
+
}) : Oe()
|
|
190
191
|
})]
|
|
191
192
|
}),
|
|
192
|
-
/* @__PURE__ */ m(
|
|
193
|
+
/* @__PURE__ */ m(ee, {
|
|
194
|
+
name: oe,
|
|
195
|
+
value: U,
|
|
196
|
+
disabled: S,
|
|
197
|
+
onReset: Y
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ m(t, { children: me })
|
|
193
200
|
]
|
|
194
201
|
})
|
|
195
202
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../_internal/rovingIndex.cjs"),t=require("../../_internal/typeahead.cjs");let n=require("react");function r({options:r,value:i,onChange:a,defaultValue:o,searchable:s,grouped:c,disabled:l,filterOption:u}){let[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(o||``),[h,g]=(0,n.useState)(``),[_,v]=(0,n.useState)(-1),[y,b]=(0,n.useState)(!1),x=(0,n.useRef)(null),S=(0,n.useRef)(null),C=(0,n.useRef)(null),w=(0,n.useRef)([]),T=i!==void 0,E=T?i:p,D=(0,n.useMemo)(()=>c&&r.length>0&&`options`in r[0]?r.flatMap(e=>e.options):r,[r,c]),O=(0,n.useMemo)(()=>{if(!h)return D;let e=u||((e,t)=>{if(e.type===`separator`)return!1;let n=typeof e.label==`string`?e.label:``,r=typeof e.value==`string`?e.value:``,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.toLowerCase().includes(i)});return D.filter(t=>e(t,h))},[D,h,u]),k=D.find(e=>e.value===E);(0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(f(!1),g(``),v(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,n.useEffect)(()=>{d&&s&&C.current&&C.current.focus()},[d,s]),(0,n.useEffect)(()=>{_>=0&&w.current[_]&&w.current[_]?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[_]);let A=()=>{l||(f(!d),d||(g(``),v(-1)))},j=e=>{e.type===`separator`||e.disabled||(!T&&e.value!==void 0&&m(e.value),a&&e.value!==void 0&&a(e.value),f(!1),g(``),v(-1),S.current?.focus())},M=()=>{l||(T||m(``),a?.(``))},N=e=>!!O[e]?.disabled||O[e]?.type===`separator`,
|
|
2
|
+
const e=require("../../_internal/rovingIndex.cjs"),t=require("../../_internal/typeahead.cjs");let n=require("react");function r({options:r,value:i,onChange:a,defaultValue:o,searchable:s,grouped:c,disabled:l,filterOption:u}){let[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(o||``),[h,g]=(0,n.useState)(``),[_,v]=(0,n.useState)(-1),[y,b]=(0,n.useState)(!1),x=(0,n.useRef)(null),S=(0,n.useRef)(null),C=(0,n.useRef)(null),w=(0,n.useRef)([]),T=i!==void 0,E=T?i:p,D=(0,n.useMemo)(()=>c&&r.length>0&&`options`in r[0]?r.flatMap(e=>e.options):r,[r,c]),O=(0,n.useMemo)(()=>{if(!h)return D;let e=u||((e,t)=>{if(e.type===`separator`)return!1;let n=typeof e.label==`string`?e.label:``,r=typeof e.value==`string`?e.value:``,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.toLowerCase().includes(i)});return D.filter(t=>e(t,h))},[D,h,u]),k=D.find(e=>e.value===E);(0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(f(!1),g(``),v(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,n.useEffect)(()=>{d&&s&&C.current&&C.current.focus()},[d,s]),(0,n.useEffect)(()=>{_>=0&&w.current[_]&&w.current[_]?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[_]);let A=()=>{l||(f(!d),d||(g(``),v(-1)))},j=e=>{e.type===`separator`||e.disabled||(!T&&e.value!==void 0&&m(e.value),a&&e.value!==void 0&&a(e.value),f(!1),g(``),v(-1),S.current?.focus())},M=()=>{l||(T||m(``),a?.(``))},N=()=>{T||m(o||``)},P=e=>!!O[e]?.disabled||O[e]?.type===`separator`,F=t.useTypeahead();return{isOpen:d,searchValue:h,setSearchValue:g,focusedIndex:_,setFocusedIndex:v,isKeyboardNavigating:y,setIsKeyboardNavigating:b,containerRef:x,triggerRef:S,searchInputRef:C,listItemsRef:w,currentValue:E,flatOptions:D,filteredOptions:O,selectedOption:k,focusedOption:_>=0?O[_]:null,handleToggle:A,handleSelect:j,handleClear:M,handleKeyDown:n=>{if(b(!0),!l){if(!s&&t.isTypeaheadKey(n,F.typing())){n.preventDefault();let e=t.findTypeaheadIndex({query:F.push(n.key),current:d?_:-1,count:O.length,getText:e=>{let t=O[e];return typeof t?.label==`string`?t.label:String(t?.value??``)},isDisabled:P});e>=0&&(f(!0),v(e))}else if(d&&e.isRovingKey(n.key,`vertical`)){n.preventDefault();let t=e.getRovingIndex({key:n.key,current:_,count:O.length,orientation:`vertical`,isDisabled:P});t!==null&&v(t)}else switch(n.key){case`Enter`:case` `:d?_>=0&&O[_]&&j(O[_]):f(!0),n.preventDefault();break;case`Escape`:if(!d)break;f(!1),g(``),v(-1),S.current?.focus(),n.preventDefault();break;case`Tab`:d&&(f(!1),g(``),v(-1));break;case`ArrowDown`:n.preventDefault(),f(!0)}}},resetToDefault:N}}exports.useSelect=r;
|
|
@@ -36,7 +36,9 @@ function l({ options: l, value: u, onChange: d, defaultValue: f, searchable: p,
|
|
|
36
36
|
e.type === "separator" || e.disabled || (!j && e.value !== void 0 && b(e.value), d && e.value !== void 0 && d(e.value), v(!1), S(""), w(-1), O.current?.focus());
|
|
37
37
|
}, R = () => {
|
|
38
38
|
h || (j || b(""), d?.(""));
|
|
39
|
-
}, z = (
|
|
39
|
+
}, z = () => {
|
|
40
|
+
j || b(f || "");
|
|
41
|
+
}, B = (e) => !!P[e]?.disabled || P[e]?.type === "separator", V = i();
|
|
40
42
|
return {
|
|
41
43
|
isOpen: _,
|
|
42
44
|
searchValue: x,
|
|
@@ -59,17 +61,17 @@ function l({ options: l, value: u, onChange: d, defaultValue: f, searchable: p,
|
|
|
59
61
|
handleClear: R,
|
|
60
62
|
handleKeyDown: (i) => {
|
|
61
63
|
if (E(!0), !h) {
|
|
62
|
-
if (!p && r(i,
|
|
64
|
+
if (!p && r(i, V.typing())) {
|
|
63
65
|
i.preventDefault();
|
|
64
66
|
let e = n({
|
|
65
|
-
query:
|
|
67
|
+
query: V.push(i.key),
|
|
66
68
|
current: _ ? C : -1,
|
|
67
69
|
count: P.length,
|
|
68
70
|
getText: (e) => {
|
|
69
71
|
let t = P[e];
|
|
70
72
|
return typeof t?.label == "string" ? t.label : String(t?.value ?? "");
|
|
71
73
|
},
|
|
72
|
-
isDisabled:
|
|
74
|
+
isDisabled: B
|
|
73
75
|
});
|
|
74
76
|
e >= 0 && (v(!0), w(e));
|
|
75
77
|
} else if (_ && t(i.key, "vertical")) {
|
|
@@ -79,7 +81,7 @@ function l({ options: l, value: u, onChange: d, defaultValue: f, searchable: p,
|
|
|
79
81
|
current: C,
|
|
80
82
|
count: P.length,
|
|
81
83
|
orientation: "vertical",
|
|
82
|
-
isDisabled:
|
|
84
|
+
isDisabled: B
|
|
83
85
|
});
|
|
84
86
|
t !== null && w(t);
|
|
85
87
|
} else switch (i.key) {
|
|
@@ -97,7 +99,8 @@ function l({ options: l, value: u, onChange: d, defaultValue: f, searchable: p,
|
|
|
97
99
|
case "ArrowDown": i.preventDefault(), v(!0);
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
}
|
|
102
|
+
},
|
|
103
|
+
resetToDefault: z
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
106
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/composeEventHandlers.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("../../../utilities/slider-utils.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/composeEventHandlers.cjs"),r=require("../FieldTemplate/FieldTemplate.cjs"),i=require("../../_internal/HiddenFormValue.cjs"),a=require("../../../utilities/slider-utils.cjs"),o=require("./slider.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(0,s.forwardRef)(({value:e,defaultValue:u=0,min:d=0,max:f=100,step:p=1,disabled:m=!1,onChange:h,onAfterChange:g,className:_,name:v,label:y,error:b,required:x,layout:S=`vertical`,id:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E,asChild:D=!1,styles:O,children:k,...A},j)=>{let M=e!==void 0,[N,P]=(0,s.useState)(u),F=M?e:N,I=(0,s.useRef)(null),L=(0,s.useRef)(null),R=(0,s.useRef)(null),z=(0,s.useRef)(null);i.useFormReset(z,()=>{M||P(u)});let B=(0,s.useRef)(!1),V=(0,s.useRef)(F),H=(0,s.useId)(),U=C||H,W=`wim-slider-label-${U}`,G=`wim-slider-error-${U}`,{calculateValue:K}=a.useSliderCommon(d,f,p),q=(0,s.useCallback)(e=>(e-d)/(f-d)*100,[d,f]),J=(0,s.useCallback)(e=>{let t=q(e);R.current&&(R.current.style.width=`${t}%`),L.current&&(L.current.style.left=`${t}%`,L.current.setAttribute(`aria-valuenow`,String(e))),z.current&&(z.current.value=String(e))},[q]);(0,s.useEffect)(()=>{B.current||J(F)},[F,J]);let Y=e=>{if(m)return;B.current=!0;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=K(t,I.current);V.current=n,J(n),h?.(n),e.preventDefault()},X=(0,s.useCallback)(e=>{if(!B.current||m)return;let t=`touches`in e?e.touches[0].clientX:e.clientX,n=K(t,I.current);V.current=n,J(n),h?.(n)},[m,K,h,J]),Z=(0,s.useCallback)(()=>{if(B.current){B.current=!1;let e=V.current;M||P(e),g?.(e)}},[M,g]);(0,s.useEffect)(()=>(document.addEventListener(`mousemove`,X),document.addEventListener(`mouseup`,Z),document.addEventListener(`touchmove`,X,{passive:!1}),document.addEventListener(`touchend`,Z),()=>{document.removeEventListener(`mousemove`,X),document.removeEventListener(`mouseup`,Z),document.removeEventListener(`touchmove`,X),document.removeEventListener(`touchend`,Z)}),[X,Z]);let Q=e=>{if(m)return;let t;if(e.key===`ArrowLeft`||e.key===`ArrowDown`)t=Math.max(d,F-p);else if(e.key===`ArrowRight`||e.key===`ArrowUp`)t=Math.min(f,F+p);else if(e.key===`PageDown`)t=Math.max(d,F-a.largeStepOf(d,f,p));else if(e.key===`PageUp`)t=Math.min(f,F+a.largeStepOf(d,f,p));else if(e.key===`Home`)t=d;else if(e.key===`End`)t=f;else return;M||P(t),h?.(t),e.preventDefault()},$=q(F);return(0,l.jsx)(r.FieldTemplate,{label:y,error:b,required:x,layout:S,labelId:W,errorId:G,className:_,styles:O,children:(0,l.jsxs)(D?t.Root:`div`,{role:`presentation`,className:(0,c.default)(`wim-slider`,o.default.root,m&&o.default.disabled,b&&o.default.danger),ref:j,...A,onMouseDown:n.composeEventHandlers(A.onMouseDown,Y),onTouchStart:n.composeEventHandlers(A.onTouchStart,Y),children:[(0,l.jsxs)(`div`,{className:o.default.trackContainer,ref:I,children:[(0,l.jsx)(`div`,{ref:R,className:o.default.track,style:{width:`${$}%`}}),(0,l.jsx)(`div`,{ref:L,className:o.default.thumb,style:{left:`${$}%`},role:`slider`,"aria-valuemin":d,"aria-valuemax":f,"aria-valuenow":F,"aria-disabled":m,"aria-labelledby":y?W:T,"aria-label":y?void 0:w,"aria-describedby":[E,b?G:void 0].filter(Boolean).join(` `)||void 0,"aria-invalid":b?!0:void 0,tabIndex:m?-1:0,onKeyDown:Q})]}),(0,l.jsx)(`input`,{ref:z,type:`hidden`,name:v,value:F}),D?(0,l.jsx)(t.Slottable,{children:k}):null]})})});u.displayName=`Slider`,exports.Slider=u,exports.default=u;
|