react-animated-select 0.8.0 → 0.8.1

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/utils.js CHANGED
@@ -52,7 +52,7 @@ const C = {
52
52
  }
53
53
  });
54
54
  return typeof t == "string" ? /* @__PURE__ */ i("img", { src: t, ...n(), className: m("rac-icon", e?.className), alt: "" }) : p(t) ? w(t, n(t.props)) : typeof t == "function" || typeof t == "object" && t.$$typeof ? /* @__PURE__ */ i(t, { ...n() }) : null;
55
- }, M = (t, e) => `${t}-${String(e).replace(/[^A-Za-z0-9-]/gu, (n) => `_${n.codePointAt(0).toString(36)}_`)}`, b = (t) => t ? "" : void 0, m = (t, e) => e ? `${t} ${e}` : t, L = (t, e, n) => t.jsx || (e && "original" in t ? e(t.original, { selected: n, disabled: !!t.disabled }) : null), j = /* @__PURE__ */ f("span", { className: "rac-dots", "aria-hidden": "true", children: [
55
+ }, M = (t, e) => `${t}-${String(e).replace(/[^A-Za-z0-9-]/gu, (n) => `_${n.codePointAt(0).toString(36)}_`)}`, b = (t) => t ? "" : void 0, m = (t, e) => e ? `${t} ${e}` : t, L = (t, e, n) => t.jsx || (e && "original" in t ? e(t.original, { selected: n, disabled: !!t.disabled }) : null), S = /* @__PURE__ */ f("span", { className: "rac-dots", "aria-hidden": "true", children: [
56
56
  /* @__PURE__ */ i("i", {}),
57
57
  /* @__PURE__ */ i("i", {}),
58
58
  /* @__PURE__ */ i("i", {})
@@ -62,38 +62,38 @@ const C = {
62
62
  } catch {
63
63
  return !1;
64
64
  }
65
- })(), d = /* @__PURE__ */ new Set(), z = (t, e) => {
65
+ })(), d = /* @__PURE__ */ new Set(), j = (t, e) => {
66
66
  !v || d.has(t) || (d.add(t), console.warn(`[react-animated-select] ${e}`));
67
- }, D = (t) => {
67
+ }, z = (t) => {
68
68
  t?.stopPropagation(), t?.preventDefault();
69
- }, S = (t, e) => {
69
+ }, D = (t, e) => {
70
70
  t?.currentTarget.contains(document.activeElement) && e.current?.focus();
71
71
  }, h = "(prefers-reduced-motion: reduce)", y = () => !!window.matchMedia?.(h).matches, N = (t) => {
72
72
  const e = window.matchMedia?.(h);
73
73
  return e?.addEventListener("change", t), () => e?.removeEventListener("change", t);
74
74
  }, A = (t, e, n, r, u, s) => {
75
75
  if (!t || n === e.value) return;
76
- const o = getComputedStyle(t), c = e.anim ? o.height : e.root;
76
+ const o = getComputedStyle(t), a = e.anim?.playState === "running" ? o.height : e.root;
77
77
  e.anim?.cancel(), s && Object.assign(s.style, { height: `${n}px`, boxSizing: "border-box" }), e.root = o.height, s && Object.assign(s.style, { height: "", boxSizing: "" });
78
- const g = !e.value || c === e.root || !t.animate || y();
78
+ const g = !e.value || a === e.root || !t.animate || y();
79
79
  if (e.value = n, e.anim = null, g) return;
80
- const a = { overflow: "hidden", alignItems: "flex-start" }, l = e.anim = t.animate([{ ...a, height: c }, { ...a, height: e.root }], { duration: r, easing: u });
80
+ const c = { overflow: "hidden", alignItems: "flex-start" }, l = e.anim = t.animate([{ ...c, height: a }, { ...c, height: e.root }], { duration: r, easing: u });
81
81
  l.onfinish = () => {
82
82
  e.anim === l && (e.anim = null);
83
83
  };
84
84
  };
85
85
  export {
86
- j as dots,
86
+ S as dots,
87
87
  b as flag,
88
88
  A as followHeight,
89
89
  C as icons,
90
90
  L as optionContent,
91
91
  M as optionDomId,
92
92
  y as reducedMotion,
93
- S as refocus,
93
+ D as refocus,
94
94
  $ as renderIcon,
95
- D as stopEvent,
96
- z as warnOnce,
95
+ z as stopEvent,
96
+ j as warnOnce,
97
97
  N as watchMotion,
98
98
  m as withClass
99
99
  };
package/index.d.ts CHANGED
@@ -43,6 +43,11 @@ export interface SelectIcons {
43
43
  checkbox: SelectIcon
44
44
  }
45
45
 
46
+ /** An extension passed to `<Select plugins={[...]}/>`: use the built-in `chips` and `paging`. */
47
+ export interface SelectPlugin {
48
+ readonly [key: string]: unknown
49
+ }
50
+
46
51
  export interface SelectProps extends AriaAttributes {
47
52
  [key: `data-${string}`]: string | number | boolean | undefined
48
53
 
@@ -58,6 +63,8 @@ export interface SelectProps extends AriaAttributes {
58
63
  /** value: an array item as given (an object stays the whole object), an <Option/> as its `value`; a controlled value must have the shape of its source. */
59
64
  onChange?: (value: any, ids: any) => void
60
65
  multiple?: boolean
66
+ /** Optional features: `[chips]` for chips in a multiple Select, `[paging]` for `hasMore` / `loadMore` / `loadButton`. */
67
+ plugins?: SelectPlugin[]
61
68
  childrenFirst?: boolean
62
69
  groupsClosed?: boolean
63
70
 
@@ -158,6 +165,12 @@ export interface SelectProps extends AriaAttributes {
158
165
 
159
166
  export const Select: FC<SelectProps>
160
167
 
168
+ /** Plugin: chips for the selected values of a multiple Select. */
169
+ export const chips: SelectPlugin
170
+
171
+ /** Plugin: loading more options (`hasMore`, `loadMore`, `loadButton`, `loadOffset`, `loadAhead`). */
172
+ export const paging: SelectPlugin
173
+
161
174
  export interface OptionProps {
162
175
  value?: any
163
176
  id?: any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-animated-select",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "l1nway",