jaguar-form 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +112 -2
- package/dist/Control-fWNQOzmu.js +47 -0
- package/dist/Select-DUPUVAXB.js +250 -0
- package/dist/TreeSelect-CBxoAWvp.js +435 -0
- package/dist/core.js +1 -0
- package/dist/date-time.js +1 -0
- package/dist/form-D0JeWv6M.js +407 -0
- package/dist/form.js +3 -0
- package/dist/icons-KmLuj5v3.js +63 -0
- package/dist/image-upload-CkX8vlWK.js +638 -0
- package/dist/image-upload.js +1 -0
- package/dist/index.js +12 -0
- package/dist/input.js +1 -0
- package/dist/inputs-DNNFmj2K.js +402 -0
- package/dist/locale/ar-SA.js +68 -0
- package/dist/locale/de-DE.js +68 -0
- package/dist/locale/en-US.js +1 -0
- package/dist/locale/es-ES.js +68 -0
- package/dist/locale/fr-FR.js +68 -0
- package/dist/locale/it-IT.js +68 -0
- package/dist/locale/ja-JP.js +68 -0
- package/dist/locale/ko-KR.js +68 -0
- package/dist/locale/load.js +21 -0
- package/dist/locale/nl-NL.js +68 -0
- package/dist/locale/pl-PL.js +68 -0
- package/dist/locale/pt-PT.js +68 -0
- package/dist/locale/ru-RU.js +68 -0
- package/dist/locale/zh-CN.js +1 -0
- package/dist/locale/zh-TW.js +68 -0
- package/dist/locale-yHkdw2xz.js +188 -0
- package/dist/pickers-CBW5Lzgr.js +629 -0
- package/dist/select.js +1 -0
- package/dist/selection-9OQvyjyD.js +135 -0
- package/dist/slider-BwDcSnnI.js +244 -0
- package/dist/slider.js +1 -0
- package/dist/store-DmlIFdPW.js +549 -0
- package/dist/style.css +2 -0
- package/dist/tree-select.js +1 -0
- package/dist/types/components/date-time/CalendarPanel.d.ts +17 -0
- package/dist/types/components/date-time/Picker.d.ts +7 -0
- package/dist/types/components/date-time/TimePanel.d.ts +6 -0
- package/dist/types/components/date-time/types.d.ts +24 -0
- package/dist/types/components/image-upload/ManagedImageUpload.d.ts +18 -0
- package/dist/types/components/image-upload/index.d.ts +21 -0
- package/dist/types/components/image-upload/sorting.d.ts +22 -0
- package/dist/types/components/image-upload/upload.d.ts +29 -0
- package/dist/types/components/image-upload/validation.d.ts +16 -0
- package/dist/types/components/inputs.d.ts +72 -0
- package/dist/types/components/pickers.d.ts +12 -0
- package/dist/types/components/select/Select.d.ts +4 -0
- package/dist/types/components/select/TreeSelect.d.ts +7 -0
- package/dist/types/components/select/types.d.ts +38 -0
- package/dist/types/components/select/useSelection.d.ts +16 -0
- package/dist/types/components/select.d.ts +4 -0
- package/dist/types/components/slider/index.d.ts +24 -0
- package/dist/types/components/slider/math.d.ts +12 -0
- package/dist/types/config/index.d.ts +32 -0
- package/dist/types/entries/core.d.ts +1 -0
- package/dist/types/entries/date-time.d.ts +1 -0
- package/dist/types/entries/form.d.ts +1 -0
- package/dist/types/entries/image-upload.d.ts +1 -0
- package/dist/types/entries/input.d.ts +2 -0
- package/dist/types/entries/select.d.ts +2 -0
- package/dist/types/entries/slider.d.ts +1 -0
- package/dist/types/entries/tree-select.d.ts +2 -0
- package/dist/types/form/adapter.d.ts +25 -0
- package/dist/types/form/array.d.ts +17 -0
- package/dist/types/form/index.d.ts +188 -0
- package/dist/types/form/path-access.d.ts +11 -0
- package/dist/types/form/paths.d.ts +7 -0
- package/dist/types/form/store.d.ts +69 -0
- package/dist/types/form/validation.d.ts +21 -0
- package/dist/types/icons/index.d.ts +42 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/locale/ar-SA.d.ts +3 -0
- package/dist/types/locale/de-DE.d.ts +3 -0
- package/dist/types/locale/en-US.d.ts +1 -0
- package/dist/types/locale/es-ES.d.ts +3 -0
- package/dist/types/locale/fr-FR.d.ts +3 -0
- package/dist/types/locale/index.d.ts +85 -0
- package/dist/types/locale/it-IT.d.ts +3 -0
- package/dist/types/locale/ja-JP.d.ts +3 -0
- package/dist/types/locale/ko-KR.d.ts +3 -0
- package/dist/types/locale/load.d.ts +20 -0
- package/dist/types/locale/nl-NL.d.ts +3 -0
- package/dist/types/locale/pl-PL.d.ts +3 -0
- package/dist/types/locale/pt-PT.d.ts +3 -0
- package/dist/types/locale/ru-RU.d.ts +3 -0
- package/dist/types/locale/zh-CN.d.ts +1 -0
- package/dist/types/locale/zh-TW.d.ts +3 -0
- package/dist/types/primitives/Control.d.ts +22 -0
- package/dist/types/primitives/Popup.d.ts +17 -0
- package/dist/types/primitives/selection.d.ts +37 -0
- package/dist/types/types.d.ts +39 -0
- package/dist/types/utils/date.d.ts +25 -0
- package/dist/types/utils/lazy-tree.d.ts +24 -0
- package/dist/types/utils/number.d.ts +3 -0
- package/dist/types/utils/picker-validation.d.ts +17 -0
- package/dist/types/utils/selection.d.ts +4 -0
- package/dist/types/utils/tree.d.ts +30 -0
- package/dist/types/utils/useControllable.d.ts +1 -0
- package/dist/useControllable-Dl8gno_5.js +82 -0
- package/dist/useSelection-B85KkHB9.js +348 -0
- package/package.json +171 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 React Form Engine contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,113 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Jaguar Form
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern React 19 form controls and schema-driven forms with validation, value adapters, internationalization and customizable themes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install jaguar-form
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
React and React DOM 19 are peer dependencies. The library is ESM with TypeScript declarations. Import the shared stylesheet once.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Form, Input, NumberInput, ConfigProvider, defineForm } from 'jaguar-form';
|
|
15
|
+
import 'jaguar-form/style.css';
|
|
16
|
+
|
|
17
|
+
const fields = defineForm([
|
|
18
|
+
{ name: 'name', label: 'Device name', type: 'input', required: true },
|
|
19
|
+
{
|
|
20
|
+
name: 'power', label: 'Power', type: 'number',
|
|
21
|
+
componentProps: { suffix: 'kW', precision: 2 },
|
|
22
|
+
transform: {
|
|
23
|
+
fromInput: value => Number(value) / 1000,
|
|
24
|
+
toOutput: value => Math.round(Number(value) * 1000),
|
|
25
|
+
},
|
|
26
|
+
rules: [{ required: true, type: 'number', min: 0, max: 10 }],
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export default function App() {
|
|
31
|
+
return (
|
|
32
|
+
<ConfigProvider theme="system">
|
|
33
|
+
<Form fields={fields} initialValues={{ name: 'Inverter', power: 5500 }}
|
|
34
|
+
onSubmit={values => console.log(values)} />
|
|
35
|
+
</ConfigProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- Standalone controls, schema-driven forms and JSX fields with custom components.
|
|
43
|
+
- Field subscriptions, sync/async validation, dependencies, nested paths and field-array helpers.
|
|
44
|
+
- Bidirectional API value conversion, dirty tracking and incremental output.
|
|
45
|
+
- Input, Password, SearchInput, NumberInput, Textarea, Button, IconButton, Checkbox, CheckboxGroup, RadioGroup, Switch, Segmented, Slider and RangeSlider.
|
|
46
|
+
- Select, MultiSelect and TreeSelect with search, virtualization, selection confirmation and lazy tree loading.
|
|
47
|
+
- Panel-only date/time, date/time range, month and year pickers.
|
|
48
|
+
- ImageUpload with local files or custom network transport, preview, progress, cancellation and retry.
|
|
49
|
+
- Light/dark/system themes, icon overrides, responsive popovers and mobile sheets, and 14 locale dictionaries.
|
|
50
|
+
|
|
51
|
+
## JSX forms
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Form, Input, useForm } from 'jaguar-form';
|
|
55
|
+
|
|
56
|
+
function Example() {
|
|
57
|
+
const form = useForm({ defaultValues: { email: '' } });
|
|
58
|
+
return <Form form={form} onSubmit={values => console.log(values)}>
|
|
59
|
+
<Form.Field name="email" label="Email" rules={[{ required: true }, { type: 'email' }]}>
|
|
60
|
+
<Input clearable />
|
|
61
|
+
</Form.Field>
|
|
62
|
+
</Form>;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use `initialValues` or `form.loadValues(raw)` for API payloads; `defaultValues` and `setValue` use editing values. `getValues()` reads editing values; `getOutputValues()` serializes them. Manual getters do not validate. `Form.onSubmit` validates before output conversion. Use `getChangedOutputValues()` for incremental updates; whole-form serializers require an explicit `toChangedOutput` for partial updates.
|
|
67
|
+
|
|
68
|
+
## Subpath imports and localization
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { Input } from 'jaguar-form/input';
|
|
72
|
+
import { Select, MultiSelect } from 'jaguar-form/select';
|
|
73
|
+
import { TreeSelect } from 'jaguar-form/tree-select';
|
|
74
|
+
import { Slider, RangeSlider } from 'jaguar-form/slider';
|
|
75
|
+
import { ImageUpload } from 'jaguar-form/image-upload';
|
|
76
|
+
import { DatePicker } from 'jaguar-form/date-time';
|
|
77
|
+
import { createFormStore } from 'jaguar-form/core';
|
|
78
|
+
import { ConfigProvider } from 'jaguar-form';
|
|
79
|
+
import zhCN from 'jaguar-form/locale/zh-CN';
|
|
80
|
+
import 'jaguar-form/style.css';
|
|
81
|
+
|
|
82
|
+
function LocalizedApp() {
|
|
83
|
+
return <ConfigProvider locale={zhCN}><Input clearable /></ConfigProvider>;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
English is the default. Import other locale dictionaries from `jaguar-form/locale/<code>` or use `loadLocale` from `jaguar-form/locale/load`. Supported dictionary codes: en-US, zh-CN, zh-TW, de-DE, fr-FR, es-ES, it-IT, pt-PT, pl-PL, nl-NL, ja-JP, ko-KR, ru-RU, ar-SA. Custom locale messages and external translation functions are supported.
|
|
88
|
+
|
|
89
|
+
## Behavior and compatibility
|
|
90
|
+
|
|
91
|
+
- Controlled controls use `value` and `onChange`; uncontrolled controls use `defaultValue`.
|
|
92
|
+
- Dates and times use local civil values; display formatting does not change the stored value. Duration constraints are in seconds.
|
|
93
|
+
- Nested field names are opt-in (`nested: true`). Array patches are atomic. Lazy tree cascade selection covers loaded leaves only.
|
|
94
|
+
- Upload file validation in the browser is not a replacement for server validation. Supply your own authenticated upload transport.
|
|
95
|
+
- Chromium regression coverage exists; full Safari/Firefox, RTL, screen-reader, visual and heap-retention testing is not claimed.
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
Node.js 20.19+ (20.x) or 22.12+ is required for the development tools.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install
|
|
103
|
+
npm run dev
|
|
104
|
+
npm run docs:dev
|
|
105
|
+
npx playwright install chromium
|
|
106
|
+
npm run release:check
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The release check includes dependency audits, syntax, core checks, TypeScript, Vitest, build, Chromium tests, documentation and package exports. See the source repository's `docs/` directory for guides and release instructions.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
MIT.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { i as e, s as t } from "./useControllable-Dl8gno_5.js";
|
|
2
|
+
import { t as n } from "./icons-KmLuj5v3.js";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
// src/primitives/Control.tsx
|
|
5
|
+
function a({ children: a, actions: o, prefix: s, suffix: c, prefixIcon: l, suffixIcon: u, size: d, variant: f, status: p, disabled: m, readOnly: h, className: g, style: _, "aria-invalid": v }) {
|
|
6
|
+
let y = e();
|
|
7
|
+
return /* @__PURE__ */ i("div", {
|
|
8
|
+
className: t("rfe-control", g),
|
|
9
|
+
style: _,
|
|
10
|
+
"data-size": d ?? y.size,
|
|
11
|
+
"data-variant": f ?? y.variant,
|
|
12
|
+
"data-status": v ? "error" : p ?? "default",
|
|
13
|
+
"data-disabled": m || void 0,
|
|
14
|
+
"data-readonly": h || void 0,
|
|
15
|
+
children: [
|
|
16
|
+
(l || s) && /* @__PURE__ */ i("span", {
|
|
17
|
+
className: "rfe-affix",
|
|
18
|
+
children: [/* @__PURE__ */ r(n, { source: l }), s]
|
|
19
|
+
}),
|
|
20
|
+
a,
|
|
21
|
+
(u || c) && /* @__PURE__ */ i("span", {
|
|
22
|
+
className: "rfe-affix",
|
|
23
|
+
children: [/* @__PURE__ */ r(n, { source: u }), c]
|
|
24
|
+
}),
|
|
25
|
+
o
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function o({ name: e, source: t, label: i, onClick: a, disabled: o, hidden: s }) {
|
|
30
|
+
return /* @__PURE__ */ r("button", {
|
|
31
|
+
className: "rfe-action",
|
|
32
|
+
type: "button",
|
|
33
|
+
"aria-label": i,
|
|
34
|
+
title: i,
|
|
35
|
+
disabled: o || s,
|
|
36
|
+
style: s ? { visibility: "hidden" } : void 0,
|
|
37
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
38
|
+
onClick: (e) => {
|
|
39
|
+
e.stopPropagation(), a();
|
|
40
|
+
},
|
|
41
|
+
children: /* @__PURE__ */ r(n, {
|
|
42
|
+
name: e,
|
|
43
|
+
source: t
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export { a as n, o as t };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { useEffect as e, useId as t, useMemo as n, useState as r } from "react";
|
|
2
|
+
import { n as i, t as ee } from "./Control-fWNQOzmu.js";
|
|
3
|
+
import { n as a, r as o } from "./selection-9OQvyjyD.js";
|
|
4
|
+
import { c as s, l as c, o as l, s as te, t as u } from "./useSelection-B85KkHB9.js";
|
|
5
|
+
import { t as d } from "./icons-KmLuj5v3.js";
|
|
6
|
+
import { a as f } from "./useControllable-Dl8gno_5.js";
|
|
7
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
8
|
+
// src/components/select/Select.tsx
|
|
9
|
+
function g(e) {
|
|
10
|
+
return /* @__PURE__ */ m(y, {
|
|
11
|
+
...e,
|
|
12
|
+
multiple: !1
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function _(e) {
|
|
16
|
+
return /* @__PURE__ */ m(y, {
|
|
17
|
+
...e,
|
|
18
|
+
multiple: !0
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var v = (e) => e.value;
|
|
22
|
+
function y(g) {
|
|
23
|
+
let { text: _, t: y } = f(), { open: b, changeOpen: x, committed: S, selected: C, update: w, confirm: T, blocked: E, triggerReadOnly: D } = u(g), [O, k] = r(""), [A, j] = r(!1), [M, N] = r(-1), P = t(), F = `${P}-options`, I = (e) => `${P}-option-${e}`, L = g["aria-label"] ?? _.choose, R = n(() => new Map(g.options.map((e) => [e.value, e])), [g.options]), z = n(() => new Set(C), [C]), B = (e) => R.get(e) ?? {
|
|
24
|
+
value: e,
|
|
25
|
+
label: String(e)
|
|
26
|
+
}, V = n(() => C.map(B), [C, R]), H = n(() => S.map(B), [S, R]), U = n(() => g.options.filter((e) => (e.searchText ?? (typeof e.label == "string" ? e.label : String(e.value))).toLocaleLowerCase().includes(O.toLocaleLowerCase())), [g.options, O]), W = (e) => !U[e]?.disabled, G = M >= 0 && M < U.length && W(M) ? M : a(U.length, -1, "Home", W), K = n(() => (g.selectAllScope === "all" ? g.options : U).filter((e) => !e.disabled).map((e) => e.value), [
|
|
27
|
+
g.options,
|
|
28
|
+
U,
|
|
29
|
+
g.selectAllScope
|
|
30
|
+
]), q = K.filter((e) => z.has(e)).length, J = K.length > 0 && q === K.length, Y = !J && z.size + K.length - q > (g.maxCount ?? 1e400), X = J ? "all" : q ? "partial" : "none";
|
|
31
|
+
e(() => {
|
|
32
|
+
b || (k(""), N(-1), j(!1));
|
|
33
|
+
}, [b]);
|
|
34
|
+
let Z = (e) => {
|
|
35
|
+
E || g.readOnly || e.disabled || (g.multiple ? w(l(C, [e.value], g.maxCount)) : (w([e.value]), g.needConfirm || x(!1)));
|
|
36
|
+
}, Q = () => w(C.filter((e) => R.get(e)?.disabled)), $ = (e) => {
|
|
37
|
+
R.get(e)?.disabled || w(C.filter((t) => t !== e));
|
|
38
|
+
}, ne = () => {
|
|
39
|
+
E || (b || x(!0), j(!0));
|
|
40
|
+
}, re = (e) => {
|
|
41
|
+
!e.nativeEvent.isComposing && e.target instanceof HTMLElement && e.target.matches(".rfe-trigger-arrow") && ["ArrowDown", "ArrowUp"].includes(e.key) && (e.preventDefault(), N(a(U.length, -1, e.key, W)), x(!0));
|
|
42
|
+
}, ie = (e) => {
|
|
43
|
+
if (e.nativeEvent.isComposing || e.keyCode === 229 || A) return;
|
|
44
|
+
let t = e.target;
|
|
45
|
+
t instanceof HTMLElement && t.matches(".rfe-search,.rfe-list,.rfe-option") && (t instanceof HTMLInputElement && [
|
|
46
|
+
"Home",
|
|
47
|
+
"End",
|
|
48
|
+
" "
|
|
49
|
+
].includes(e.key) || ([
|
|
50
|
+
"ArrowDown",
|
|
51
|
+
"ArrowUp",
|
|
52
|
+
"Home",
|
|
53
|
+
"End"
|
|
54
|
+
].includes(e.key) ? (e.preventDefault(), N(a(U.length, G, e.key, W))) : ["Enter", " "].includes(e.key) && G >= 0 && (e.preventDefault(), Z(U[G]))));
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ m(o, {
|
|
57
|
+
...g,
|
|
58
|
+
open: b,
|
|
59
|
+
onOpenChange: x,
|
|
60
|
+
label: L,
|
|
61
|
+
trigger: (e, t) => /* @__PURE__ */ m("div", {
|
|
62
|
+
ref: t,
|
|
63
|
+
className: "rfe-anchor",
|
|
64
|
+
onKeyDown: re,
|
|
65
|
+
onBlur: (e) => {
|
|
66
|
+
!b && !e.currentTarget.contains(e.relatedTarget) && g.onBlur?.();
|
|
67
|
+
},
|
|
68
|
+
children: /* @__PURE__ */ m(i, {
|
|
69
|
+
...g,
|
|
70
|
+
actions: /* @__PURE__ */ h(p, { children: [g.clearable !== !1 && /* @__PURE__ */ m(ee, {
|
|
71
|
+
name: "clear",
|
|
72
|
+
source: g.icons?.clear,
|
|
73
|
+
label: _.clear,
|
|
74
|
+
hidden: !S.length,
|
|
75
|
+
disabled: D,
|
|
76
|
+
onClick: Q
|
|
77
|
+
}), /* @__PURE__ */ m("button", {
|
|
78
|
+
type: "button",
|
|
79
|
+
...e,
|
|
80
|
+
id: g.id ?? P,
|
|
81
|
+
className: "rfe-trigger-arrow",
|
|
82
|
+
disabled: E,
|
|
83
|
+
"aria-invalid": g["aria-invalid"] ?? g.status === "error",
|
|
84
|
+
"aria-describedby": g["aria-describedby"],
|
|
85
|
+
"aria-label": L,
|
|
86
|
+
onClick: () => x(!b),
|
|
87
|
+
"data-open": b,
|
|
88
|
+
children: /* @__PURE__ */ m(d, {
|
|
89
|
+
name: "dropdown",
|
|
90
|
+
source: g.icons?.dropdown
|
|
91
|
+
})
|
|
92
|
+
})] }),
|
|
93
|
+
children: /* @__PURE__ */ m("div", {
|
|
94
|
+
className: "rfe-value",
|
|
95
|
+
onClick: () => x(!b),
|
|
96
|
+
children: g.multiple ? /* @__PURE__ */ m(s, {
|
|
97
|
+
options: H,
|
|
98
|
+
mode: g.displayMode,
|
|
99
|
+
maxTagCount: g.maxTagCount,
|
|
100
|
+
maxTagRows: g.maxTagRows,
|
|
101
|
+
onRemove: $,
|
|
102
|
+
onInspect: ne,
|
|
103
|
+
readOnly: D,
|
|
104
|
+
placeholder: g.placeholder
|
|
105
|
+
}) : /* @__PURE__ */ m("span", {
|
|
106
|
+
className: H.length ? "rfe-single-value" : "rfe-placeholder",
|
|
107
|
+
children: H[0]?.label ?? g.placeholder ?? _.choose
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
}),
|
|
112
|
+
children: /* @__PURE__ */ h("div", {
|
|
113
|
+
onKeyDown: ie,
|
|
114
|
+
"data-selection-style": g.selectionStyle ?? (g.multiple ? "subtle" : "accent"),
|
|
115
|
+
children: [g.multiple && A ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ h("button", {
|
|
116
|
+
type: "button",
|
|
117
|
+
className: "rfe-link",
|
|
118
|
+
onClick: () => j(!1),
|
|
119
|
+
children: [/* @__PURE__ */ m(d, { name: "previous" }), _.choose]
|
|
120
|
+
}), /* @__PURE__ */ m(te, {
|
|
121
|
+
options: V,
|
|
122
|
+
onRemove: $,
|
|
123
|
+
onClear: Q,
|
|
124
|
+
readOnly: g.readOnly
|
|
125
|
+
})] }) : /* @__PURE__ */ h(p, { children: [
|
|
126
|
+
g.searchable !== !1 && /* @__PURE__ */ m("input", {
|
|
127
|
+
className: "rfe-search",
|
|
128
|
+
role: "combobox",
|
|
129
|
+
"aria-expanded": "true",
|
|
130
|
+
"aria-controls": U.length ? F : void 0,
|
|
131
|
+
"aria-activedescendant": G >= 0 ? I(G) : void 0,
|
|
132
|
+
"aria-autocomplete": "list",
|
|
133
|
+
"aria-label": _.search,
|
|
134
|
+
placeholder: _.search,
|
|
135
|
+
value: O,
|
|
136
|
+
onChange: (e) => {
|
|
137
|
+
k(e.target.value), N(-1);
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
g.multiple && g.showSelectAll && !g.readOnly && /* @__PURE__ */ h("div", {
|
|
141
|
+
className: "rfe-toolbar",
|
|
142
|
+
children: [/* @__PURE__ */ h("button", {
|
|
143
|
+
type: "button",
|
|
144
|
+
className: "rfe-select-all",
|
|
145
|
+
role: "checkbox",
|
|
146
|
+
"aria-checked": J ? !0 : q ? "mixed" : !1,
|
|
147
|
+
"aria-label": _.all,
|
|
148
|
+
title: Y ? y("max", { max: g.maxCount ?? 0 }) : void 0,
|
|
149
|
+
disabled: !K.length || Y,
|
|
150
|
+
onClick: () => w(l(C, K, g.maxCount)),
|
|
151
|
+
children: [/* @__PURE__ */ m("span", {
|
|
152
|
+
className: "rfe-option-check",
|
|
153
|
+
"data-checked": X !== "none",
|
|
154
|
+
children: X !== "none" && /* @__PURE__ */ m(d, { name: X === "all" ? "check" : "minus" })
|
|
155
|
+
}), J ? _.deselectAll : _.all]
|
|
156
|
+
}), /* @__PURE__ */ m("button", {
|
|
157
|
+
type: "button",
|
|
158
|
+
className: "rfe-link",
|
|
159
|
+
onClick: Q,
|
|
160
|
+
children: _.clear
|
|
161
|
+
})]
|
|
162
|
+
}),
|
|
163
|
+
g.optionsLoading && /* @__PURE__ */ h("div", {
|
|
164
|
+
className: "rfe-options-loading",
|
|
165
|
+
role: "status",
|
|
166
|
+
children: [/* @__PURE__ */ m(d, { name: "loading" }), _.loading]
|
|
167
|
+
}),
|
|
168
|
+
U.length ? /* @__PURE__ */ m(c, {
|
|
169
|
+
items: U,
|
|
170
|
+
getKey: v,
|
|
171
|
+
id: F,
|
|
172
|
+
role: "listbox",
|
|
173
|
+
label: L,
|
|
174
|
+
multiple: g.multiple,
|
|
175
|
+
tabIndex: 0,
|
|
176
|
+
activeIndex: G,
|
|
177
|
+
activeId: G >= 0 ? I(G) : void 0,
|
|
178
|
+
variableHeight: g.variableHeight,
|
|
179
|
+
render: (e, t) => /* @__PURE__ */ h("button", {
|
|
180
|
+
id: I(t),
|
|
181
|
+
type: "button",
|
|
182
|
+
role: "option",
|
|
183
|
+
tabIndex: -1,
|
|
184
|
+
"aria-selected": z.has(e.value),
|
|
185
|
+
"aria-posinset": t + 1,
|
|
186
|
+
"aria-setsize": U.length,
|
|
187
|
+
"data-active": G === t || void 0,
|
|
188
|
+
"data-selected": z.has(e.value) || void 0,
|
|
189
|
+
className: "rfe-option",
|
|
190
|
+
disabled: e.disabled || g.readOnly || E,
|
|
191
|
+
onMouseEnter: () => N(t),
|
|
192
|
+
onClick: () => Z(e),
|
|
193
|
+
children: [
|
|
194
|
+
g.multiple && /* @__PURE__ */ m("span", {
|
|
195
|
+
className: "rfe-option-check",
|
|
196
|
+
"data-checked": z.has(e.value),
|
|
197
|
+
children: z.has(e.value) && /* @__PURE__ */ m(d, { name: "check" })
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ m("span", {
|
|
200
|
+
className: "rfe-option-label",
|
|
201
|
+
children: g.renderOption ? g.renderOption(e, z.has(e.value)) : /* @__PURE__ */ h(p, { children: [
|
|
202
|
+
e.icon,
|
|
203
|
+
e.label,
|
|
204
|
+
e.description && /* @__PURE__ */ m("small", { children: e.description })
|
|
205
|
+
] })
|
|
206
|
+
}),
|
|
207
|
+
!g.multiple && z.has(e.value) && /* @__PURE__ */ m(d, {
|
|
208
|
+
name: "check",
|
|
209
|
+
source: g.icons?.check
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
}) : !g.optionsLoading && /* @__PURE__ */ h("div", {
|
|
214
|
+
className: "rfe-empty",
|
|
215
|
+
role: "status",
|
|
216
|
+
children: [/* @__PURE__ */ m(d, { name: "empty" }), _.empty]
|
|
217
|
+
})
|
|
218
|
+
] }), (g.multiple || g.needConfirm) && /* @__PURE__ */ h("div", {
|
|
219
|
+
className: "rfe-footer",
|
|
220
|
+
children: [
|
|
221
|
+
/* @__PURE__ */ h("button", {
|
|
222
|
+
type: "button",
|
|
223
|
+
className: "rfe-link",
|
|
224
|
+
onClick: () => j(!A),
|
|
225
|
+
children: [
|
|
226
|
+
_.selected,
|
|
227
|
+
" ",
|
|
228
|
+
C.length
|
|
229
|
+
]
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ m("span", { className: "rfe-spacer" }),
|
|
232
|
+
g.needConfirm && /* @__PURE__ */ m("button", {
|
|
233
|
+
type: "button",
|
|
234
|
+
className: "rfe-link",
|
|
235
|
+
onClick: () => x(!1),
|
|
236
|
+
children: _.cancel
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ m("button", {
|
|
239
|
+
className: "rfe-button",
|
|
240
|
+
"data-variant": "primary",
|
|
241
|
+
type: "button",
|
|
242
|
+
onClick: T,
|
|
243
|
+
children: _.done
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
})]
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
export { g as n, _ as t };
|