mainstack-design-system 1.19.2 → 1.19.3

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.
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("./index-C8aODXfJ.cjs"),D=require("./index-4R9KShCu.cjs"),n=require("react"),I=require("./mainstack-design-system606.cjs"),y=require("./mainstack-design-system607.cjs"),b=n.forwardRef(({isDisabled:x,isError:C,isMultiSelect:s=!1,isSuccess:d,children:h,value:e,defaultValue:p,inputReadOnly:j,isCreatableSelect:q,options:u=[],isOptionOpen:A,onOptionOpenChange:P,onValueChange:f,onOptionSelect:R},r)=>{const O=n.useRef(null),[t,_]=n.useState(y.parseSelectOptions(u)),[i,v]=m.useControllableState({prop:e,defaultProp:y.mapDefaultValuesToSelectedOption({isMultiSelect:s,defaultValue:p,options:u}),onChange:f}),[E,l]=n.useState(()=>typeof e=="string"?t.map.get(e)?.label||"":typeof p=="string"&&t.map.get(p)?.label||""),[c,g]=m.useControllableState({prop:A,defaultProp:!1,onChange:P}),[T,S]=n.useState("idle");return n.useEffect(()=>{s||Array.isArray(e)||l(t.map.get(e)?.label||"")},[s,t.map,e]),a.jsx(I.SelectContext.Provider,{value:{defaultValue:p,options:t,selectedOption:i,isOptionOpen:c,isDisabled:x,isError:C,isMultiSelect:s,isSuccess:d,inputValue:E,inputReadOnly:j,previousAction:T,isCreatableSelect:q,rootElementRef:O,setOptions:_,setPreviousAction:S,setInputValue:l,setSelectedOption:v,onOptionOpenChange:g,onValueChange:f,onOptionSelect:R},children:a.jsx(D.Popover,{open:c,onOpenChange:o=>{console.log("open",o,c),g(c),i&&!Array.isArray(i)&&!o&&(l(t.map.get(i)?.label||""),S("selection"))},children:a.jsx("div",{ref:o=>{O.current=o,typeof r=="function"?r(o):typeof r=="object"&&r?.current&&(r.current=o)},"data-slot":"select-root",children:h})})})});b.displayName="SelectRoot";exports.SelectRoot=b;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),m=require("./index-C8aODXfJ.cjs"),D=require("./index-4R9KShCu.cjs"),n=require("react"),I=require("./mainstack-design-system606.cjs"),y=require("./mainstack-design-system607.cjs"),b=n.forwardRef(({isDisabled:x,isError:C,isMultiSelect:s=!1,isSuccess:d,children:h,value:e,defaultValue:i,inputReadOnly:j,isCreatableSelect:q,options:a=[],isOptionOpen:A,onOptionOpenChange:P,onValueChange:u,onOptionSelect:R},r)=>{const f=n.useRef(null),[t,_]=n.useState(y.parseSelectOptions(a)),[p,v]=m.useControllableState({prop:e,defaultProp:y.mapDefaultValuesToSelectedOption({isMultiSelect:s,defaultValue:i,options:a}),onChange:u}),[E,c]=n.useState(()=>typeof e=="string"?t.map.get(e)?.label||"":typeof i=="string"&&t.map.get(i)?.label||""),[O,S]=m.useControllableState({prop:A,defaultProp:!1,onChange:P}),[T,g]=n.useState("idle");return n.useEffect(()=>{s||Array.isArray(e)||c(t.map.get(e)?.label||"")},[s,t.map,e]),l.jsx(I.SelectContext.Provider,{value:{defaultValue:i,options:t,selectedOption:p,isOptionOpen:O,isDisabled:x,isError:C,isMultiSelect:s,isSuccess:d,inputValue:E,inputReadOnly:j,previousAction:T,isCreatableSelect:q,rootElementRef:f,setOptions:_,setPreviousAction:g,setInputValue:c,setSelectedOption:v,onOptionOpenChange:S,onValueChange:u,onOptionSelect:R},children:l.jsx(D.Popover,{open:O,onOpenChange:o=>{S(o),p&&!Array.isArray(p)&&!o&&(c(t.map.get(p)?.label||""),g("selection"))},children:l.jsx("div",{ref:o=>{f.current=o,typeof r=="function"?r(o):typeof r=="object"&&r?.current&&(r.current=o)},"data-slot":"select-root",children:h})})})});b.displayName="SelectRoot";exports.SelectRoot=b;
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import { jsx as c } from "react/jsx-runtime";
2
+ import { jsx as a } from "react/jsx-runtime";
3
3
  import { u as y } from "./index-437EL2iq.js";
4
4
  import { P as I } from "./index-RoCFhqzC.js";
