react-animated-select 0.6.6 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.cts +165 -0
- package/dist/index.es.js +1040 -1656
- package/index.d.ts +165 -88
- package/package.json +71 -55
- package/dist/index.cjs.js +0 -16
package/index.d.ts
CHANGED
|
@@ -1,88 +1,165 @@
|
|
|
1
|
-
import {FC, ReactNode, CSSProperties, ElementType} from 'react'
|
|
2
|
-
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
import {FC, FunctionComponent, ReactNode, CSSProperties, ElementType, Ref, FocusEvent, AriaAttributes} from 'react'
|
|
2
|
+
|
|
3
|
+
export interface SelectTexts {
|
|
4
|
+
empty: string
|
|
5
|
+
disabled: string
|
|
6
|
+
loading: string
|
|
7
|
+
error: string
|
|
8
|
+
clear: string
|
|
9
|
+
remove: string
|
|
10
|
+
loadMore: string
|
|
11
|
+
loadingMore: string
|
|
12
|
+
emptyOption: string
|
|
13
|
+
invalidOption: string
|
|
14
|
+
disabledOption: string
|
|
15
|
+
emptyGroup: string
|
|
16
|
+
list: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type SelectIcon = ElementType | string | ReactNode | null | false
|
|
20
|
+
|
|
21
|
+
export interface SelectIcons {
|
|
22
|
+
arrow: SelectIcon
|
|
23
|
+
clear: SelectIcon
|
|
24
|
+
remove: SelectIcon
|
|
25
|
+
check: SelectIcon
|
|
26
|
+
checkbox: SelectIcon
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SelectProps extends AriaAttributes {
|
|
30
|
+
[key: `data-${string}`]: string | number | boolean | undefined
|
|
31
|
+
|
|
32
|
+
ref?: Ref<HTMLDivElement>
|
|
33
|
+
children?: ReactNode
|
|
34
|
+
|
|
35
|
+
options?: any[] | Record<string, any>
|
|
36
|
+
value?: any
|
|
37
|
+
defaultValue?: any
|
|
38
|
+
onChange?: (value: any, ids: any) => void
|
|
39
|
+
multiple?: boolean
|
|
40
|
+
childrenFirst?: boolean
|
|
41
|
+
groupsClosed?: boolean
|
|
42
|
+
|
|
43
|
+
disabled?: boolean
|
|
44
|
+
loading?: boolean
|
|
45
|
+
error?: boolean
|
|
46
|
+
|
|
47
|
+
open?: boolean
|
|
48
|
+
onOpenChange?: (open: boolean) => void
|
|
49
|
+
onFocus?: (e: FocusEvent<HTMLDivElement>) => void
|
|
50
|
+
onBlur?: (e: FocusEvent<HTMLDivElement>) => void
|
|
51
|
+
|
|
52
|
+
id?: string
|
|
53
|
+
name?: string
|
|
54
|
+
required?: boolean
|
|
55
|
+
|
|
56
|
+
hasMore?: boolean
|
|
57
|
+
loadMore?: () => void | Promise<unknown>
|
|
58
|
+
loadButton?: boolean
|
|
59
|
+
loadOffset?: number
|
|
60
|
+
loadAhead?: number
|
|
61
|
+
|
|
62
|
+
placeholder?: string
|
|
63
|
+
selectedText?: string
|
|
64
|
+
texts?: Partial<SelectTexts>
|
|
65
|
+
renderOption?: (item: any, state: {selected: boolean, disabled: boolean}) => ReactNode
|
|
66
|
+
valueAsOption?: boolean
|
|
67
|
+
|
|
68
|
+
icons?: Partial<SelectIcons>
|
|
69
|
+
deleteInline?: boolean
|
|
70
|
+
deleteAlways?: boolean
|
|
71
|
+
|
|
72
|
+
className?: string
|
|
73
|
+
optionsClassName?: string
|
|
74
|
+
style?: CSSProperties
|
|
75
|
+
container?: HTMLElement | null | (() => HTMLElement | null)
|
|
76
|
+
duration?: number
|
|
77
|
+
easing?: string
|
|
78
|
+
offset?: number
|
|
79
|
+
animateOpacity?: boolean
|
|
80
|
+
keepMounted?: boolean
|
|
81
|
+
|
|
82
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `open`. */
|
|
83
|
+
visibility?: boolean
|
|
84
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `onOpenChange`. */
|
|
85
|
+
setVisibility?: (open: boolean) => void
|
|
86
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `open` without `onOpenChange`. */
|
|
87
|
+
ownBehavior?: boolean
|
|
88
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `onOpenChange`. */
|
|
89
|
+
onOpen?: () => void
|
|
90
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `onOpenChange`. */
|
|
91
|
+
onClose?: () => void
|
|
92
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `keepMounted` (inverted). */
|
|
93
|
+
unmount?: boolean
|
|
94
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `deleteAlways`. */
|
|
95
|
+
showDelete?: boolean
|
|
96
|
+
|
|
97
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `icons.arrow`. */
|
|
98
|
+
OpenIcon?: ElementType | string | ReactNode | boolean
|
|
99
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `icons.clear`. */
|
|
100
|
+
ClearIcon?: ElementType | string | ReactNode | boolean
|
|
101
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `icons.remove`. */
|
|
102
|
+
DelIcon?: ElementType | string | ReactNode | boolean
|
|
103
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `icons.check`. */
|
|
104
|
+
Checkmark?: ElementType | string | ReactNode | boolean
|
|
105
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `icons.checkbox`. */
|
|
106
|
+
Checkbox?: ElementType | string | ReactNode | boolean
|
|
107
|
+
|
|
108
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.empty`. */
|
|
109
|
+
emptyText?: string
|
|
110
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.disabled`. */
|
|
111
|
+
disabledText?: string
|
|
112
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.loading`. */
|
|
113
|
+
loadingText?: string
|
|
114
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.error`. */
|
|
115
|
+
errorText?: string
|
|
116
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.clear`. */
|
|
117
|
+
clearText?: string
|
|
118
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.remove`. */
|
|
119
|
+
removeText?: string
|
|
120
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.loadMore`. */
|
|
121
|
+
loadButtonText?: string
|
|
122
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.loadingMore`. */
|
|
123
|
+
loadMoreText?: string
|
|
124
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.emptyOption`. */
|
|
125
|
+
emptyOption?: string
|
|
126
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.invalidOption`. */
|
|
127
|
+
invalidOption?: string
|
|
128
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.disabledOption`. */
|
|
129
|
+
disabledOption?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const Select: FC<SelectProps>
|
|
133
|
+
|
|
134
|
+
export interface OptionProps {
|
|
135
|
+
value?: any
|
|
136
|
+
id?: any
|
|
137
|
+
label?: any
|
|
138
|
+
name?: any
|
|
139
|
+
group?: string
|
|
140
|
+
children?: ReactNode
|
|
141
|
+
disabled?: boolean
|
|
142
|
+
className?: string
|
|
143
|
+
style?: CSSProperties
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const Option: FC<OptionProps>
|
|
147
|
+
|
|
148
|
+
export interface OptGroupProps {
|
|
149
|
+
value?: any
|
|
150
|
+
id?: any
|
|
151
|
+
name?: any
|
|
152
|
+
label?: any
|
|
153
|
+
children?: ReactNode
|
|
154
|
+
disabled?: boolean
|
|
155
|
+
className?: string
|
|
156
|
+
style?: CSSProperties
|
|
157
|
+
|
|
158
|
+
/** @deprecated Removed in v0.7.5, has no effect. Use `texts.emptyGroup` on the `<Select/>`. */
|
|
159
|
+
emptyGroupText?: string
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const OptGroup: FC<OptGroupProps>
|
|
163
|
+
|
|
164
|
+
/** Makes a reusable option component that `<Select/>` reads as data. `render` must be pure: no hooks. */
|
|
165
|
+
export function defineOption<P>(render: (props: P) => ReactNode): FunctionComponent<P>
|
package/package.json
CHANGED
|
@@ -1,55 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-animated-select",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "l1nway",
|
|
7
|
-
"email": "l1nway@icloud.com",
|
|
8
|
-
"url": "https://github.com/l1nway/"
|
|
9
|
-
|
|
10
|
-
"description": "Animated, accessible
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"index.d.ts"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "react-animated-select",
|
|
3
|
+
"version": "0.7.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "l1nway",
|
|
7
|
+
"email": "l1nway@icloud.com",
|
|
8
|
+
"url": "https://github.com/l1nway/"
|
|
9
|
+
},
|
|
10
|
+
"description": "Animated, accessible and deeply customizable select for React: single and multiple choice, groups, chips, async loading, keyboard, touch and SSR, with zero dependencies",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"index.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react",
|
|
17
|
+
"select",
|
|
18
|
+
"multiselect",
|
|
19
|
+
"combobox",
|
|
20
|
+
"dropdown",
|
|
21
|
+
"chips",
|
|
22
|
+
"animated",
|
|
23
|
+
"accessible",
|
|
24
|
+
"ssr",
|
|
25
|
+
"ui-components"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/l1nway/react-animated-select.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/l1nway/react-animated-select/issues"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"homepage": "https://l1nway.github.io/react-animated-select-docs/",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"dev": "vite build --watch",
|
|
39
|
+
"prepublishOnly": "npm run build"
|
|
40
|
+
},
|
|
41
|
+
"main": "./dist/index.cjs",
|
|
42
|
+
"module": "./dist/index.es.js",
|
|
43
|
+
"types": "./index.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./index.d.ts",
|
|
48
|
+
"default": "./dist/index.es.js"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./dist/index.d.cts",
|
|
52
|
+
"default": "./dist/index.cjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"./style.css": "./dist/index.css",
|
|
56
|
+
"./package.json": "./package.json"
|
|
57
|
+
},
|
|
58
|
+
"sideEffects": [
|
|
59
|
+
"**/*.css"
|
|
60
|
+
],
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"react": ">=19.2.0",
|
|
63
|
+
"react-dom": ">=19.2.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/react": "^19.2.9",
|
|
67
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
68
|
+
"vite": "^7.3.1",
|
|
69
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const t=require("react"),Me=require("react-transition-group"),ct=require("react-dom");var De={exports:{}},Ie={};var Ke;function ut(){if(Ke)return Ie;Ke=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(c,l,x){var b=null;if(x!==void 0&&(b=""+x),l.key!==void 0&&(b=""+l.key),"key"in l){x={};for(var g in l)g!=="key"&&(x[g]=l[g])}else x=l;return l=x.ref,{$$typeof:e,type:c,key:b,ref:l!==void 0?l:null,props:x}}return Ie.Fragment=n,Ie.jsx=s,Ie.jsxs=s,Ie}var He={};var Ze;function dt(){return Ze||(Ze=1,process.env.NODE_ENV!=="production"&&(function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===le?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case C:return"Fragment";case L:return"Profiler";case O:return"StrictMode";case Q:return"Suspense";case G:return"SuspenseList";case D:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case _:return"Portal";case H:return r.displayName||"Context";case I:return(r._context.displayName||"Context")+".Consumer";case Z:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case U:return o=r.displayName||null,o!==null?o:e(r.type)||"Memo";case u:o=r._payload,r=r._init;try{return e(r(o))}catch{}}return null}function n(r){return""+r}function s(r){try{n(r);var o=!1}catch{o=!0}if(o){o=console;var m=o.error,S=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return m.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",S),n(r)}}function c(r){if(r===C)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===u)return"<...>";try{var o=e(r);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function l(){var r=F.A;return r===null?null:r.getOwner()}function x(){return Error("react-stack-top-frame")}function b(r){if(q.call(r,"key")){var o=Object.getOwnPropertyDescriptor(r,"key").get;if(o&&o.isReactWarning)return!1}return r.key!==void 0}function g(r,o){function m(){re||(re=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}m.isReactWarning=!0,Object.defineProperty(r,"key",{get:m,configurable:!0})}function j(){var r=e(this.type);return P[r]||(P[r]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),r=this.props.ref,r!==void 0?r:null}function i(r,o,m,S,ce,a){var y=m.ref;return r={$$typeof:N,type:r,key:o,props:m,_owner:S},(y!==void 0?y:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:j}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ce}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function v(r,o,m,S,ce,a){var y=o.children;if(y!==void 0)if(S)if(fe(y)){for(S=0;S<y.length;S++)k(y[S]);Object.freeze&&Object.freeze(y)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else k(y);if(q.call(o,"key")){y=e(r);var p=Object.keys(o).filter(function(T){return T!=="key"});S=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",W[y+S]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,S,y,p,y),W[y+S]=!0)}if(y=null,m!==void 0&&(s(m),y=""+m),b(o)&&(s(o.key),y=""+o.key),"key"in o){m={};for(var $ in o)$!=="key"&&(m[$]=o[$])}else m=o;return y&&g(m,typeof r=="function"?r.displayName||r.name||"Unknown":r),i(r,y,m,l(),ce,a)}function k(r){d(r)?r._store&&(r._store.validated=1):typeof r=="object"&&r!==null&&r.$$typeof===u&&(r._payload.status==="fulfilled"?d(r._payload.value)&&r._payload.value._store&&(r._payload.value._store.validated=1):r._store&&(r._store.validated=1))}function d(r){return typeof r=="object"&&r!==null&&r.$$typeof===N}var R=t,N=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),H=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),le=Symbol.for("react.client.reference"),F=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,fe=Array.isArray,V=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(r){return r()}};var re,P={},ie=R.react_stack_bottom_frame.bind(R,x)(),E=V(c(x)),W={};He.Fragment=C,He.jsx=function(r,o,m){var S=1e4>F.recentlyCreatedOwnerStacks++;return v(r,o,m,!1,S?Error("react-stack-top-frame"):ie,S?V(c(r)):E)},He.jsxs=function(r,o,m){var S=1e4>F.recentlyCreatedOwnerStacks++;return v(r,o,m,!0,S?Error("react-stack-top-frame"):ie,S?V(c(r)):E)}})()),He}var Qe;function ft(){return Qe||(Qe=1,process.env.NODE_ENV==="production"?De.exports=ut():De.exports=dt()),De.exports}var h=ft();const et=({className:e="",...n})=>h.jsx("svg",{className:e,role:"button","aria-label":"Clear selection",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:"1em",height:"1em",fill:"currentColor",...n,children:h.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),gt=({className:e="",...n})=>h.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",...n,children:h.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),pt=({className:e="",...n})=>h.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"1em",height:"1em",fill:"currentColor",...n,children:h.jsx("path",{d:"M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z"})}),Ve=t.createContext(null),Ae=t.forwardRef(({className:e="",visibility:n=void 0,setLeaving:s,setEntering:c,setSpacer:l,children:x,duration:b=300,unmount:g,style:j,exit:i=!0,...v},k)=>{const d=t.useRef(null),R=n!==void 0?n:v.in;t.useImperativeHandle(k,()=>d.current),t.useEffect(()=>{!R&&d.current&&(d.current.style.width="0px")},[]);const N=t.useCallback(()=>{if(!d.current)return{left:"0px",right:"0px"};const _=window.getComputedStyle(d.current);return{left:_.marginLeft,right:_.marginRight}},[]);return h.jsx(Me.CSSTransition,{onEnter:()=>{d.current.style.transition="none",d.current.style.marginRight="0px",d.current.style.marginLeft="0px",d.current.style.width="0px",c?.(!0)},onEntering:()=>{const{left:_,right:C}=N();requestAnimationFrame(()=>{requestAnimationFrame(()=>{d.current&&(d.current.style.transition=`width ${b}ms, color ${b}ms, background-color ${b}ms, margin ${b}ms ease`,d.current.style.width=d.current.scrollWidth+"px",d.current.style.marginRight=C,d.current.style.marginLeft=_)})})},onEntered:()=>{d.current.style.width="auto",l?.(!1),c?.(!1)},onExit:()=>{const{left:_,right:C}=N();d.current.style.width=d.current.scrollWidth+"px",d.current.style.marginRight=C,d.current.style.marginLeft=_,d.current.offsetHeight,s?.(!0)},onExiting:()=>{d.current.style.marginRight="0px",d.current.style.marginLeft="0px",d.current.style.width="0px"},onExited:()=>{g?.(),s?.(!1),l?.(!1)},classNames:"rac-slide-left",unmountOnExit:i,timeout:b,nodeRef:d,in:R,...v,children:h.jsx("div",{className:e,ref:d,style:{transition:`width ${b}ms, color ${b}ms, background-color ${b}ms, margin ${b}ms ease`,willChange:"width",overflow:"hidden",...j},children:x})})}),ht=t.memo(({element:e,index:n,setEntering:s,leaving:c,setLeaving:l,setSpacer:x,selectRef:b,spacer:g,delSpacer:j,setVisibility:i,setActiveHoverId:v,activeHoverId:k,swipedId:d,deleteInline:R,remove:N,renderIcon:_,DelIcon:C,normalizedOptions:O,swiped:L,onSwipe:I,deleting:H,setDeleting:Z,onRender:Q,duration:G,showDelete:U})=>{const u=t.useRef(null),D=t.useRef(!1),le=t.useRef(!1),F=t.useRef(0),q=t.useRef(null),fe=t.useCallback(o=>{F.current=o.touches[0].clientX,D.current=!1,u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{Z(!0),D.current=!0,b.current?.focus(),i(!1),window.navigator.vibrate&&window.navigator.vibrate(50)},600),o.preventDefault()},[]),V=t.useCallback(o=>{u.current&&clearTimeout(u.current);const m=o.touches[0].clientX,S=F.current-m;Math.abs(S)>10&&(le.current=!0,S>30&&!L?(v(null),I(e.id)):S<-30&&L&&I(null))},[e.id,L,I]),re=t.useCallback(o=>{u.current&&clearTimeout(u.current),D.current&&o.preventDefault()},[]);let P=null;if(e?.jsx)P=e.jsx;else if(e?.name)P=e.name;else if(e?.raw!==void 0){const o=O.find(m=>m.raw===e.raw||m.original===e.raw||m.userId===e.raw);o&&(P=o.jsx??o.name)}P==null&&(P=typeof e=="object"?e.label??e.name??e.value??"Selected item":String(e));const ie=t.useCallback(o=>{o.stopPropagation(),o.preventDefault()},[]),E=t.useCallback(o=>{ie(o),N(e.id),I(null)},[e.id,N,I]),W=t.useCallback(o=>{if(ie(o),D.current){D.current=!1;return}if(H){E(o);return}},[H,E]);t.useLayoutEffect(()=>{if(q.current&&Q){const o=q.current.offsetWidth;Q(o)}},[Q,P]);const r=U?!0:k===e.id||d===e.id||H;return h.jsxs(t.Fragment,{children:[h.jsxs("div",{className:`rac-multiple-selected-option ${H?"--deleting-shake":""}`,onMouseEnter:()=>{v(e.id),I(null)},onMouseLeave:()=>v(null),onTouchStart:fe,onTouchMove:V,onTouchEnd:re,onClick:W,ref:q,children:[P,h.jsx(Ae,{style:{backgroundColor:H||R?"transparent":"--rac-multiple-del-bg",position:H||R?"relative":"absolute"},className:"rac-multiple-del",visibility:r,setEntering:s,setLeaving:l,setSpacer:x,duration:G,children:_(C,{onClick:E,onMouseDown:ie})})]}),h.jsx(Ae,{visibility:!c&&!g?.state&&!k&&!d&&!H&&R&&j,className:"rac-multiple-option",style:{visibility:"hidden"},children:h.jsx("div",{style:{padding:0,marginRight:0,marginLeft:0},className:"rac-multiple-selected-option",children:_(C)})})]})}),st=({children:e,setLeaving:n,duration:s,setSpacer:c,id:l=null,widthMode:x=!1,...b})=>{const g=t.useRef(null),j=t.useCallback(()=>{if(!g.current)return{t:0,b:0,l:0,r:0};const i=window.getComputedStyle(g.current);return{t:i.marginTop,b:i.marginBottom,l:i.marginLeft,r:i.marginRight}},[]);return h.jsx(Me.CSSTransition,{classNames:"rac-slide-left",timeout:s,nodeRef:g,unmountOnExit:!0,...b,onEnter:()=>{const i=g.current;i&&(x?(i.style.width="0px",i.style.marginLeft="0px",i.style.marginRight="0px"):(i.style.height="0px",i.style.marginTop="0px",i.style.marginBottom="0px",i.style.transform="translateY(-10px)"),i.style.opacity="0")},onEntering:()=>{const i=g.current,v=j();i.offsetHeight,x?(i.style.width=i.scrollWidth+"px",i.style.marginRight=v.r,i.style.marginLeft=v.l):(i.style.height=i.scrollHeight+"px",i.style.transform="translateY(0)",i.style.marginBottom=v.b,i.style.marginTop=v.t),i.style.opacity="1"},onEntered:()=>{const i=g.current;i.style.width=x?"auto":"",i.style.height=x?"":"100%",i.style.opacity="1",i.style.transform="",c?.(!1)},onExit:()=>{const i=g.current,v=j();x?(i.style.width=i.offsetWidth+"px",i.style.marginRight=v.r,i.style.marginLeft=v.l):(i.style.height=i.offsetHeight+"px",i.style.position="absolute",i.style.marginBottom=v.b,i.style.marginTop=v.t),i.style.opacity="1",n?.(!0)},onExiting:()=>{const i=g.current;x?(i.style.marginRight="0px",i.style.marginLeft="0px",i.style.width="0px"):(i.style.transform="translateY(10px)",i.style.marginBottom="0px",i.style.marginTop="0px",i.style.height="0px"),i.style.opacity="0"},onExited:()=>{c?.(!1),n?.(!1)},children:h.jsx("div",{ref:g,id:l,style:{transition:`all ${s}ms ease`,alignItems:"center",whiteSpace:"nowrap",overflow:"hidden",display:"flex",left:0,top:0},children:e})})},mt=t.memo(({element:e,index:n,setEntering:s,leaving:c,setLeaving:l,selectRef:x,setVisibility:b,setActiveHoverId:g,delSpacer:j,swiped:i,swipedId:v,onSwipe:k,activeHoverId:d,deleteInline:R,spacer:N,duration:_,normalizedOptions:C,setDeleting:O,renderIcon:L,deleting:I,DelIcon:H,remove:Z,registerItemWidth:Q,setSpacer:G,showDelete:U,...u})=>h.jsxs(t.Fragment,{children:[h.jsx(st,{className:"rac-multiple-option",onEnter:u.onEnter,setLeaving:l,setSpacer:G,onExit:u.onExit,duration:_,id:e.id,in:u.in,widthMode:!0,children:h.jsx(ht,{onRender:D=>Q(e.id,D),normalizedOptions:C,setActiveHoverId:g,activeHoverId:d,setVisibility:b,deleteInline:R,setDeleting:O,setEntering:s,setLeaving:l,renderIcon:L,showDelete:U,setSpacer:G,selectRef:x,delSpacer:j,duration:_,deleting:I,swipedId:v,onSwipe:k,element:e,DelIcon:H,leaving:c,swiped:i,remove:Z,spacer:N,index:n},e.id??n)}),N.state&&N.id===e.id&&h.jsx("div",{style:{width:N.width-2},className:"rac-spacer"})]}));function yt({visibility:e,children:n,selectRef:s,onAnimationDone:c,unmount:l=!0,duration:x,easing:b,offset:g,animateOpacity:j,style:i,className:v,setBottomDirection:k=()=>{}}){const d=t.useRef(null),[R,N]=t.useState({top:0,left:0,width:0}),_=t.useRef(R);t.useLayoutEffect(()=>{_.current=R},[R]);const C=t.useCallback(()=>{if(s?.current){const u=s.current.getBoundingClientRect(),D=window.innerHeight,le=d.current?.scrollHeight||250,F=D-u.bottom,q=F<le&&u.top>F;k(q),N({top:u.top,bottom:u.bottom,left:u.left,width:u.width,isUpward:q})}},[s]);t.useLayoutEffect(()=>{if(e)return C(),window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[e,C]);const O=`height var(--rac-duration) ${b}${j?`, opacity var(--rac-duration) ${b}`:""}`;t.useLayoutEffect(()=>{if(!s?.current)return;const u=new ResizeObserver(D=>{for(let le of D)if(e&&d.current&&s.current){const F=s.current.getBoundingClientRect(),{isUpward:q}=_.current;d.current.style.width=`${F.width}px`,d.current.style.left=`${F.left}px`,q?d.current.style.bottom=`${window.innerHeight-F.top+g}px`:d.current.style.top=`${F.bottom+g}px`}});return u.observe(s.current),()=>u.disconnect()},[s,e,g]);const L={position:"fixed","--rac-duration":`${x}ms`,"--rac-easing":b,left:`${R.left}px`,width:`${R.width}px`,overflow:"hidden",zIndex:"2147483647",height:e?"auto":"0px",opacity:j?e?1:0:1,pointerEvents:e?"all":"none",boxSizing:"border-box",transformOrigin:R.isUpward?"bottom":"top",...R.isUpward?{bottom:`${window.innerHeight-R.top+g}px`,top:"auto"}:{top:`${R.bottom+g}px`,bottom:"auto"},...Object.fromEntries(Object.entries(i||{}).map(([u,D])=>[u.startsWith("--")?u:`--rac-${u.replace(/([A-Z])/g,"-$1").toLowerCase()}`,D]))},I=t.useCallback(()=>{const u=d.current;u&&(u.style.height="0px",j&&(u.style.opacity="0"),u.style.transition="")},[j]),H=t.useCallback(()=>{const u=d.current;u&&(u.style.transition=O,u.style.height=`${u.scrollHeight}px`,j&&(u.style.opacity="1"))},[O,j]),Z=t.useCallback(()=>{const u=d.current;u&&(u.style.height="auto",u.style.transition="",c&&c())},[c]),Q=t.useCallback(()=>{const u=d.current;u&&(u.style.height=`${u.scrollHeight}px`,j&&(u.style.opacity="1"),u.offsetHeight,u.style.transition=O)},[O,j]),G=t.useCallback(()=>{const u=d.current;u&&(u.style.height="0px",j&&(u.style.opacity="0"))},[j]),U=t.useCallback(()=>{const u=d.current;u&&(u.style.transition="")},[]);return ct.createPortal(h.jsx(Me.CSSTransition,{in:e,timeout:x,classNames:"rac-options",unmountOnExit:l,nodeRef:d,onEnter:I,onEntering:H,onEntered:Z,onExit:Q,onExiting:G,onExited:U,children:h.jsx("div",{ref:d,className:`rac-options ${v||""}`,style:{...L,"--rac-duration":`${x}ms`,"--rac-duration-fast":"calc(var(--rac-duration) * 0.5)","--rac-duration-base":"var(--rac-duration)","--rac-duration-slow":"calc(var(--rac-duration) * 1.3)"},onMouseDown:u=>u.preventDefault(),children:n})}),document.body)}const bt=t.memo(yt,(e,n)=>e.visibility===n.visibility&&e.duration===n.duration&&e.easing===n.easing&&e.offset===n.offset&&e.animateOpacity===n.animateOpacity&&e.selectRef===n.selectRef&&e.children===n.children&&JSON.stringify(e.style)===JSON.stringify(n.style)),tt=e=>{const n=window.getComputedStyle(e);return parseFloat(n.marginLeft)+parseFloat(n.marginRight)},rt=e=>e.reduce((n,s)=>{const c=s.offsetTop,l=s.getBoundingClientRect().width;return n[c]=(n[c]||0)+l,n},{}),xt=t.memo(({deleteInline:e,selectRef:n,setVisibility:s,selectId:c,removeOption:l,renderOptions:x,selected:b,selectedIDs:g,setSelectedIds:j,normalizedOptions:i,title:v,visibility:k,active:d,hasOptions:R,hasActualValue:N,optionsClassName:_,selectedText:C,disabled:O,loading:L,error:I,registerOption:H,unregisterOption:Z,handleBlur:Q,handleFocus:G,toggleVisibility:U,handleKeyDown:u,handleListScroll:D,setAnimationFinished:le,clear:F,children:q,placeholder:fe,className:V,style:re,duration:P,easing:ie,offset:E,animateOpacity:W,unmount:r,OpenIcon:o,ClearIcon:m,DelIcon:S,renderIcon:ce,hasMore:a,loadButton:y,deleting:p,setDeleting:$,showDelete:T})=>{const[Y,ue]=t.useState(!1),[oe,xe]=t.useState(null),[ee,f]=t.useState(!1),[A,ne]=t.useState({}),[he,z]=t.useState(null),[ke,X]=t.useState(null),[be,ve]=t.useState(!1),[te,Re]=t.useState(!1),$e=t.useRef(!0),Se=t.useRef(null),We=t.useCallback(J=>{l?l(J):j(B=>B.filter(ae=>ae.id!==J))},[l,j]),Ye=t.useCallback(J=>{if(p){J.stopPropagation(),J.preventDefault(),$(!1);return}U(J)},[p,U]),Ge=t.useCallback((J,B)=>{ne(ae=>ae[J]===B?ae:{...ae,[J]:B})},[]);t.useLayoutEffect(()=>{const J=Se.current;if(!J)return;const B=new ResizeObserver(ae=>{window.requestAnimationFrame(()=>{if(!Array.isArray(ae)||!ae.length)return;const Oe=ae[0].contentRect.height;xe(Oe)})});return B.observe(J),()=>B.disconnect()},[]),t.useEffect(()=>{$e.current=!1,n&&(typeof n=="function"?n(n.current):n.current=n.current)},[n]),t.useEffect(()=>{p&&k&&U()&&U?.()(p&&g?.length===0)&&$(!1),X(null)},[g?.length,p]),t.useLayoutEffect(()=>{const J=Se.current;if(!J||!g?.length||p){g?.length||f({state:!1,id:null,width:0});return}const B=Array.from(J.children).filter(ye=>ye.classList.contains("rac-multiple-option")),ae=J.clientWidth;if(B.length>g.length){const ye=new Set(g.map(me=>me.id)),Ee=B.findIndex(me=>!ye.has(me.id));if(Ee===-1)return;const de=B[Ee],ge=B[Ee-1];if(!(ge&&de.offsetTop!==ge.offsetTop)){f({state:!1,id:null,width:0});return}const Le=rt(B),Pe=Object.keys(Le).map(Number).sort((me,je)=>me-je),M=Pe.indexOf(de.offsetTop);if(M<=0){f({state:!1,id:null,width:0});return}const K=Pe[M-1],se=Le[K],pe=ae-se;Oe(ge?.id||null,!0,pe)}else if(B.length===g.length){const ye=B[B.length-1],Ee=g[g.length-1]?.id,de=A[Ee];if(!de)return;const ge=ye?.firstElementChild||ye,Ne=tt(ge),Le=tt(ye),Pe=B.slice(0,-1),M=rt(Pe),K=Object.keys(M).map(Number).sort((je,w)=>je-w);let se=ae;if(K.length>0){const je=Math.max(...K);se=ae-(M[je]||0)}const pe=de+Ne+Le>se,me=g[g.length-2]?.id;Oe(me,pe,se)}function Oe(ye,Ee,de){f(ge=>ge.id===ye&&ge.state===Ee&&ge.width===de?ge:{state:Ee,id:ye,width:de})}},[g,A,p]);const Ce=m&&N&&R&&!O&&!L&&!I&&!p,Te=o&&d&&!p,Ue=g?.map((J,B)=>{const ae=B===g.length-1;return h.jsx(mt,{normalizedOptions:i,registerItemWidth:Ge,setActiveHoverId:X,swiped:he===J.id,activeHoverId:ke,setVisibility:s,deleteInline:e,setDeleting:$,setEntering:Re,setLeaving:ve,renderIcon:ce,showDelete:T,selectRef:n,setSpacer:f,onSwipe:z,delSpacer:ae,duration:P,deleting:p,swipedId:he,leaving:be,element:J,DelIcon:S,spacer:ee,remove:We,index:B},J.id??B)});return h.jsxs(Ve.Provider,{value:{registerOption:H,unregisterOption:Z},children:[q,h.jsxs("div",{ref:n,style:{"--rac-duration-fast":"calc(var(--rac-duration) * 0.5)","--rac-duration-slow":"calc(var(--rac-duration) * 1.3)","--rac-duration-base":"var(--rac-duration)","--rac-duration":`${P}ms`,...re},className:`
|
|
7
|
-
${!R||O?"rac-disabled-style":""}
|
|
8
|
-
${L?"rac-loading-style":""}
|
|
9
|
-
${I?"rac-error-style":""}
|
|
10
|
-
${V}
|
|
11
|
-
rac-select
|
|
12
|
-
`,...d&&{onKeyDown:u,onFocus:G,onClick:Ye,onBlur:Q},"aria-disabled":O||!R,"aria-controls":`${c}-listbox`,tabIndex:d?0:-1,"aria-expanded":k,"aria-label":fe,"aria-haspopup":"listbox",role:"combobox",children:[h.jsx("div",{className:`rac-select-title-wrapper
|
|
13
|
-
${!I&&!L&&b?.type==="boolean"?b.raw?"rac-true-option":"rac-false-option":""}
|
|
14
|
-
`,style:{alignItems:g?.length&&!C?"flex-start":"center",height:oe?`${oe}px`:"auto"},children:h.jsx("div",{style:{alignItems:g?.length&&!C?"flex-start":"center",height:L?"100%":"auto"},className:"rac-select-title",ref:Se,children:h.jsx(Me.TransitionGroup,{enter:!$e.current,component:null,appear:!1,children:g?.length&&!C&&!L?Ue:h.jsxs(st,{className:"rac-title-container",duration:P,widthMode:!0,children:[h.jsx("span",{className:"rac-title-text",children:v}),h.jsx(Ae,{className:"rac-loading-container",visibility:L&&!I,duration:P,children:h.jsxs("span",{className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]})})]},v)})})}),h.jsx(Ae,{visibility:Ce||Te,className:"rac-select-buttons",children:h.jsxs(Me.TransitionGroup,{component:null,children:[Ce&&h.jsx(Ae,{style:{display:"grid"},duration:P,children:ce(m,{className:"rac-select-cancel",onMouseDown:J=>{J.preventDefault(),J.stopPropagation()},onClick:F})},"clear-icon")," ",Te&&h.jsx(Ae,{style:{display:"grid"},duration:P,children:ce(o,{className:`rac-select-arrow ${k?"--open":""} ${Y?"":"--up"}`})},"open-button")]})}),h.jsx(bt,{style:{"--rac-duration":`${P}ms`,...re},visibility:k&&i.length,onAnimationDone:()=>le(!0),setBottomDirection:ue,animateOpacity:W,className:_,selectRef:n,duration:P,unmount:r,easing:ie,offset:E,children:h.jsxs("div",{onScroll:D,className:"rac-select-list","aria-label":"Options",role:"listbox",tabIndex:"-1",children:[x,!y&&a&&h.jsxs("div",{className:"rac-select-option rac-disabled-option rac-loading-option",style:{justifyContent:"initial",alignItems:"end",gap:0},onClick:J=>J.stopPropagation(),children:[h.jsx("span",{className:"rac-loading-option-title",children:"Loading"}),h.jsx("div",{className:"rac-loading-container",children:h.jsxs("span",{style:{paddingBottom:"0.1em"},className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]})})]})]})})]})]})}),Et=["group","disabled","options","items","children"],Je=["name","label","id","value"],nt=[],Fe=(e,n=!1)=>{if(n&&typeof e.group=="string")return e.group;const s=Je.find(l=>e[l]!=null&&e[l]!=="");if(s)return String(e[s]);const c=Object.entries(e).find(([l,x])=>!Et.includes(l)&&x!=null&&x!=="");return c?String(c[1]):null};function wt({options:e=nt,jsxOptions:n=nt,value:s,onChange:c,disabled:l=!1,loading:x=!1,error:b=!1,multiple:g=!1,placeholder:j="Choose option",emptyText:i="No options",disabledText:v="Disabled",loadingText:k="Loading",errorText:d="Failed to load",disabledOption:R="Disabled option",emptyOption:N="Empty option",invalidOption:_="Invalid option",setVisibility:C,hasMore:O,loadButton:L,setLoadingTitle:I,loadingTitle:H,loadMoreText:Z,loadMore:Q,childrenFirst:G=!1,groupsClosed:U=!1}){const u=s!==void 0,[D,le]=t.useState(()=>{const a=new Set;if(U)return a;const y=p=>{Array.isArray(p)&&p.forEach($=>{if($&&typeof $=="object"){if(("options"in $||"group"in $&&!Je.some(Y=>Y in $))&&!$.disabled){const Y=Fe($,!0)||"Empty group";a.add(Y)}$.options&&y($.options)}})};return y(e),a}),F=t.useRef(null),q=t.useCallback(a=>{le(y=>{const p=new Set(y);return p.has(a)?p.delete(a):p.add(a),p})},[]),fe=t.useCallback((a,y,p="n",$=null,T=!1)=>{const Y=`${p}-${y}`;if(a==null||a===""||a===void 0)return{name:N,disabled:!0,type:"normal",groupDisabled:T,userId:null,raw:a,group:$,id:Y};if(typeof a=="function")return{id:Y,userId:null,name:_,raw:a,disabled:!0,invalid:!0,type:"normal",group:$};if(typeof a=="object"&&!Array.isArray(a)){const ue=$||a.group||null,oe=T||a.disabled===!0,xe=a.id??a.value??a.name??a.label,ee=a.value!==void 0?a.value:a.id!==void 0?a.id:a;let f=Fe(a)||(oe?R:N);return{id:Y,userId:xe,name:f,raw:ee,original:a,disabled:oe||f===N&&!oe,type:typeof ee=="boolean"?"boolean":"normal",group:ue,groupDisabled:T}}return{id:Y,userId:a,name:String(a),raw:a,original:a,disabled:T,type:typeof a=="boolean"?"boolean":"normal",group:$}},[N,_,R]),V=t.useMemo(()=>{const a=new Map,y=[],p=n.map((f,A)=>{if(f.isGroupMarker)return{...f,type:"group-marker"};const ne=!f.label&&!f.userId&&!f.value&&(f.value===void 0||f.value===null||f.value==="")&&!f.hasJsx;return{...f,id:`jsx-${f.id}`,index:A,userId:f.userId,raw:f.value,original:f.value,name:ne?N:f.label||f.userId||String(f.value||""),disabled:!!f.disabled||ne,type:typeof f.value=="boolean"?"boolean":"normal",group:f.group||null}});let $=0;const T=(f,A=null,ne=!1,he="0")=>{Array.isArray(f)||(f=[f]),f.forEach((z,ke)=>{const X=`${he}-${ke}`,be=z!=null&&typeof z=="object"&&!Array.isArray(z);if(be&&("options"in z||"group"in z&&!Je.some(te=>te in z))){const te=Fe(z,!0)||"Empty group";a.has(te)||a.set(te,{disabled:!!z.disabled,closedByDefault:!!z.disabled||U,items:[]}),z.options?T(z.options,te,ne||!!z.disabled,X):y.push({id:`empty-${te}-${X}`,name:te,group:te,isPlaceholder:!0,type:"group-marker",index:$++})}else if(be&&!Je.some(te=>te in z)&&!z.group)Object.entries(z).forEach(([te,Re],$e)=>{const Se=fe(Re,`${X}-${$e}`,"default",A,ne);y.push({...Se,index:$++})});else{const te=fe(z,X,"default",A,ne);y.push({...te,index:$++})}})};T(e);const Y=G?[...p,...y]:[...y,...p];if(!F.current)F.current=new Map(Y.map((f,A)=>[f.id,A]));else{let f=!1;if(Y.forEach(A=>{F.current.has(A.id)||(f=!0)}),f){const A=new Map;Y.forEach((ne,he)=>{A.set(ne.id,he)}),F.current=A}}const ue=[...Y].sort((f,A)=>{const ne=F.current.get(f.id)??999999,he=F.current.get(A.id)??999999;return ne-he}),oe=[],xe=new Set;ue.forEach(f=>{if(!f.group)oe.push({type:"item",data:f});else{xe.has(f.group)||(xe.add(f.group),oe.push({type:"group",name:f.group}));const A=a.get(f.group)||{items:[]};a.has(f.group)||a.set(f.group,A),f.isGroupMarker?(A.className=f.className,A.style=f.style,f.disabled&&(A.disabled=!0)):f.isPlaceholder||A.items.push(f)}});const ee=[];return oe.forEach(f=>{if(f.type==="item")ee.push(f.data);else{const A=f.name,ne=a.get(A),he=D.has(A);ee.push({className:ne?.className||"",id:`group-header-${A}`,disabled:!!ne?.disabled,style:ne?.style||{},groupHeader:!0,name:A,type:"group",hidden:!1,expanded:he}),ne?.items.forEach(z=>{const ke=D.size>0?!he:!!U;ee.push({...z,hidden:ke})})}}),O&&L&&ee.push({id:"special-load-more-id",name:H,loadMore:!0,loading:H===Z,type:"special"}),ee},[e,n,fe,G,O,L,H,Z,U,D,N]),re=t.useCallback(()=>{if(s==null||Array.isArray(s)&&s.length===0)return{initialId:null,initialIDs:[]};const a=new Set,y=(p,$)=>{let T=V.find(ue=>ue.original===p&&!a.has(ue.id));if(!T&&typeof p=="object")try{const ue=JSON.stringify(p);T=V.find(oe=>oe.original&&typeof oe.original=="object"&&JSON.stringify(oe.original)===ue&&!a.has(oe.id))}catch{}if(T)return a.add(T.id),T;const Y=typeof p=="object"?p.id||p.value||JSON.stringify(p):String(p);return typeof p=="object"&&p!==null?{id:`virtual-${Y}-${$}`,name:Fe(p)||String(p.id||"Selected Object"),raw:p.value??p.id??p,original:p,userId:p.id??p.value??null,virtual:!0}:{id:`virtual-${Y}-${$}`,name:String(p),raw:p,original:p,userId:p,virtual:!0}};if(g)return{initialId:null,initialIDs:(Array.isArray(s)?s:[s]).map((T,Y)=>y(T,Y))};{const p=Array.isArray(s)?s[0]:s;return{initialId:y(p,0).id,initialIDs:[]}}},[u,s,V,g]),[P,ie]=t.useState(()=>re().initialId),[E,W]=t.useState(()=>re().initialIDs),r=t.useMemo(()=>{const a=V.find(y=>y.id===P);if(a)return a;if(!g&&P?.startsWith("virtual-")){const y=Array.isArray(s)?s[0]:s;if(y)return{id:P,name:typeof y=="object"?Fe(y):String(y),original:y}}return null},[P,V,g,u,s]),o=t.useCallback((a,y)=>{if(a.groupHeader){m(y),a.disabled||q(a.name);return}if(a.disabled||a.loadMore){m(y),a.loadMore&&!a.loading&&(I(Z),Q());return}if(g){if(a.disabled||a.groupHeader||a.loadMore){m(y);return}m(y);const $=E?.some(T=>T.id===a.id)?E.filter(T=>T.id!==a.id):[...E,a];W($),c?.($.map(T=>T.original),$.map(T=>T.userId));return}ie(a.id),c?.(a.original,a.userId),C(!1)},[c,C,Q,Z,I,q,g,E]),m=t.useCallback(a=>{a?.stopPropagation(),a?.preventDefault()},[]),S=t.useCallback(()=>{c?.(null,null),ie(null),W([])},[c]),ce=t.useCallback(a=>{const y=E.filter(p=>p.id!==a);W(y),c?.(y.map(p=>p.original),y.map(p=>p.userId))},[E,c]);return{normalizedOptions:V,selected:r,selectOption:o,clear:S,removeOption:ce,hasOptions:V.length>0,active:!b&&!x&&!l&&V.length>0,selectedValue:s,placeholder:j,emptyText:i,disabledText:v,loadingText:k,errorText:d,disabledOption:R,emptyOption:N,invalidOption:_,disabled:l,loading:x,error:b,expandedGroups:D,toggleGroup:q,selectedIDs:E,multiple:g,setSelectedIds:W}}function vt({disabled:e,open:n,setOpen:s,options:c=[],selectOption:l,setDeleting:x,selected:b,selectedIDs:g,multiple:j,hasMore:i,loadMore:v,loadButton:k,loadButtonText:d,setLoadingTitle:R,loadOffset:N,loadAhead:_,expandedGroups:C,onOpen:O,onClose:L,deleting:I}){const H=t.useRef(!1),Z=t.useRef(0),Q=t.useRef(!1),[G,U]=t.useState(-1);t.useEffect(()=>{Q.current=!1,k&&R(d)},[c.length,i,k,d,R]);const u=t.useCallback(()=>{!i||Q.current||(Q.current=!0,v())},[i,v]),D=t.useCallback(E=>{if(k||!i||Q.current)return;const{scrollTop:W,scrollHeight:r,clientHeight:o}=E.currentTarget(r-W<=o+N)&&u()},[k,i,N,u]);t.useEffect(()=>{!k&&n&&i&&G>=c.length-_&&u()},[G,n,i,c.length,_,k,u]),t.useEffect(()=>{const E=()=>{Z.current=Date.now()};return window.addEventListener("focus",E),()=>window.removeEventListener("focus",E)},[]),t.useEffect(()=>{if(!n){U(-1);return}const E=c[G],W=E&&!E.hidden&&!E.groupHeader;if(G>=0&&G<c.length&&W)return;let r=-1;if(b&&!j){const o=j?b[0]:b;o&&(r=c.findIndex(m=>m.id===o.id&&!m.disabled&&!m.hidden&&!m.groupHeader))}if(j&&g.length){const o=new Set(g.map(m=>m.id));r=c.findIndex(m=>o.has(m.id)&&!m.disabled&&!m.hidden&&!m.groupHeader)}r===-1&&(r=c.findIndex(o=>!o.disabled&&!o.hidden&&!o.groupHeader)),U(r)},[n,c,b]);const le=t.useCallback((E,W)=>{const r=S=>S&&!S?.groupHeader&&(!S?.group||C?.has(S?.group))&&!S?.disabled&&!S?.loading,o=c.length;if(o===0)return-1;let m=E;for(let S=0;S<o;S++){if(m=(m+W+o)%o,!k&&i&&(W>0&&m===0||W<0&&m===o-1))return E;if(r(c[m]))return m}return E},[c,i,k,C]),F=t.useCallback(E=>{const W=E.relatedTarget?.closest(".rac-options");!E.currentTarget.contains(E.relatedTarget)&&!W&&(s(!1),x(!1))},[s]),q=t.useCallback(()=>{e||I||document.hidden||Date.now()-Z.current<100||n||(s(!0),H.current=!0,setTimeout(()=>H.current=!1,200))},[e,n,s,I]),fe=t.useRef(n),V=t.useRef(O),re=t.useRef(L);t.useEffect(()=>{V.current=O,re.current=L},[O,L]),t.useEffect(()=>{fe.current!==n&&(n?V.current?.():re.current?.(),fe.current=n)},[n]);const P=t.useCallback(E=>{e||I||E?.target?.closest(".rac-select-cancel")||H.current||s(!n)},[e,n,s,O,L,I]),ie=t.useCallback(E=>{if(!e)switch(E.key){case"Enter":case" ":E.preventDefault(),n?G!==-1&&c[G]&&l(c[G],E):s(!0);break;case"Escape":E.preventDefault(),s(!1);break;case"ArrowDown":E.preventDefault(),n?U(W=>le(W,1)):s(!0);break;case"ArrowUp":E.preventDefault(),n?U(W=>le(W,-1)):s(!0);break;case"Tab":n&&s(!1);break}},[e,n,s,G,c,l,le]);return t.useMemo(()=>({handleBlur:F,handleFocus:q,toggleVisibility:P,handleKeyDown:ie,highlightedIndex:G,setHighlightedIndex:U,handleListScroll:D}),[F,q,P,ie,G,D])}function St({visibility:e,children:n,duration:s=300,className:c}){const l=t.useRef(null),x=t.useCallback(()=>{if(!l.current)return{top:"0px",bottom:"0px"};const b=window.getComputedStyle(l.current);return{top:b.marginTop,bottom:b.marginBottom}},[]);return h.jsx(Me.CSSTransition,{onEnter:()=>{l.current.style.height="0px",l.current.style.marginTop="0px",l.current.style.marginBottom="0px"},onEntering:()=>{const{top:b,bottom:g}=x();l.current.style.height=l.current.scrollHeight+"px",l.current.style.marginBottom=g,l.current.style.marginTop=b},onEntered:()=>l.current.style.height="auto",onExit:()=>{const{top:b,bottom:g}=x();l.current.style.height=l.current.scrollHeight+"px",l.current.style.marginBottom=g,l.current.style.marginTop=b,l.current.offsetHeight},onExiting:()=>{l.current.style.height="0px",l.current.style.marginTop="0px",l.current.style.marginBottom="0px"},classNames:"rac-slide-down",timeout:s,nodeRef:l,in:e,unmountOnExit:!0,children:h.jsx("div",{style:{transition:`height ${s}ms ease, margin ${s}ms ease`,overflow:"hidden"},className:`${c} rac-slide-down-enter-done`,ref:l,tabIndex:-1,children:n})})}const Be=(e,n="invalid-option",s="")=>{const c=s?s.replace(/:/g,""):"";if(typeof e!="string"||!e.trim())return c?`${n}-${c}`:`${n}-${Math.random().toString(36).slice(2,8)}`;const l=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"-").replace(/[^\p{L}\p{N}-]+/gu,"").toLowerCase();return l?l||`${n}-${Math.random().toString(36).slice(2,8)}`:c?`${n}-${c}`:`${n}-${Math.random().toString(36).slice(2,8)}`},ze=(e,n)=>{if(!e)return null;const s=(c={})=>({...n,...c,style:{...n?.style,...c?.style}});if(typeof e=="string")return h.jsx("img",{src:e,...s(),alt:""});if(t.isValidElement(e))return t.cloneElement(e,s(e.props));if(typeof e=="function"||typeof e=="object"&&e.$$typeof){const c=e;return h.jsx(c,{...s()})}return null},jt=(e,n,s,c,l,x,b,g)=>{const j=g?.some(i=>i.id===e.id);return e.groupHeader?"rac-select-option rac-group-option":["rac-select-option",e.className,(j||c===e.id)&&"rac-selected",n===s&&"rac-highlighted",(e.disabled||e.loading)&&"rac-disabled-option",(e.invalid||e.name===b)&&"rac-invalid-option",e.loadMore&&l===x&&"rac-loading-option",typeof e.raw=="boolean"&&(e.raw?"rac-true-option":"rac-false-option")].filter(Boolean).join(" ")},kt=t.forwardRef(({unmount:e,children:n,visibility:s,setVisibility:c=()=>{},ownBehavior:l=!1,duration:x=300,easing:b="ease-in",offset:g=1,animateOpacity:j=!0,style:i={},className:v="",OpenIcon:k=gt,ClearIcon:d=et,DelIcon:R=et,Checkmark:N=pt,Checkbox:_=void 0,hasMore:C=!1,loadMore:O=()=>console.warn("loadMore not implemented"),loadButton:L=!1,loadButtonText:I="Load more",loadMoreText:H="Loading",selectedText:Z=void 0,loadOffset:Q=100,loadAhead:G=3,optionsClassName:U="",onOpen:u=()=>{},onClose:D=()=>{},deleteInline:le=!1,showDelete:F=!1,...q},fe)=>{const V=t.useId(),re=t.useMemo(()=>V.replace(/:/g,""),[V]),[P,ie]=t.useState([]),[E,W]=t.useState(!1),[r,o]=t.useState(L?I:H),[m,S]=t.useState(!1),ce=t.useRef(null),[a,y]=t.useState(!1),p=t.useCallback(M=>{ie(K=>{const se=K.findIndex(pe=>pe.id===M.id);if(se!==-1){const pe=K[se];if(pe.label===M.label&&pe.value===M.value&&pe.disabled===M.disabled&&pe.group===M.group)return K;const me=[...K];return me[se]=M,me}return[...K,M]})},[]),$=t.useCallback(M=>{ie(K=>{const se=K.filter(pe=>pe.id!==M);return se.length===K.length?K:se})},[]),T=s!==void 0,Y=t.useMemo(()=>l||T?!!s:E,[l,T,s,E]),ue=t.useCallback(M=>{l||(!T&&W(M),c?.(M))},[l,T,c]),oe=wt({...q,setVisibility:ue,jsxOptions:P,hasMore:C,loadButton:L,loadingTitle:r,loadMore:O,loadMoreText:H,setLoadingTitle:o}),{multiple:xe,normalizedOptions:ee,selected:f,selectOption:A,clear:ne,removeOption:he,hasOptions:z,active:ke,selectedValue:X,disabled:be,loading:ve,error:te,placeholder:Re,invalidOption:$e,emptyText:Se,disabledText:We,loadingText:Ye,errorText:Ge,expandedGroups:Ce,selectedIDs:Te,setSelectedIds:Ue}=oe,J=vt({setDeleting:y,setLoadingTitle:o,loadButton:L,loadButtonText:I,hasMore:C,loadMore:O,disabled:be,multiple:xe,open:Y,setOpen:ue,options:ee,selectOption:A,selected:f,loadOffset:Q,loadAhead:G,expandedGroups:Ce,selectedIDs:Te,onOpen:u,onClose:D,deleting:a}),{handleListScroll:B,handleBlur:ae,handleFocus:Oe,toggleVisibility:ye,handleKeyDown:Ee,highlightedIndex:de,setHighlightedIndex:ge}=J;t.useImperativeHandle(fe,()=>ce.current),t.useEffect(()=>{if(!Y){S(!1);return}Y&&ce.current&&document.activeElement!==ce.current&&ce.current.focus()},[Y]),t.useEffect(()=>{(te||be||ve||!z)&&ue(!1)},[te,be,ve,z,ue]),t.useEffect(()=>{T&&W(!!s)},[s,T]),t.useEffect(()=>{if(Y&&m&&de!==-1){const M=ee[de];M&&document.getElementById(`${re}-${Be(M.id)}`)?.scrollIntoView({block:"nearest"})}},[de,Y,m,ee,re]);const Ne=t.useMemo(()=>X!=null&&!(Array.isArray(X)&&X.length===0)&&!(typeof X=="object"&&Object.keys(X).length===0),[X]),Le=t.useMemo(()=>{if(te)return Ge;if(ve)return Ye;if(be)return We;if(Ne&&Z)return Z;if(f)return f.jsx??f.name;if(Ne){const M=ee.find(K=>K.raw===X);return M?M.name:typeof X=="object"&&X!==null?X.name??X.label??"Selected Object":String(X)}return z?Re:Se},[be,ve,te,z,f,X,Re,Ge,Ye,We,Se,Ne,ee]),Pe=t.useMemo(()=>{const M=[];let K=[],se=null;const pe=ee.reduce((w,we)=>(we.group&&(w[we.group]=(w[we.group]||0)+1),w),{}),me=w=>{w===null||K.length===0||(M.push(h.jsx(St,{visibility:Ce.has(w),className:"rac-group-container",children:K},`slide-${w}`)),K=[])},je=(w,we)=>h.jsxs("div",{className:jt(w,we,de,f?.id,r,H,$e,Te),style:{...w.style,...w.loading?{justifyContent:"initial",alignItems:"end",gap:0}:{}},onMouseEnter:()=>!w.disabled&&!w.loading&&ge(we),onClick:_e=>!w.loading&&A(w,_e),"aria-disabled":w.disabled||w.loading,"aria-selected":f?.id===w.id,id:`${re}-${Be(w.id)}`,role:"option",children:[w.jsx?h.jsx("div",{className:"rac-jsx-option",children:w.jsx}):h.jsx("span",{className:"rac-option-title",children:w.name}),w.loading&&h.jsxs("span",{style:{paddingBottom:"0.1em"},className:"rac-loading-dots",children:[h.jsx("i",{}),h.jsx("i",{}),h.jsx("i",{})]}),xe&&!w.disabled&&h.jsxs("div",{className:`rac-checkbox${_?"":"-default"}`,children:[ze(N,{style:{position:_?"":"relative"},className:`
|
|
15
|
-
rac-checkmark
|
|
16
|
-
${Te?.some(_e=>_e.id===w.id)?"--checked":""}`}),ze(_,{className:"rac-check-box"})]})]},w.id);return ee.forEach((w,we)=>{const _e=w.groupHeader,Xe=!!w.group;if((_e||!Xe&&se!==null)&&(me(se),_e||(se=null)),_e){se=w.name;const ot=Ce.has(w.name),at=pe[w.name]>0;M.push(h.jsxs("div",{className:["rac-group-header",w.disabled&&"rac-disabled-group",w.className].filter(Boolean).join(" "),onClick:lt=>A(w,lt),style:w.style,id:w.id,children:[h.jsx("span",{className:"rac-group-title-text",children:w.name}),h.jsx(Ae,{visibility:at&&!w.disabled,style:{display:"grid"},duration:x,children:ze(k,{className:`rac-group-arrow ${ot?"--open":""}`})})]},w.id))}else Xe?K.push(je(w,we)):M.push(je(w,we))}),me(se),M},[ee,A,re,f,de,r,H,$e,ge,Ce,k]);return h.jsx(xt,{setDeleting:y,deleting:a,selectedText:Z,selectRef:ce,selectId:re,selectedIDs:Te,setSelectedIds:Ue,multiple:xe,removeOption:he,optionsClassName:U,renderIcon:ze,normalizedOptions:ee,renderOptions:Pe,selected:f,title:Le,visibility:Y,active:ke,hasOptions:z,hasActualValue:Ne,highlightedIndex:de,animationFinished:m,disabled:be,loading:ve,error:te,setVisibility:ue,setHighlightedIndex:ge,setAnimationFinished:S,handleBlur:ae,handleFocus:Oe,toggleVisibility:ye,handleKeyDown:Ee,handleListScroll:B,selectOption:A,clear:ne,registerOption:p,unregisterOption:$,children:n,placeholder:Re,className:v,style:i,duration:x,easing:b,offset:g,animateOpacity:j,unmount:e,OpenIcon:k,ClearIcon:d,DelIcon:R,hasMore:C,loadButton:L,deleteInline:le,showDelete:F})}),it=t.createContext(null);function Rt({children:e,name:n,label:s,value:c,id:l,disabled:x,emptyGroupText:b="Empty group",className:g="",style:j={}}){const i=t.useContext(Ve),v=t.useMemo(()=>{const d=n??s??l??c;return d!=null&&d!==""?String(d):b},[n,s,c,l,b]),k=t.useMemo(()=>`group-marker-${Be(v)}`,[v]);return t.useEffect(()=>{if(!i)return;const d={disabled:!!x,isGroupMarker:!0,group:v,id:k,className:g,style:j};return i.registerOption(d),()=>i.unregisterOption(k)},[i.registerOption,i.unregisterOption,k,v]),h.jsx(it.Provider,{value:v,children:e})}const qe=e=>e?typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(qe).join(" ").replace(/\s+/g," ").trim():t.isValidElement(e)?qe(e.props.children):"":"";function $t({name:e,label:n,id:s,value:c,className:l,style:x,children:b,disabled:g,group:j}){const i=t.useContext(Ve),v=t.useContext(it),k=i?.registerOption,d=i?.unregisterOption,R=t.useId(),N=t.useMemo(()=>s?String(s):R.replace(/:/g,""),[s,R]);return t.useEffect(()=>{if(!k)return;const _=qe(b),C=b!=null;let O="";return n!=null&&n!==""?O=String(n):e!=null&&e!==""?O=String(e):_?O=_:s!=null&&s!==""&&(O=String(s)),k({id:N,value:c!==void 0?c:_,label:O,jsx:b,hasJsx:C,className:l,style:x,disabled:!!g,group:j||v||null}),()=>d(N)},[N,e,n,c,b,l,x,g,j,v,k,d]),null}exports.OptGroup=Rt;exports.Option=$t;exports.Select=kt;
|