5
- import { forwardRef as N, useRef as T, useState as a, useEffect as k } from "react";
5
+ import { forwardRef as N, useRef as T, useState as c, useEffect as k } from "react";
6
6
  import { SelectContext as q } from "./mainstack-design-system606.js";
7
7
  import { parseSelectOptions as z, mapDefaultValuesToSelectedOption as B } from "./mainstack-design-system607.js";
8
8
  const F = N(
@@ -12,41 +12,41 @@ const F = N(
12
12
  isMultiSelect: r = !1,
13
13
  isSuccess: A,
14
14
  children: C,
15
- value: o,
15
+ value: t,
16
16
  defaultValue: p,
17
17
  inputReadOnly: P,
18
18
  isCreatableSelect: S,
19
- options: m = [],
19
+ options: l = [],
20
20
  isOptionOpen: x,
21
21
  onOptionOpenChange: d,
22
- onValueChange: f,
22
+ onValueChange: m,
23
23
  onOptionSelect: j
24
24
  }, n) => {
25
- const O = T(null), [t, E] = a(
26
- z(m)
27
- ), [s, R] = y({
28
- prop: o,
25
+ const f = T(null), [o, E] = c(
26
+ z(l)
27
+ ), [i, R] = y({
28
+ prop: t,
29
29
  defaultProp: B({
30
30
  isMultiSelect: r,
31
31
  defaultValue: p,
32
- options: m
32
+ options: l
33
33
  }),
34
- onChange: f
35
- }), [v, l] = a(() => typeof o == "string" ? t.map.get(o)?.label || "" : typeof p == "string" && t.map.get(p)?.label || ""), [i, g] = y({
34
+ onChange: m
35
+ }), [v, s] = c(() => typeof t == "string" ? o.map.get(t)?.label || "" : typeof p == "string" && o.map.get(p)?.label || ""), [O, u] = y({
36
36
  prop: x,
37
37
  defaultProp: !1,
38
38
  onChange: d
39
- }), [D, u] = a("idle");
39
+ }), [D, g] = c("idle");
40
40
  return k(() => {
41
- r || Array.isArray(o) || l(t.map.get(o)?.label || "");
42
- }, [r, t.map, o]), /* @__PURE__ */ c(
41
+ r || Array.isArray(t) || s(o.map.get(t)?.label || "");
42
+ }, [r, o.map, t]), /* @__PURE__ */ a(
43
43
  q.Provider,
44
44
  {
45
45
  value: {
46
46
  defaultValue: p,
47
- options: t,
48
- selectedOption: s,
49
- isOptionOpen: i,
47
+ options: o,
48
+ selectedOption: i,
49
+ isOptionOpen: O,
50
50
  isDisabled: b,
51
51
  isError: h,
52
52
  isMultiSelect: r,
@@ -55,27 +55,27 @@ const F = N(
55
55
  inputReadOnly: P,
56
56
  previousAction: D,
57
57
  isCreatableSelect: S,
58
- rootElementRef: O,
58
+ rootElementRef: f,
59
59
  setOptions: E,
60
- setPreviousAction: u,
61
- setInputValue: l,
60
+ setPreviousAction: g,
61
+ setInputValue: s,
62
62
  setSelectedOption: R,
63
- onOptionOpenChange: g,
64
- onValueChange: f,
63
+ onOptionOpenChange: u,
64
+ onValueChange: m,
65
65
  onOptionSelect: j
66
66
  },
67
- children: /* @__PURE__ */ c(
67
+ children: /* @__PURE__ */ a(
68
68
  I,
69
69
  {
70
- open: i,
70
+ open: O,
71
71
  onOpenChange: (e) => {
72
- console.log("open", e, i), g(i), s && !Array.isArray(s) && !e && (l(t.map.get(s)?.label || ""), u("selection"));
72
+ u(e), i && !Array.isArray(i) && !e && (s(o.map.get(i)?.label || ""), g("selection"));
73
73
  },
74
- children: /* @__PURE__ */ c(
74
+ children: /* @__PURE__ */ a(
75
75
  "div",
76
76
  {
77
77
  ref: (e) => {
78
- O.current = e, typeof n == "function" ? n(e) : typeof n == "object" && n?.current && (n.current = e);
78
+ f.current = e, typeof n == "function" ? n(e) : typeof n == "object" && n?.current && (n.current = e);
79
79
  },
80
80
  "data-slot": "select-root",
81
81
  children: C
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),S=require("react"),N=require("./utils-BJ1u234q.cjs"),P=require("./mainstack-design-system606.cjs"),x=S.forwardRef(({value:e="",className:A,isGroupLabel:g,isDisabled:d,isCreatableOption:h,onClick:l,..._},I)=>{const{isOptionOpen:q,isMultiSelect:r,selectedOption:s,rootElementRef:p,isCreatableSelect:w,options:m,setOptions:C,setPreviousAction:j,setInputValue:f,onValueChange:n,onOptionSelect:o,onOptionOpenChange:R,setSelectedOption:u}=P.useSelectContext(),y=S.useMemo(()=>r&&Array.isArray(s)?s?.some(c=>e===c):!r&&!Array.isArray(s)?s===e:!1,[r,s,e]);return O.jsx("div",{"aria-disabled":d,className:" mds:aria-disabled:cursor-not-allowed",children:O.jsx("div",{role:"button","data-slot":"select-option-item",tabIndex:0,className:N.cn("mds:body-extrasmall-medium","mds:py-8 mds:px-10 mds:cursor-pointer mds:text-left mds:rounded-12 mds:aria-selected:bg-interactive-secondary-hover mds:aria-disabled:pointer-events-none mds:aria-disabled:opacity-40 mds:hover:bg-interactive-secondary-hover",A),"aria-selected":y,"data-select-options-opened":q,ref:I,"aria-disabled":d||g,onClick:c=>{if(l&&l(c),!e)return;j("selection");let i=m;if(h&&w&&!i.map.has(e)){i={...m};const t={value:e,label:e};i.array.push(t),i.map.set(t.value,t),C(i)}if(r){let t=s;if(Array.isArray(s))if(t=[...s],y){const a=t.findIndex(M=>M===e);a>-1&&t.splice(a,1)}else t.push(e);else t=[e];if(u(t),f(""),Array.isArray(t)&&n&&n(t),Array.isArray(t)&&o&&o(t.map(a=>i.map.get(a))),!p.current)return null;const b=p.current.querySelector('[data-slot="select-input-field"]');b&&b.focus()}else n&&e&&n(e),o&&e&&o(i.map.get(e)),f(i.map.get(e)?.label||""),u(e),R(!1)},..._})})});x.displayName="SelectOptionItem";exports.SelectOptionItem=x;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),x=require("react"),N=require("./utils-BJ1u234q.cjs"),P=require("./mainstack-design-system606.cjs"),A=x.forwardRef(({value:e="",className:g,isGroupLabel:h,isDisabled:d,isCreatableOption:_,onClick:l,...I},q)=>{const{isOptionOpen:w,isMultiSelect:r,selectedOption:s,rootElementRef:p,isCreatableSelect:C,options:m,setOptions:j,setPreviousAction:R,setInputValue:f,onValueChange:n,onOptionSelect:o,onOptionOpenChange:u,setSelectedOption:y}=P.useSelectContext(),b=x.useMemo(()=>r&&Array.isArray(s)?s?.some(c=>e===c):!r&&!Array.isArray(s)?s===e:!1,[r,s,e]);return S.jsx("div",{"aria-disabled":d,className:" mds:aria-disabled:cursor-not-allowed",children:S.jsx("div",{role:"button","data-slot":"select-option-item",tabIndex:0,className:N.cn("mds:body-extrasmall-medium","mds:py-8 mds:px-10 mds:cursor-pointer mds:text-left mds:rounded-12 mds:aria-selected:bg-interactive-secondary-hover mds:aria-disabled:pointer-events-none mds:aria-disabled:opacity-40 mds:hover:bg-interactive-secondary-hover",g),"aria-selected":b,"data-select-options-opened":w,ref:q,"aria-disabled":d||h,onClick:c=>{if(l&&l(c),!e)return;R("selection");let i=m;if(_&&C&&!i.map.has(e)){i={...m};const t={value:e,label:e};i.array.push(t),i.map.set(t.value,t),j(i)}if(r){let t=s;if(Array.isArray(s))if(t=[...s],b){const a=t.findIndex(M=>M===e);a>-1&&t.splice(a,1)}else t.push(e);else t=[e];if(y(t),f(""),Array.isArray(t)&&n&&n(t),Array.isArray(t)&&o&&o(t.map(a=>i.map.get(a))),!p.current)return null;const O=p.current.querySelector('[data-slot="select-input-field"]');O&&(O.focus(),u(!0))}else n&&e&&n(e),o&&e&&o(i.map.get(e)),f(i.map.get(e)?.label||""),y(e),u(!1)},...I})})});A.displayName="SelectOptionItem";exports.SelectOptionItem=A;
@@ -1,39 +1,39 @@
1
1
  'use client';
2
- import { jsx as O } from "react/jsx-runtime";
2
+ import { jsx as A } from "react/jsx-runtime";
3
3
  import { forwardRef as R, useMemo as V } from "react";
4
4
  import { c as j } from "./utils-DH-0D-9U.js";
5
5
  import { useSelectContext as q } from "./mainstack-design-system606.js";
6
6
  const E = R(
7
7
  ({
8
8
  value: e = "",
9
- className: A,
10
- isGroupLabel: h,
9
+ className: h,
10
+ isGroupLabel: x,
11
11
  isDisabled: p,
12
- isCreatableOption: x,
12
+ isCreatableOption: S,
13
13
  onClick: c,
14
- ...S
15
- }, g) => {
14
+ ...g
15
+ }, w) => {
16
16
  const {
17
- isOptionOpen: w,
17
+ isOptionOpen: I,
18
18
  isMultiSelect: s,
19
19
  selectedOption: r,
20
20
  rootElementRef: l,
21
- isCreatableSelect: I,
21
+ isCreatableSelect: C,
22
22
  options: m,
23
- setOptions: C,
24
- setPreviousAction: _,
23
+ setOptions: _,
24
+ setPreviousAction: N,
25
25
  setInputValue: f,
26
26
  onValueChange: o,
27
27
  onOptionSelect: n,
28
- onOptionOpenChange: N,
29
- setSelectedOption: y
30
- } = q(), u = V(() => s && Array.isArray(r) ? r?.some((d) => e === d) : !s && !Array.isArray(r) ? r === e : !1, [s, r, e]);
31
- return /* @__PURE__ */ O(
28
+ onOptionOpenChange: y,
29
+ setSelectedOption: u
30
+ } = q(), b = V(() => s && Array.isArray(r) ? r?.some((d) => e === d) : !s && !Array.isArray(r) ? r === e : !1, [s, r, e]);
31
+ return /* @__PURE__ */ A(
32
32
  "div",
33
33
  {
34
34
  "aria-disabled": p,
35
35
  className: " mds:aria-disabled:cursor-not-allowed",
36
- children: /* @__PURE__ */ O(
36
+ children: /* @__PURE__ */ A(
37
37
  "div",
38
38
  {
39
39
  role: "button",
@@ -42,46 +42,46 @@ const E = R(
42
42
  className: j(
43
43
  "mds:body-extrasmall-medium",
44
44
  "mds:py-8 mds:px-10 mds:cursor-pointer mds:text-left mds:rounded-12 mds:aria-selected:bg-interactive-secondary-hover mds:aria-disabled:pointer-events-none mds:aria-disabled:opacity-40 mds:hover:bg-interactive-secondary-hover",
45
- A
45
+ h
46
46
  ),
47
- "aria-selected": u,
48
- "data-select-options-opened": w,
49
- ref: g,
50
- "aria-disabled": p || h,
47
+ "aria-selected": b,
48
+ "data-select-options-opened": I,
49
+ ref: w,
50
+ "aria-disabled": p || x,
51
51
  onClick: (d) => {
52
52
  if (c && c(d), !e)
53
53
  return;
54
- _("selection");
54
+ N("selection");
55
55
  let i = m;
56
- if (x && I && !i.map.has(e)) {
56
+ if (S && C && !i.map.has(e)) {
57
57
  i = { ...m };
58
58
  const t = {
59
59
  value: e,
60
60
  label: e
61
61
  };
62
- i.array.push(t), i.map.set(t.value, t), C(i);
62
+ i.array.push(t), i.map.set(t.value, t), _(i);
63
63
  }
64
64
  if (s) {
65
65
  let t = r;
66
66
  if (Array.isArray(r))
67
- if (t = [...r], u) {
67
+ if (t = [...r], b) {
68
68
  const a = t.findIndex((M) => M === e);
69
69
  a > -1 && t.splice(a, 1);
70
70
  } else
71
71
  t.push(e);
72
72
  else
73
73
  t = [e];
74
- if (y(t), f(""), Array.isArray(t) && o && o(t), Array.isArray(t) && n && n(
74
+ if (u(t), f(""), Array.isArray(t) && o && o(t), Array.isArray(t) && n && n(
75
75
  t.map((a) => i.map.get(a))
76
76
  ), !l.current) return null;
77
- const b = l.current.querySelector(
77
+ const O = l.current.querySelector(
78
78
  '[data-slot="select-input-field"]'
79
79
  );
80
- b && b.focus();
80
+ O && (O.focus(), y(!0));
81
81
  } else
82
- o && e && o(e), n && e && n(i.map.get(e)), f(i.map.get(e)?.label || ""), y(e), N(!1);
82
+ o && e && o(e), n && e && n(i.map.get(e)), f(i.map.get(e)?.label || ""), u(e), y(!1);
83
83
  },
84
- ...S
84
+ ...g
85
85
  }
86
86
  )
87
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mainstack-design-system",
3
- "version": "1.19.2",
3
+ "version": "1.19.3",
4
4
  "type": "module",
5
5
  "main": "./dist/mainstack-design-system.cjs",
6
6
  "module": "./dist/mainstack-design-system.js",