@stokelp/ui 2.121.0 → 2.122.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.
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../utils/slots.cjs"),n=require("../../tag/Tag.cjs"),r=require("../../icon/Icon.cjs"),i=require("../../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/ArrowLeftCircleIcon.cjs");let a=require("@stokelp/styled-system/jsx"),o=require("@stokelp/styled-system/recipes"),s=require("react/jsx-runtime");var c=e.__exportAll({Body:()=>m,Footer:()=>x,Header:()=>p,Item:()=>h,ItemAlpha:()=>b,ItemContent:()=>_,ItemIcon:()=>y,ItemLabel:()=>v,ItemSubItems:()=>g,MiniaturizeTrigger:()=>S,Root:()=>f}),{withProvider:l,withContext:u}=t.createStyleContext(o.appNavigation,{dataAttr:!0}),d=e=>(0,a.styled)(e),f=l(d(`nav`),`root`,{defaultProps:{}}),p=u(d(`header`),`header`),m=u(d(`main`),`body`),h=u(d(`div`),`item`),g=u(d(`div`),`itemSubItems`),_=u(d(`div`),`itemContent`),v=u(d(`p`),`itemLabel`),y=u(r.Icon,`itemIcon`,{defaultProps:{size:`sm`}}),b=u(n.Tag,`itemAlpha`,{defaultProps:{severity:`success`}}),x=u(d(`footer`),`footer`),S=u(d(`div`),`miniaturizeTrigger`,{defaultProps:{onClick:e=>{e.preventDefault();let t=localStorage.getItem(`isMiniaturizeNav`)===`closed`?`open`:`closed`;localStorage.setItem(`isMiniaturizeNav`,t),e.currentTarget.setAttribute(`data-state`,t),window.dispatchEvent(new Event(`storage`))},className:`app-navigation__miniaturizeTrigger`,"data-state":typeof localStorage<`u`&&localStorage.getItem(`isMiniaturizeNav`)||`open`,children:(0,s.jsx)(r.Icon,{children:(0,s.jsx)(i.default,{})})}});Object.defineProperty(exports,"AppNavigation_exports",{enumerable:!0,get:function(){return c}});
1
+ "use client";const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../utils/slots.cjs"),n=require("../../tag/Tag.cjs"),r=require("../../icon/Icon.cjs"),i=require("../../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/ArrowLeftCircleIcon.cjs");let a=require("@stokelp/styled-system/jsx"),o=require("@stokelp/styled-system/recipes"),s=require("react/jsx-runtime");var c=e.__exportAll({Body:()=>_,Footer:()=>w,Header:()=>g,Item:()=>v,ItemAlpha:()=>C,ItemContent:()=>b,ItemIcon:()=>S,ItemLabel:()=>x,ItemSubItems:()=>y,MiniaturizeTrigger:()=>T,Root:()=>h}),{withProvider:l,withContext:u}=t.createStyleContext(o.appNavigation,{dataAttr:!0}),d=`isMiniaturizeNav`,f=()=>{try{return localStorage.getItem(d)===`closed`?`closed`:`open`}catch{return`open`}},p=e=>{try{localStorage.setItem(d,e)}catch{}},m=e=>(0,a.styled)(e),h=l(m(`nav`),`root`,{defaultProps:{}}),g=u(m(`header`),`header`),_=u(m(`main`),`body`),v=u(m(`div`),`item`),y=u(m(`div`),`itemSubItems`),b=u(m(`div`),`itemContent`),x=u(m(`p`),`itemLabel`),S=u(r.Icon,`itemIcon`,{defaultProps:{size:`sm`}}),C=u(n.Tag,`itemAlpha`,{defaultProps:{severity:`success`}}),w=u(m(`footer`),`footer`),T=u(m(`div`),`miniaturizeTrigger`,{defaultProps:{onClick:e=>{e.preventDefault();let t=f()===`closed`?`open`:`closed`;p(t),e.currentTarget.setAttribute(`data-state`,t),window.dispatchEvent(new Event(`storage`))},className:`app-navigation__miniaturizeTrigger`,...{get"data-state"(){return f()}},children:(0,s.jsx)(r.Icon,{children:(0,s.jsx)(i.default,{})})}});Object.defineProperty(exports,"AppNavigation_exports",{enumerable:!0,get:function(){return c}});
2
2
  //# sourceMappingURL=AppNavigation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppNavigation.cjs","names":[],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {\n //'data-state': localStorage.getItem('isMiniaturizeNav') || 'open',\n },\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const currentState = localStorage.getItem('isMiniaturizeNav')\n const newState = currentState === 'closed' ? 'open' : 'closed'\n localStorage.setItem('isMiniaturizeNav', newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n 'data-state': typeof localStorage !== 'undefined' ? localStorage.getItem('isMiniaturizeNav') || 'open' : 'open',\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":"snBASM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,cAAe,CACtE,SAAU,EACZ,CAAC,EAGK,EAAoD,IAAA,EAAA,EAAA,QACjD,CAAG,EAEC,EAAO,EAAa,EAAU,KAAK,EAAG,OAAQ,CACzD,aAAc,CAEd,CACF,CAAC,EACY,EAAS,EAAY,EAAU,QAAQ,EAAG,QAAQ,EAClD,EAAO,EAAY,EAAU,MAAM,EAAG,MAAM,EAE5C,EAAO,EAAY,EAAU,KAAK,EAAG,MAAM,EAC3C,EAAe,EAAY,EAAU,KAAK,EAAG,cAAc,EAC3D,EAAc,EAAY,EAAU,KAAK,EAAG,aAAa,EACzD,EAAY,EAAY,EAAU,GAAG,EAAG,WAAW,EACnD,EAAW,EAAY,EAAA,KAAM,WAAY,CACpD,aAAc,CACZ,KAAM,IACR,CACF,CAAC,EACY,EAAY,EAAY,EAAA,IAAK,YAAa,CACrD,aAAc,CACZ,SAAU,SACZ,CACF,CAAC,EAEY,EAAS,EAAY,EAAU,QAAQ,EAAG,QAAQ,EAElD,EAAqB,EAAY,EAAU,KAAK,EAAG,qBAAsB,CACpF,aAAc,CACZ,QAAU,GAAkC,CAC1C,EAAE,eAAe,EAEjB,IAAM,EADe,aAAa,QAAQ,kBACzB,IAAiB,SAAW,OAAS,SACtD,aAAa,QAAQ,mBAAoB,CAAQ,EACjD,EAAE,cAAc,aAAa,aAAc,CAAQ,EACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC,CAC3C,EACA,UAAW,qCAET,aAAc,OAAO,aAAiB,KAAc,aAAa,QAAQ,kBAAkB,GAAc,OAE3G,UACE,EAAA,EAAA,KAAC,EAAA,KAAD,CAAA,UACE,EAAA,EAAA,KAAC,EAAA,QAAD,CAAsB,CAAA,CAClB,CAAA,CAEV,CACF,CAAC"}
1
+ {"version":3,"file":"AppNavigation.cjs","names":[],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":"snBASM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,cAAe,CACtE,SAAU,EACZ,CAAC,EAEK,EAA0B,mBAa1B,MAA+C,CACnD,GAAI,CACF,OAAO,aAAa,QAAQ,CAAuB,IAAM,SAAW,SAAW,MACjF,MAAQ,CACN,MAAO,MACT,CACF,EAEM,EAAyB,GAAkC,CAC/D,GAAI,CACF,aAAa,QAAQ,EAAyB,CAAK,CACrD,MAAQ,CAGR,CACF,EAGM,EAAoD,IAAA,EAAA,EAAA,QACjD,CAAG,EAEC,EAAO,EAAa,EAAU,KAAK,EAAG,OAAQ,CACzD,aAAc,CAAC,CACjB,CAAC,EACY,EAAS,EAAY,EAAU,QAAQ,EAAG,QAAQ,EAClD,EAAO,EAAY,EAAU,MAAM,EAAG,MAAM,EAE5C,EAAO,EAAY,EAAU,KAAK,EAAG,MAAM,EAC3C,EAAe,EAAY,EAAU,KAAK,EAAG,cAAc,EAC3D,EAAc,EAAY,EAAU,KAAK,EAAG,aAAa,EACzD,EAAY,EAAY,EAAU,GAAG,EAAG,WAAW,EACnD,EAAW,EAAY,EAAA,KAAM,WAAY,CACpD,aAAc,CACZ,KAAM,IACR,CACF,CAAC,EACY,EAAY,EAAY,EAAA,IAAK,YAAa,CACrD,aAAc,CACZ,SAAU,SACZ,CACF,CAAC,EAEY,EAAS,EAAY,EAAU,QAAQ,EAAG,QAAQ,EAElD,EAAqB,EAAY,EAAU,KAAK,EAAG,qBAAsB,CACpF,aAAc,CACZ,QAAU,GAAkC,CAC1C,EAAE,eAAe,EACjB,IAAM,EAAW,EAAqB,IAAM,SAAW,OAAS,SAChE,EAAsB,CAAQ,EAC9B,EAAE,cAAc,aAAa,aAAc,CAAQ,EACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC,CAC3C,EACA,UAAW,qCACX,GAAG,CAOD,GAAI,cAAe,CACjB,OAAO,EAAqB,CAC9B,CACF,EACA,UACE,EAAA,EAAA,KAAC,EAAA,KAAD,CAAA,UACE,EAAA,EAAA,KAAC,EAAA,QAAD,CAAsB,CAAA,CAClB,CAAA,CAEV,CACF,CAAC"}
@@ -9,25 +9,37 @@ import { appNavigation as o } from "@stokelp/styled-system/recipes";
9
9
  import { jsx as s } from "react/jsx-runtime";
10
10
  //#region src/components/app/navigation/AppNavigation.tsx
11
11
  var c = /* @__PURE__ */ e({
12
- Body: () => m,
13
- Footer: () => x,
14
- Header: () => p,
15
- Item: () => h,
16
- ItemAlpha: () => b,
17
- ItemContent: () => _,
18
- ItemIcon: () => y,
19
- ItemLabel: () => v,
20
- ItemSubItems: () => g,
21
- MiniaturizeTrigger: () => S,
22
- Root: () => f
23
- }), { withProvider: l, withContext: u } = t(o, { dataAttr: !0 }), d = (e) => a(e), f = l(d("nav"), "root", { defaultProps: {} }), p = u(d("header"), "header"), m = u(d("main"), "body"), h = u(d("div"), "item"), g = u(d("div"), "itemSubItems"), _ = u(d("div"), "itemContent"), v = u(d("p"), "itemLabel"), y = u(r, "itemIcon", { defaultProps: { size: "sm" } }), b = u(n, "itemAlpha", { defaultProps: { severity: "success" } }), x = u(d("footer"), "footer"), S = u(d("div"), "miniaturizeTrigger", { defaultProps: {
12
+ Body: () => _,
13
+ Footer: () => w,
14
+ Header: () => g,
15
+ Item: () => v,
16
+ ItemAlpha: () => C,
17
+ ItemContent: () => b,
18
+ ItemIcon: () => S,
19
+ ItemLabel: () => x,
20
+ ItemSubItems: () => y,
21
+ MiniaturizeTrigger: () => T,
22
+ Root: () => h
23
+ }), { withProvider: l, withContext: u } = t(o, { dataAttr: !0 }), d = "isMiniaturizeNav", f = () => {
24
+ try {
25
+ return localStorage.getItem(d) === "closed" ? "closed" : "open";
26
+ } catch {
27
+ return "open";
28
+ }
29
+ }, p = (e) => {
30
+ try {
31
+ localStorage.setItem(d, e);
32
+ } catch {}
33
+ }, m = (e) => a(e), h = l(m("nav"), "root", { defaultProps: {} }), g = u(m("header"), "header"), _ = u(m("main"), "body"), v = u(m("div"), "item"), y = u(m("div"), "itemSubItems"), b = u(m("div"), "itemContent"), x = u(m("p"), "itemLabel"), S = u(r, "itemIcon", { defaultProps: { size: "sm" } }), C = u(n, "itemAlpha", { defaultProps: { severity: "success" } }), w = u(m("footer"), "footer"), T = u(m("div"), "miniaturizeTrigger", { defaultProps: {
24
34
  onClick: (e) => {
25
35
  e.preventDefault();
26
- let t = localStorage.getItem("isMiniaturizeNav") === "closed" ? "open" : "closed";
27
- localStorage.setItem("isMiniaturizeNav", t), e.currentTarget.setAttribute("data-state", t), window.dispatchEvent(new Event("storage"));
36
+ let t = f() === "closed" ? "open" : "closed";
37
+ p(t), e.currentTarget.setAttribute("data-state", t), window.dispatchEvent(new Event("storage"));
28
38
  },
29
39
  className: "app-navigation__miniaturizeTrigger",
30
- "data-state": typeof localStorage < "u" && localStorage.getItem("isMiniaturizeNav") || "open",
40
+ ...{ get "data-state"() {
41
+ return f();
42
+ } },
31
43
  children: /* @__PURE__ */ s(r, { children: /* @__PURE__ */ s(i, {}) })
32
44
  } });
33
45
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"AppNavigation.js","names":[],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {\n //'data-state': localStorage.getItem('isMiniaturizeNav') || 'open',\n },\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const currentState = localStorage.getItem('isMiniaturizeNav')\n const newState = currentState === 'closed' ? 'open' : 'closed'\n localStorage.setItem('isMiniaturizeNav', newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n 'data-state': typeof localStorage !== 'undefined' ? localStorage.getItem('isMiniaturizeNav') || 'open' : 'open',\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IASM,EAAE,iBAAc,mBAAgB,EAAmB,GAAe,EACtE,UAAU,GACZ,CAAC,GAGK,KAAoD,MACxD,EAAO,CAAG,GAEC,IAAO,EAAa,EAAU,KAAK,GAAG,QAAQ,EACzD,cAAc,CAEd,EACF,CAAC,GACY,IAAS,EAAY,EAAU,QAAQ,GAAG,QAAQ,GAClD,IAAO,EAAY,EAAU,MAAM,GAAG,MAAM,GAE5C,IAAO,EAAY,EAAU,KAAK,GAAG,MAAM,GAC3C,IAAe,EAAY,EAAU,KAAK,GAAG,cAAc,GAC3D,IAAc,EAAY,EAAU,KAAK,GAAG,aAAa,GACzD,IAAY,EAAY,EAAU,GAAG,GAAG,WAAW,GACnD,IAAW,EAAY,GAAM,YAAY,EACpD,cAAc,EACZ,MAAM,KACR,EACF,CAAC,GACY,IAAY,EAAY,GAAK,aAAa,EACrD,cAAc,EACZ,UAAU,UACZ,EACF,CAAC,GAEY,IAAS,EAAY,EAAU,QAAQ,GAAG,QAAQ,GAElD,IAAqB,EAAY,EAAU,KAAK,GAAG,sBAAsB,EACpF,cAAc;CACZ,UAAU,MAAkC;EAC1C,EAAE,eAAe;EAEjB,IAAM,IADe,aAAa,QAAQ,kBACzB,MAAiB,WAAW,SAAS;EAGtD,AAFA,aAAa,QAAQ,oBAAoB,CAAQ,GACjD,EAAE,cAAc,aAAa,cAAc,CAAQ,GACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC;CAC3C;CACA,WAAW;CAET,cAAc,OAAO,eAAiB,OAAc,aAAa,QAAQ,kBAAkB,KAAc;CAE3G,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,CAAsB,CAAA,EAClB,CAAA;AAEV,EACF,CAAC"}
1
+ {"version":3,"file":"AppNavigation.js","names":[],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IASM,EAAE,iBAAc,mBAAgB,EAAmB,GAAe,EACtE,UAAU,GACZ,CAAC,GAEK,IAA0B,oBAa1B,UAA+C;CACnD,IAAI;EACF,OAAO,aAAa,QAAQ,CAAuB,MAAM,WAAW,WAAW;CACjF,QAAQ;EACN,OAAO;CACT;AACF,GAEM,KAAyB,MAAkC;CAC/D,IAAI;EACF,aAAa,QAAQ,GAAyB,CAAK;CACrD,QAAQ,CAGR;AACF,GAGM,KAAoD,MACxD,EAAO,CAAG,GAEC,IAAO,EAAa,EAAU,KAAK,GAAG,QAAQ,EACzD,cAAc,CAAC,EACjB,CAAC,GACY,IAAS,EAAY,EAAU,QAAQ,GAAG,QAAQ,GAClD,IAAO,EAAY,EAAU,MAAM,GAAG,MAAM,GAE5C,IAAO,EAAY,EAAU,KAAK,GAAG,MAAM,GAC3C,IAAe,EAAY,EAAU,KAAK,GAAG,cAAc,GAC3D,IAAc,EAAY,EAAU,KAAK,GAAG,aAAa,GACzD,IAAY,EAAY,EAAU,GAAG,GAAG,WAAW,GACnD,IAAW,EAAY,GAAM,YAAY,EACpD,cAAc,EACZ,MAAM,KACR,EACF,CAAC,GACY,IAAY,EAAY,GAAK,aAAa,EACrD,cAAc,EACZ,UAAU,UACZ,EACF,CAAC,GAEY,IAAS,EAAY,EAAU,QAAQ,GAAG,QAAQ,GAElD,IAAqB,EAAY,EAAU,KAAK,GAAG,sBAAsB,EACpF,cAAc;CACZ,UAAU,MAAkC;EAC1C,EAAE,eAAe;EACjB,IAAM,IAAW,EAAqB,MAAM,WAAW,SAAS;EAGhE,AAFA,EAAsB,CAAQ,GAC9B,EAAE,cAAc,aAAa,cAAc,CAAQ,GACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC;CAC3C;CACA,WAAW;CACX,GAAG,EAOD,IAAI,eAAe;EACjB,OAAO,EAAqB;CAC9B,EACF;CACA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,CAAsB,CAAA,EAClB,CAAA;AAEV,EACF,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../input/Input.cjs"),a=require("../chip/Chip.cjs");let o=require("@ark-ui/react"),s=require("@stokelp/styled-system/jsx"),c=require("@stokelp/styled-system/recipes"),l=require("react"),u=require("react/jsx-runtime"),d=require("@stokelp/styled-system/css"),f=require("react-window"),p=require("lodash");var{withProvider:m,withContext:h}=e.createStyleContext(c.combobox),g=m((0,s.styled)(o.Combobox.Root),`root`,{defaultProps:{loopFocus:!0}}),_=h((0,s.styled)(o.Combobox.ClearTrigger),`clearTrigger`),v=h((0,s.styled)(o.Combobox.Content),`content`),y=h((0,s.styled)(o.Combobox.Input),`input`),b=h((0,s.styled)(o.Combobox.Control),`control`),x=h((0,s.styled)(o.Combobox.Item),`item`),S=h((0,s.styled)(o.Combobox.ItemText),`itemText`),C=h((0,s.styled)(o.Combobox.Positioner),`positioner`),w=h((0,s.styled)(o.Combobox.Trigger),`trigger`),T=()=>(0,u.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,u.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,u.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,d.css)({stroke:`grey.100`})})]}),E=()=>(0,u.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,u.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,d.css)({fill:`primary.500`})}),(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function D({item:e,isMultiple:t,renderItem:n}){let r=(0,o.useComboboxItemContext)();return(0,u.jsxs)(u.Fragment,{children:[t?r.selected?(0,u.jsx)(E,{}):(0,u.jsx)(T,{}):null,n?n(e):(0,u.jsx)(S,{truncate:!0,children:e.label})]})}var O=({items:e=[],initialItems:s,debounceMs:c=0,placeholder:d,emptyLabel:m,loadingLabel:h,usePortal:S=!0,withAutoFilter:T=!0,positioning:E,loadItems:O,renderItem:k,renderValue:A,onResetInitialItems:j,isLoading:M,value:N,openDropdownOnFocus:P=!0,clearValueWhenEmpty:F=!0,virtualized:ee,rowHeight:I=34,returnItemsOnEmpty:L,multiple:R=!1,...z})=>{let[B,V]=(0,l.useState)(()=>e),[H,U]=(0,l.useState)(!1),[W,G]=(0,l.useState)(!1),K=typeof O==`function`,q=(0,l.useMemo)(()=>O?(0,p.debounce)(async e=>{try{G(!0),U(!0),V(await O(e))}catch(e){console.error(e),V([])}finally{U(!1)}},c):null,[O,c]),J=[...B,...s??[]],Y=(0,l.useCallback)(async t=>{s&&s.length>0&&!s.find(e=>e.label===t.inputValue)&&j?.();let{inputValue:n}=t;if(q)q(n);else{let t=T&&n!==``?e.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())):e;if(t.length===0&&L)return V(e);V(t)}},[q,e,T]);(0,l.useEffect)(()=>{q||V(e)},[e,q]);let X=(0,l.useMemo)(()=>(0,o.createListCollection)({items:J}),[J]),Z=M??H,Q=h??(0,u.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:`Chargement...`}),$=m??(0,u.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:`Aucun résultat`});return(0,u.jsxs)(g,{lazyMount:!0,unmountOnExit:!0,collection:X,positioning:{sameWidth:!0,gutter:0,...E},"data-recipe":`combobox`,onInputValueChange:Y,value:N,...z,multiple:R,children:[R?(0,u.jsx)(o.Combobox.Context,{children:t=>(0,u.jsxs)(b,{"data-multiple":`true`,"data-open":t.open||void 0,children:[t.value.map(n=>{let r=e.find(e=>String(e.value)===String(n));return r?(0,u.jsxs)(a.Chip,{size:`sm`,children:[A?A(r):(0,u.jsx)(a.ChipLabel,{children:r.label}),!z.readOnly&&!z.disabled&&(0,u.jsx)(a.ChipClearTrigger,{"aria-label":`Retirer ${r.label}`,onClick:()=>t.setValue(t.value.filter(e=>String(e)!==String(n)))})]},n):null}),(0,u.jsx)(y,{asChild:!0,"data-multiple":`true`,placeholder:t.hasSelectedItems?void 0:d,onFocus:()=>{!P||K||t.setOpen(!0)},children:(0,u.jsx)(i.Input,{})}),(0,u.jsx)(w,{asChild:!0,hidden:K&&(!s||s.length===0),children:(0,u.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]})}):(0,u.jsxs)(b,{children:[(0,u.jsx)(o.Combobox.Context,{children:e=>(0,u.jsx)(y,{asChild:!0,placeholder:d,onInput:t=>{let n=t.currentTarget.value;F&&n===``&&e.clearValue()},onFocus:()=>{!P||K||e.setOpen(!0)},children:(0,u.jsx)(i.Input,{})})}),(0,u.jsx)(w,{asChild:!0,hidden:K&&(!s||s.length===0),children:(0,u.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})}),(0,u.jsx)(_,{disabled:z.readOnly,onClick:j,asChild:!0,children:(0,u.jsx)(`button`,{children:(0,u.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,u.jsx)(r.ConditionalWrapper,{when:S,wrapper:e=>(0,u.jsx)(o.Portal,{children:e}),children:(0,u.jsx)(C,{children:(0,u.jsx)(v,{children:Z?Q:J.length===0?(0,u.jsx)(u.Fragment,{children:K?W?$:Q:$}):ee?(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(f.FixedSizeList,{height:Math.min(I*J.length,180),itemCount:J.length,itemSize:I,width:`100%`,children:({index:e,style:n})=>(0,u.jsx)(r.ConditionalWrapper,{when:!!J[e].tooltip,wrapper:n=>(0,u.jsx)(t.Tooltip,{label:J[e].tooltip,children:n}),children:(0,u.jsx)(x,{item:J[e],style:n,children:(0,u.jsx)(D,{renderItem:k,item:J[e],isMultiple:R})},J[e].value)},J[e].value)})}):J.map(e=>(0,u.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,u.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,u.jsx)(x,{item:e,children:(0,u.jsx)(D,{renderItem:k,item:e,isMultiple:R})},e.value)},e.value))})})})]})};exports.Combobox=O;
1
+ "use client";const e=require("../../utils/slots.cjs"),t=require("../tooltip/Tooltip.cjs"),n=require("../text/Text.cjs"),r=require("../../shared/ConditionalWrapper.cjs"),i=require("../input/Input.cjs"),a=require("../chip/Chip.cjs");let o=require("@ark-ui/react"),s=require("@stokelp/styled-system/jsx"),c=require("@stokelp/styled-system/recipes"),l=require("react"),u=require("react/jsx-runtime"),d=require("@stokelp/styled-system/css"),f=require("react-window"),p=require("lodash");var{withProvider:m,withContext:h}=e.createStyleContext(c.combobox),g=m((0,s.styled)(o.Combobox.Root),`root`,{defaultProps:{loopFocus:!0}}),_=h((0,s.styled)(o.Combobox.ClearTrigger),`clearTrigger`),v=h((0,s.styled)(o.Combobox.Content),`content`),y=h((0,s.styled)(o.Combobox.Input),`input`),b=h((0,s.styled)(o.Combobox.Control),`control`),x=h((0,s.styled)(o.Combobox.Item),`item`),S=h((0,s.styled)(o.Combobox.ItemText),`itemText`),C=h((0,s.styled)(o.Combobox.Positioner),`positioner`),w=h((0,s.styled)(o.Combobox.Trigger),`trigger`),T=()=>(0,u.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,u.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,u.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,d.css)({stroke:`grey.100`})})]}),E=()=>(0,u.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,u.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,d.css)({fill:`primary.500`})}),(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z`,fill:`white`})]});function D({item:e,isMultiple:t,renderItem:n}){let r=(0,o.useComboboxItemContext)();return(0,u.jsxs)(u.Fragment,{children:[t?r.selected?(0,u.jsx)(E,{}):(0,u.jsx)(T,{}):null,n?n(e):(0,u.jsx)(S,{truncate:!0,children:e.label})]})}var O=({items:e=[],initialItems:s,debounceMs:c=0,placeholder:d,emptyLabel:m,loadingLabel:h,usePortal:S=!0,withAutoFilter:T=!0,positioning:E,loadItems:O,renderItem:k,renderValue:A,onResetInitialItems:j,isLoading:M,value:N,openDropdownOnFocus:P=!0,clearValueWhenEmpty:F=!0,virtualized:I,rowHeight:L=34,returnItemsOnEmpty:ee,multiple:R=!1,...z})=>{let[B,V]=(0,l.useState)(()=>e),[H,U]=(0,l.useState)(!1),[W,G]=(0,l.useState)(!1),K=typeof O==`function`,q=(0,l.useMemo)(()=>O?(0,p.debounce)(async e=>{try{G(!0),U(!0),V(await O(e))}catch(e){console.error(e),V([])}finally{U(!1)}},c):null,[O,c]),J=[...!K&&!T?e:B,...s??[]],Y=(0,l.useCallback)(async t=>{s&&s.length>0&&!s.find(e=>e.label===t.inputValue)&&j?.();let{inputValue:n}=t;if(q)q(n);else{let t=T&&n!==``?e.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())):e;if(t.length===0&&ee)return V(e);V(t)}},[q,e,T]);(0,l.useEffect)(()=>{q||V(e)},[e,q]);let X=(0,l.useMemo)(()=>(0,o.createListCollection)({items:J}),[J]),Z=M??H,Q=h??(0,u.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:`Chargement...`}),$=m??(0,u.jsx)(n.Text,{p:`space-8`,textAlign:`center`,children:`Aucun résultat`});return(0,u.jsxs)(g,{lazyMount:!0,unmountOnExit:!0,collection:X,positioning:{sameWidth:!0,gutter:0,...E},"data-recipe":`combobox`,onInputValueChange:Y,value:N,...z,multiple:R,children:[R?(0,u.jsx)(o.Combobox.Context,{children:t=>(0,u.jsxs)(b,{"data-multiple":`true`,"data-open":t.open||void 0,children:[t.value.map(n=>{let r=e.find(e=>String(e.value)===String(n));return r?(0,u.jsxs)(a.Chip,{size:`sm`,children:[A?A(r):(0,u.jsx)(a.ChipLabel,{children:r.label}),!z.readOnly&&!z.disabled&&(0,u.jsx)(a.ChipClearTrigger,{"aria-label":`Retirer ${r.label}`,onClick:()=>t.setValue(t.value.filter(e=>String(e)!==String(n)))})]},n):null}),(0,u.jsx)(y,{asChild:!0,"data-multiple":`true`,placeholder:t.hasSelectedItems?void 0:d,onFocus:()=>{!P||K||t.setOpen(!0)},children:(0,u.jsx)(i.Input,{})}),(0,u.jsx)(w,{asChild:!0,hidden:K&&(!s||s.length===0),children:(0,u.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})})]})}):(0,u.jsxs)(b,{children:[(0,u.jsx)(o.Combobox.Context,{children:e=>(0,u.jsx)(y,{asChild:!0,placeholder:d,onInput:t=>{let n=t.currentTarget.value;F&&n===``&&e.clearValue()},onFocus:()=>{!P||K||e.setOpen(!0)},children:(0,u.jsx)(i.Input,{})})}),(0,u.jsx)(w,{asChild:!0,hidden:K&&(!s||s.length===0),children:(0,u.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z`,fill:`currentColor`})})}),(0,u.jsx)(_,{disabled:z.readOnly,onClick:j,asChild:!0,children:(0,u.jsx)(`button`,{children:(0,u.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z`,fill:`currentColor`})})})})]}),(0,u.jsx)(r.ConditionalWrapper,{when:S,wrapper:e=>(0,u.jsx)(o.Portal,{children:e}),children:(0,u.jsx)(C,{children:(0,u.jsx)(v,{children:Z?Q:J.length===0?(0,u.jsx)(u.Fragment,{children:K?W?$:Q:$}):I?(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(f.FixedSizeList,{height:Math.min(L*J.length,180),itemCount:J.length,itemSize:L,width:`100%`,children:({index:e,style:n})=>(0,u.jsx)(r.ConditionalWrapper,{when:!!J[e].tooltip,wrapper:n=>(0,u.jsx)(t.Tooltip,{label:J[e].tooltip,children:n}),children:(0,u.jsx)(x,{item:J[e],style:n,children:(0,u.jsx)(D,{renderItem:k,item:J[e],isMultiple:R})},J[e].value)},J[e].value)})}):J.map(e=>(0,u.jsx)(r.ConditionalWrapper,{when:!!e.tooltip,wrapper:n=>(0,u.jsx)(t.Tooltip,{label:e.tooltip,children:n}),children:(0,u.jsx)(x,{item:e,children:(0,u.jsx)(D,{renderItem:k,item:e,isMultiple:R})},e.value)},e.value))})})})]})};exports.Combobox=O;
2
2
  //# sourceMappingURL=Combobox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.cjs","names":[],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from 'lodash'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, 'collection' | 'value'> & {\n value?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n const allItems = [...items, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (\"Aucun résultat\") until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Chargement...\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Aucun résultat\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":"keAuBA,GA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jD,UAAW,EAAS,OACpB,SAAU,EACV,MAAM,iBAEJ,CAAE,QAAO,YACT,EAAA,EAAA,KAAC,EAAA,mBAAD,CAEE,KAAM,CAAC,CAAC,EAAS,GAAO,QACxB,QAAS,IAAY,EAAA,EAAA,KAAC,EAAA,QAAD,CAAS,MAAO,EAAS,GAAO,QAAU,UAAkB,CAAA,YAEjF,EAAA,EAAA,KAAC,EAAD,CAAkC,KAAM,EAAS,GAAe,kBAC9D,EAAA,EAAA,KAAC,EAAD,CAA6B,aAAY,KAAM,EAAS,GAAQ,WAAY,CAAW,CAAA,CACnF,EAFK,EAAS,GAAO,KAErB,CACY,EAPb,EAAS,GAAO,KAOH,CAET,CAAA,CACf,CAAA,EAEF,EAAS,IAAI,IACX,EAAA,EAAA,KAAC,EAAA,mBAAD,CAEE,KAAM,CAAC,CAAC,EAAK,QACb,QAAS,IAAY,EAAA,EAAA,KAAC,EAAA,QAAD,CAAS,MAAO,EAAK,QAAU,UAAkB,CAAA,YAEtE,EAAA,EAAA,KAAC,EAAD,CAA6B,iBAC3B,EAAA,EAAA,KAAC,EAAD,CAA6B,aAAkB,OAAM,WAAY,CAAW,CAAA,CACxE,EAFK,EAAK,KAEV,CACY,EAPb,EAAK,KAOQ,CACrB,CAEI,CAAA,CACC,CAAA,CACM,CAAA,CAChB,GAEV"}
1
+ {"version":3,"file":"Combobox.cjs","names":[],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from 'lodash'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, 'collection' | 'value'> & {\n value?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (\"Aucun résultat\") until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Chargement...\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Aucun résultat\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":"keAuBA,GAAM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,QAAQ,EAG3D,EAAO,GAAA,EAAA,EAAA,QAAoB,EAAA,SAAY,IAAS,EAAG,OAAQ,CAC/D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEK,EAAe,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,YAAY,EAAG,cAAc,EAC3E,EAAU,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,OAAO,EAAG,SAAS,EAC5D,EAAQ,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,KAAK,EAAG,OAAO,EACtD,EAAU,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,OAAO,EAAG,SAAS,EAC5D,EAAO,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,IAAI,EAAG,MAAM,EACnD,EAAW,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,QAAQ,EAAG,UAAU,EAC/D,EAAa,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,UAAU,EAAG,YAAY,EACrE,EAAU,GAAA,EAAA,EAAA,QAAmB,EAAA,SAAY,OAAO,EAAG,SAAS,EAqC5D,OACJ,EAAA,EAAA,MAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,sCAAlE,EACE,EAAA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AA,CACM,CAAA,CAChB,GAEV"}
@@ -70,7 +70,7 @@ var M = ({ items: e = [], initialItems: l, debounceMs: u = 0, placeholder: d, em
70
70
  } finally {
71
71
  q(!1);
72
72
  }
73
- }, u) : null, [A, u]), X = [...W, ...l ?? []], Z = f(async (t) => {
73
+ }, u) : null, [A, u]), X = [...!J && !D ? e : W, ...l ?? []], Z = f(async (t) => {
74
74
  l && l.length > 0 && !l.find((e) => e.label === t.inputValue) && P?.();
75
75
  let { inputValue: n } = t;
76
76
  if (Y) Y(n);
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","names":[],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from 'lodash'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, 'collection' | 'value'> & {\n value?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n const allItems = [...items, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (\"Aucun résultat\") until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Chargement...\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Aucun résultat\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAQ,GAG3D,KAAO,EAAa,EAAO,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEK,IAAe,EAAY,EAAO,EAAY,YAAY,GAAG,cAAc,GAC3E,IAAU,EAAY,EAAO,EAAY,OAAO,GAAG,SAAS,GAC5D,IAAQ,E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AAA,UAAG,IAAa,KAAsB,IAAe,IAAkB,EAAe,CAAA,IACpF,IACF,kBAAA,GAAA,EAAA,UACE,kBAAC,IAAD;IACE,QAAQ,KAAK,IAAI,IAAY,EAAS,QAAQ,GAAG;IACjD,WAAW,EAAS;IACpB,UAAU;IACV,OAAM;eAEJ,EAAE,UAAO,eACT,kBAAC,GAAD;KAEE,MAAM,CAAC,CAAC,EAAS,GAAO;KACxB,UAAS,MAAY,kBAAC,GAAD;MAAS,OAAO,EAAS,GAAO;MAAU;KAAkB,CAAA;eAEjF,kBAAC,GAAD;MAAkC,MAAM,EAAS;MAAe;gBAC9D,kBAAC,GAAD;OAA6B;OAAY,MAAM,EAAS;OAAQ,YAAY;MAAW,CAAA;KACnF,GAFK,EAAS,GAAO,KAErB;IACY,GAPb,EAAS,GAAO,KAOH;GAET,CAAA,EACf,CAAA,IAEF,EAAS,KAAI,MACX,kBAAC,GAAD;IAEE,MAAM,CAAC,CAAC,EAAK;IACb,UAAS,MAAY,kBAAC,GAAD;KAAS,OAAO,EAAK;KAAU;IAAkB,CAAA;cAEtE,kBAAC,GAAD;KAA6B;eAC3B,kBAAC,GAAD;MAA6B;MAAkB;MAAM,YAAY;KAAW,CAAA;IACxE,GAFK,EAAK,KAEV;GACY,GAPb,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
1
+ {"version":3,"file":"Combobox.js","names":[],"sources":["../../../src/components/combobox/Combobox.tsx"],"sourcesContent":["import {\n Combobox as ArkCombobox,\n type ComboboxRootProps,\n createListCollection,\n Portal,\n useComboboxItemContext,\n} from '@ark-ui/react'\nimport { FC, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { debounce } from 'lodash'\n\nimport { combobox } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input as UIInput } from '~/components/input'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { Chip, ChipClearTrigger, ChipLabel } from '~/components/chip'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { FixedSizeList } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(combobox)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkCombobox.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkCombobox.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkCombobox.Content), 'content')\nconst Input = withContext(styled(ArkCombobox.Input), 'input')\nconst Control = withContext(styled(ArkCombobox.Control), 'control')\nconst Item = withContext(styled(ArkCombobox.Item), 'item')\nconst ItemText = withContext(styled(ArkCombobox.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkCombobox.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkCombobox.Trigger), 'trigger')\n\nexport type ComboboxItem = {\n value: string | number\n label: string\n disabled?: boolean\n tooltip?: ReactNode\n}\n\nexport type ComboboxProps<T extends ComboboxItem> = Omit<ComboboxRootProps<T>, 'collection' | 'value'> & {\n value?: Array<string | number>\n items?: T[]\n initialItems?: T[]\n renderItem?: (item: T) => ReactNode\n /**\n * Renders the inner content of each selected chip in `multiple` mode.\n * Receives the selected item and should return the chip body (the removable\n * clear button is appended automatically). Defaults to the item label.\n */\n renderValue?: (item: T) => ReactNode\n loadItems?: (inputValue: string) => Promise<T[]>\n debounceMs?: number\n emptyLabel?: ReactNode\n loadingLabel?: ReactNode\n placeholder?: string\n usePortal?: boolean\n isLoading?: boolean\n withAutoFilter?: boolean\n onResetInitialItems?: () => void\n openDropdownOnFocus?: boolean\n clearValueWhenEmpty?: boolean\n virtualized?: boolean\n rowHeight?: number\n returnItemsOnEmpty?: boolean\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof combobox>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends ComboboxItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\nfunction CustomInnerItem<Item extends ComboboxItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useComboboxItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\nexport const Combobox = <T extends ComboboxItem>({\n items: itemsFromUsers = [],\n initialItems,\n debounceMs = 0,\n placeholder,\n emptyLabel,\n loadingLabel,\n usePortal = true,\n withAutoFilter = true,\n positioning,\n loadItems,\n renderItem,\n renderValue,\n onResetInitialItems,\n isLoading: controlledIsLoading,\n value,\n openDropdownOnFocus = true,\n clearValueWhenEmpty = true,\n virtualized,\n rowHeight = 34,\n returnItemsOnEmpty,\n multiple = false,\n ...props\n}: ComboboxProps<T>) => {\n const [items, setItems] = useState(() => itemsFromUsers)\n const [isLoading, setIsLoading] = useState(false)\n const [firstQueryTriggered, setFirstQueryTriggered] = useState(false)\n const asyncMode = typeof loadItems === 'function'\n\n const debouncedLoadItems = useMemo(\n () =>\n loadItems\n ? debounce(async (value: string) => {\n try {\n setFirstQueryTriggered(true)\n setIsLoading(true)\n const newItems = await loadItems(value)\n setItems(newItems)\n } catch (error) {\n console.error(error)\n setItems([])\n } finally {\n setIsLoading(false)\n }\n }, debounceMs)\n : null,\n [loadItems, debounceMs],\n )\n\n // A sync, unfiltered list has nothing to derive: read the prop itself. The mirrored\n // `items` state only catches up in an effect, one render late, and zag re-derives the\n // input text from the collection the moment `value` changes: a value set in the same\n // render as the item that carries it was stringified against a list without it, and\n // the input went blank.\n const sourceItems = !asyncMode && !withAutoFilter ? itemsFromUsers : items\n const allItems = [...sourceItems, ...(initialItems ?? [])]\n\n const handleInputChange = useCallback(\n async (details: ArkCombobox.InputValueChangeDetails) => {\n if (\n initialItems &&\n initialItems.length > 0 &&\n !initialItems.find((item: ComboboxItem) => item.label === details.inputValue)\n ) {\n onResetInitialItems?.()\n }\n const { inputValue } = details\n\n if (debouncedLoadItems) {\n debouncedLoadItems(inputValue)\n } else {\n const items =\n withAutoFilter && inputValue !== ''\n ? itemsFromUsers.filter((item: ComboboxItem) => item.label.toLowerCase().includes(inputValue.toLowerCase()))\n : itemsFromUsers\n\n if (items.length === 0 && returnItemsOnEmpty) {\n return setItems(itemsFromUsers)\n }\n setItems(items)\n }\n },\n [debouncedLoadItems, itemsFromUsers, withAutoFilter],\n )\n\n // Keep the visible items in sync with the source list whenever it changes\n // (e.g. options that load asynchronously after mount). Without this, an empty\n // input shows a stale/empty list (\"Aucun résultat\") until the user types.\n // Consumers memoize `items`, so this only fires on real data changes, not on\n // every keystroke.\n useEffect(() => {\n if (!debouncedLoadItems) {\n setItems(itemsFromUsers)\n }\n }, [itemsFromUsers, debouncedLoadItems])\n\n const collection = useMemo(() => createListCollection({ items: allItems }), [allItems])\n\n const effectiveIsLoading = controlledIsLoading ?? isLoading\n\n const loadingContent = loadingLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Chargement...\n </Text>\n )\n const emptyContent = emptyLabel ?? (\n <Text p=\"space-8\" textAlign=\"center\">\n Aucun résultat\n </Text>\n )\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"combobox\"\n onInputValueChange={handleInputChange}\n value={value as string[] | undefined}\n {...props}\n multiple={multiple}\n >\n {multiple ? (\n // Tags-input layout: the control (styled via the recipe's `&[data-multiple]`\n // selectors) is the bordered box holding the selected chips and a\n // borderless growing input.\n <ArkCombobox.Context>\n {api => (\n <Control data-multiple=\"true\" data-open={api.open || undefined}>\n {/* Resolve chips from the current value against the full source\n list rather than ark's cached `selectedItems`: the cache is only\n re-derived on value changes, so async-loaded defaults would show\n 0 chips until the user selects something. Looking up in\n itemsFromUsers (never the filtered list) also keeps chips visible\n while the user is typing to filter. */}\n {api.value.map(v => {\n const item = itemsFromUsers.find((i: T) => String(i.value) === String(v))\n if (!item) return null\n return (\n <Chip key={v} size=\"sm\">\n {renderValue ? renderValue(item) : <ChipLabel>{item.label}</ChipLabel>}\n {!props.readOnly && !props.disabled && (\n <ChipClearTrigger\n aria-label={`Retirer ${item.label}`}\n // Remove by strict-equality-safe filter: stored values may\n // be numbers while item.value is compared as a string.\n onClick={() => api.setValue(api.value.filter(x => String(x) !== String(v)))}\n />\n )}\n </Chip>\n )\n })}\n <Input\n asChild\n data-multiple=\"true\"\n placeholder={api.hasSelectedItems ? undefined : placeholder}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n </Control>\n )}\n </ArkCombobox.Context>\n ) : (\n <Control>\n <ArkCombobox.Context>\n {api => (\n <Input\n asChild\n placeholder={placeholder}\n onInput={(e: React.FormEvent<HTMLInputElement>) => {\n const value = e.currentTarget.value\n\n if (clearValueWhenEmpty && value === '') {\n api.clearValue()\n }\n }}\n onFocus={() => {\n if (!openDropdownOnFocus || asyncMode) return\n api.setOpen(true)\n }}\n >\n <UIInput />\n </Input>\n )}\n </ArkCombobox.Context>\n <Trigger asChild hidden={asyncMode && (!initialItems || initialItems.length === 0)}>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} onClick={onResetInitialItems} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n )}\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal>{children}</Portal>}>\n <Positioner>\n <Content>\n {effectiveIsLoading ? (\n loadingContent\n ) : allItems.length === 0 ? (\n <>{asyncMode ? (firstQueryTriggered ? emptyContent : loadingContent) : emptyContent}</>\n ) : virtualized ? (\n <>\n <FixedSizeList\n height={Math.min(rowHeight * allItems.length, 180)}\n itemCount={allItems.length}\n itemSize={rowHeight}\n width=\"100%\"\n >\n {({ index, style }) => (\n <ConditionalWrapper\n key={allItems[index].value}\n when={!!allItems[index].tooltip}\n wrapper={children => <Tooltip label={allItems[index].tooltip}>{children}</Tooltip>}\n >\n <Item key={allItems[index].value} item={allItems[index]} style={style}>\n <CustomInnerItem renderItem={renderItem} item={allItems[index]} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n )}\n </FixedSizeList>\n </>\n ) : (\n allItems.map(item => (\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={multiple} />\n </Item>\n </ConditionalWrapper>\n ))\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAQ,GAG3D,KAAO,EAAa,EAAO,EAAY,IAAS,GAAG,QAAQ,EAC/D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GAEK,IAAe,EAAY,EAAO,EAAY,YAAY,GAAG,cAAc,GAC3E,IAAU,EAAY,EAAO,EAAY,OAAO,GAAG,SAAS,GAC5D,IAAQ,EAAY,EAAO,EAAY,KAAK,GAAG,OAAO,GACtD,IAAU,EAAY,EAAO,EAAY,OAAO,GAAG,SAAS,GAC5D,IAAO,EAAY,EAAO,EAAY,IAAI,GAAG,MAAM,GACnD,IAAW,EAAY,EAAO,EAAY,QAAQ,GAAG,UAAU,GAC/D,KAAa,EAAY,EAAO,EAAY,UAAU,GAAG,YAAY,GACrE,IAAU,EAAY,EAAO,EAAY,OAAO,GAAG,SAAS,GAqC5D,UACJ,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;CAAY,MAAK;CAAO,OAAM;WAAlE,CACE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAAM;EAAK,QAAO;EAAK,IAAG;EAAM,MAAK;CAAS,CAAA,GAClE,kBAAC,QAAD;EAAM,GAAE;EAAM,GAAE;EAAI,OAA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,GAAO,KAOH;GAET,CAAA,EACf,CAAA,IAEF,EAAS,KAAI,MACX,kBAAC,GAAD;IAEE,MAAM,CAAC,CAAC,EAAK;IACb,UAAS,MAAY,kBAAC,GAAD;KAAS,OAAO,EAAK;KAAU;IAAkB,CAAA;cAEtE,kBAAC,GAAD;KAA6B;eAC3B,kBAAC,GAAD;MAA6B;MAAkB;MAAM,YAAY;KAAW,CAAA;IACxE,GAFK,EAAK,KAEV;GACY,GAPb,EAAK,KAOQ,CACrB,EAEI,CAAA,EACC,CAAA;EACM,CAAA,CAChB;;AAEV"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/slots.cjs");let t=require("@ark-ui/react"),n=require("@stokelp/styled-system/jsx"),r=require("@stokelp/styled-system/recipes"),i=require("react"),a=require("react/jsx-runtime");var{withProvider:o,withContext:s}=e.createStyleContext(r.tabs),c=o((0,n.styled)(t.Tabs.Root),`root`,{defaultProps:{lazyMount:!0}}),l=s((0,n.styled)(t.Tabs.Content),`content`),u=s((0,n.styled)(t.Tabs.Trigger),`trigger`),d=(0,n.styled)(t.ark.span,r.tabsChip),f=s((0,n.styled)(t.Tabs.Indicator),`indicator`),p=(0,i.forwardRef)(({children:e,...n},r)=>(0,a.jsxs)(t.Tabs.List,{ref:r,...n,children:[e,(0,a.jsx)(f,{})]}));p.displayName=t.Tabs.List.displayName;var m=s((0,n.styled)(p),`list`);exports.Tabs=c,exports.TabsChip=d,exports.TabsContent=l,exports.TabsList=m,exports.TabsTrigger=u;
1
+ "use client";const e=require("../../utils/slots.cjs");let t=require("@ark-ui/react"),n=require("@stokelp/styled-system/jsx"),r=require("@stokelp/styled-system/recipes"),i=require("react"),a=require("react/jsx-runtime");var{withProvider:o,withContext:s}=e.createStyleContext(r.tabs),c=o((0,n.styled)(t.Tabs.Root),`root`,{defaultProps:{lazyMount:!0}}),l=s((0,n.styled)(t.Tabs.Content),`content`),u=(0,i.forwardRef)(({children:e,...n},r)=>(0,a.jsx)(t.Tabs.Trigger,{ref:r,...n,children:i.Children.map(e,e=>typeof e==`string`&&e.trim()!==``||typeof e==`number`?(0,a.jsx)(`span`,{"data-label":e,children:e}):e)}));u.displayName=t.Tabs.Trigger.displayName;var d=s((0,n.styled)(u),`trigger`),f=(0,n.styled)(t.ark.span,r.tabsChip),p=s((0,n.styled)(t.Tabs.Indicator),`indicator`),m=(0,i.forwardRef)(({children:e,...n},r)=>(0,a.jsxs)(t.Tabs.List,{ref:r,...n,children:[e,(0,a.jsx)(p,{})]}));m.displayName=t.Tabs.List.displayName;var h=s((0,n.styled)(m),`list`);exports.Tabs=c,exports.TabsChip=f,exports.TabsContent=l,exports.TabsList=h,exports.TabsTrigger=d;
2
2
  //# sourceMappingURL=Tabs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.cjs","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import { ark, Tabs as ArkTab } from '@ark-ui/react'\nimport { ComponentProps, type ComponentPropsWithoutRef, type ElementRef, forwardRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { tabs, tabsChip } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots.tsx'\n\nconst { withProvider, withContext } = createStyleContext(tabs)\n\nexport const Tabs = withProvider(styled(ArkTab.Root), 'root', {\n defaultProps: {\n lazyMount: true,\n },\n})\nexport const TabsContent = withContext(styled(ArkTab.Content), 'content')\nexport const TabsTrigger = withContext(styled(ArkTab.Trigger), 'trigger')\nexport const TabsChip = styled(ark.span, tabsChip)\n\nconst TabsIndicator = withContext(styled(ArkTab.Indicator), 'indicator')\n\nconst List = forwardRef<ElementRef<typeof ArkTab.List>, ComponentPropsWithoutRef<typeof ArkTab.List>>(\n ({ children, ...props }, ref) => (\n <ArkTab.List ref={ref} {...props}>\n {children}\n <TabsIndicator />\n </ArkTab.List>\n ),\n)\nList.displayName = ArkTab.List.displayName\n\nexport const TabsList = withContext(styled(List), 'list')\n\nexport interface TabsProps extends ComponentProps<typeof Tabs> {}\n\nexport interface TabsContentProps extends ComponentProps<typeof TabsContent> {}\n\nexport interface TabsIndicatorProps extends ComponentProps<typeof TabsIndicator> {}\n\nexport interface TabsListProps extends ComponentProps<typeof TabsList> {}\n\nexport interface TabsTriggerProps extends ComponentProps<typeof TabsTrigger> {}\n\nexport interface TabsChipProps extends ComponentProps<typeof TabsChip> {}\n"],"mappings":"2NAMA,GAAM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,IAAI,EAEhD,EAAO,GAAA,EAAA,EAAA,QAAoB,EAAA,KAAO,IAAI,EAAG,OAAQ,CAC5D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EACY,EAAc,GAAA,EAAA,EAAA,QAAmB,EAAA,KAAO,OAAO,EAAG,SAAS,EAC3D,EAAc,GAAA,EAAA,EAAA,QAAmB,EAAA,KAAO,OAAO,EAAG,SAAS,EAC3D,GAAA,EAAA,EAAA,QAAkB,EAAA,IAAI,KAAM,EAAA,QAAQ,EAE3C,EAAgB,GAAA,EAAA,EAAA,QAAmB,EAAA,KAAO,SAAS,EAAG,WAAW,EAEjE,GAAA,EAAA,EAAA,aACH,CAAE,WAAU,GAAG,GAAS,KACvB,EAAA,EAAA,MAAC,EAAA,KAAO,KAAR,CAAkB,MAAK,GAAI,WAA3B,CACG,GACD,EAAA,EAAA,KAAC,EAAD,CAAgB,CAAA,CACL,GAEjB,EACA,EAAK,YAAc,EAAA,KAAO,KAAK,YAE/B,IAAa,EAAW,GAAA,EAAA,EAAA,QAAmB,CAAI,EAAG,MAAM"}
1
+ {"version":3,"file":"Tabs.cjs","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import { ark, Tabs as ArkTab } from '@ark-ui/react'\nimport { Children, ComponentProps, type ComponentPropsWithoutRef, type ElementRef, forwardRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { tabs, tabsChip } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots.tsx'\n\nconst { withProvider, withContext } = createStyleContext(tabs)\n\nexport const Tabs = withProvider(styled(ArkTab.Root), 'root', {\n defaultProps: {\n lazyMount: true,\n },\n})\nexport const TabsContent = withContext(styled(ArkTab.Content), 'content')\n\n// Hover and selection render a trigger bold, which widens its label. The recipe\n// reserves the bold width on every [data-label] element, so string labels are\n// wrapped here and a weight change never moves a tab. Wrap a JSX label yourself\n// with `<span data-label={label}>{label}</span>` to get the same guarantee.\nconst Trigger = forwardRef<ElementRef<typeof ArkTab.Trigger>, ComponentPropsWithoutRef<typeof ArkTab.Trigger>>(\n ({ children, ...props }, ref) => (\n <ArkTab.Trigger ref={ref} {...props}>\n {Children.map(children, child =>\n (typeof child === 'string' && child.trim() !== '') || typeof child === 'number' ? (\n <span data-label={child}>{child}</span>\n ) : (\n child\n ),\n )}\n </ArkTab.Trigger>\n ),\n)\nTrigger.displayName = ArkTab.Trigger.displayName\n\nexport const TabsTrigger = withContext(styled(Trigger), 'trigger')\nexport const TabsChip = styled(ark.span, tabsChip)\n\nconst TabsIndicator = withContext(styled(ArkTab.Indicator), 'indicator')\n\nconst List = forwardRef<ElementRef<typeof ArkTab.List>, ComponentPropsWithoutRef<typeof ArkTab.List>>(\n ({ children, ...props }, ref) => (\n <ArkTab.List ref={ref} {...props}>\n {children}\n <TabsIndicator />\n </ArkTab.List>\n ),\n)\nList.displayName = ArkTab.List.displayName\n\nexport const TabsList = withContext(styled(List), 'list')\n\nexport interface TabsProps extends ComponentProps<typeof Tabs> {}\n\nexport interface TabsContentProps extends ComponentProps<typeof TabsContent> {}\n\nexport interface TabsIndicatorProps extends ComponentProps<typeof TabsIndicator> {}\n\nexport interface TabsListProps extends ComponentProps<typeof TabsList> {}\n\nexport interface TabsTriggerProps extends ComponentProps<typeof TabsTrigger> {}\n\nexport interface TabsChipProps extends ComponentProps<typeof TabsChip> {}\n"],"mappings":"2NAMA,GAAM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,IAAI,EAEhD,EAAO,GAAA,EAAA,EAAA,QAAoB,EAAA,KAAO,IAAI,EAAG,OAAQ,CAC5D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EACY,EAAc,GAAA,EAAA,EAAA,QAAmB,EAAA,KAAO,OAAO,EAAG,SAAS,EAMlE,GAAA,EAAA,EAAA,aACH,CAAE,WAAU,GAAG,GAAS,KACvB,EAAA,EAAA,KAAC,EAAA,KAAO,QAAR,CAAqB,MAAK,GAAI,WAC3B,EAAA,SAAS,IAAI,EAAU,GACrB,OAAO,GAAU,UAAY,EAAM,KAAK,IAAM,IAAO,OAAO,GAAU,UACrE,EAAA,EAAA,KAAC,OAAD,CAAM,aAAY,WAAQ,CAAY,CAAA,EAEtC,CAEJ,CACc,CAAA,CAEpB,EACA,EAAQ,YAAc,EAAA,KAAO,QAAQ,YAErC,IAAa,EAAc,GAAA,EAAA,EAAA,QAAmB,CAAO,EAAG,SAAS,EACpD,GAAA,EAAA,EAAA,QAAkB,EAAA,IAAI,KAAM,EAAA,QAAQ,EAE3C,EAAgB,GAAA,EAAA,EAAA,QAAmB,EAAA,KAAO,SAAS,EAAG,WAAW,EAEjE,GAAA,EAAA,EAAA,aACH,CAAE,WAAU,GAAG,GAAS,KACvB,EAAA,EAAA,MAAC,EAAA,KAAO,KAAR,CAAkB,MAAK,GAAI,WAA3B,CACG,GACD,EAAA,EAAA,KAAC,EAAD,CAAgB,CAAA,CACL,GAEjB,EACA,EAAK,YAAc,EAAA,KAAO,KAAK,YAE/B,IAAa,EAAW,GAAA,EAAA,EAAA,QAAmB,CAAI,EAAG,MAAM"}
@@ -5,7 +5,7 @@ import { StyledComponent } from '@stokelp/styled-system/types';
5
5
  import { TabsRecipe } from '@stokelp/styled-system/recipes';
6
6
  export declare const Tabs: ComponentVariants<StyledComponent<ForwardRefExoticComponent<ArkTab.RootProps & RefAttributes<HTMLDivElement>>, {}>, TabsRecipe>;
7
7
  export declare const TabsContent: StyledComponent<ForwardRefExoticComponent<ArkTab.ContentProps & RefAttributes<HTMLDivElement>>, {}>;
8
- export declare const TabsTrigger: StyledComponent<ForwardRefExoticComponent<ArkTab.TriggerProps & RefAttributes<HTMLButtonElement>>, {}>;
8
+ export declare const TabsTrigger: StyledComponent<ForwardRefExoticComponent<Omit<ArkTab.TriggerProps & RefAttributes<HTMLButtonElement>, "ref"> & RefAttributes<HTMLButtonElement>>, {}>;
9
9
  export declare const TabsChip: StyledComponent<any, {
10
10
  [x: string]: unknown;
11
11
  [x: number]: unknown;
@@ -3,17 +3,26 @@ import { createStyleContext as e } from "../../utils/slots.js";
3
3
  import { Tabs as t, ark as n } from "@ark-ui/react";
4
4
  import { styled as r } from "@stokelp/styled-system/jsx";
5
5
  import { tabs as i, tabsChip as a } from "@stokelp/styled-system/recipes";
6
- import { forwardRef as o } from "react";
7
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ import { Children as o, forwardRef as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
8
  //#region src/components/tabs/Tabs.tsx
9
- var { withProvider: l, withContext: u } = e(i), d = l(r(t.Root), "root", { defaultProps: { lazyMount: !0 } }), f = u(r(t.Content), "content"), p = u(r(t.Trigger), "trigger"), m = r(n.span, a), h = u(r(t.Indicator), "indicator"), g = o(({ children: e, ...n }, r) => /* @__PURE__ */ c(t.List, {
9
+ var { withProvider: u, withContext: d } = e(i), f = u(r(t.Root), "root", { defaultProps: { lazyMount: !0 } }), p = d(r(t.Content), "content"), m = s(({ children: e, ...n }, r) => /* @__PURE__ */ c(t.Trigger, {
10
10
  ref: r,
11
11
  ...n,
12
- children: [e, /* @__PURE__ */ s(h, {})]
12
+ children: o.map(e, (e) => typeof e == "string" && e.trim() !== "" || typeof e == "number" ? /* @__PURE__ */ c("span", {
13
+ "data-label": e,
14
+ children: e
15
+ }) : e)
13
16
  }));
14
- g.displayName = t.List.displayName;
15
- var _ = u(r(g), "list");
17
+ m.displayName = t.Trigger.displayName;
18
+ var h = d(r(m), "trigger"), g = r(n.span, a), _ = d(r(t.Indicator), "indicator"), v = s(({ children: e, ...n }, r) => /* @__PURE__ */ l(t.List, {
19
+ ref: r,
20
+ ...n,
21
+ children: [e, /* @__PURE__ */ c(_, {})]
22
+ }));
23
+ v.displayName = t.List.displayName;
24
+ var y = d(r(v), "list");
16
25
  //#endregion
17
- export { d as Tabs, m as TabsChip, f as TabsContent, _ as TabsList, p as TabsTrigger };
26
+ export { f as Tabs, g as TabsChip, p as TabsContent, y as TabsList, h as TabsTrigger };
18
27
 
19
28
  //# sourceMappingURL=Tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import { ark, Tabs as ArkTab } from '@ark-ui/react'\nimport { ComponentProps, type ComponentPropsWithoutRef, type ElementRef, forwardRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { tabs, tabsChip } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots.tsx'\n\nconst { withProvider, withContext } = createStyleContext(tabs)\n\nexport const Tabs = withProvider(styled(ArkTab.Root), 'root', {\n defaultProps: {\n lazyMount: true,\n },\n})\nexport const TabsContent = withContext(styled(ArkTab.Content), 'content')\nexport const TabsTrigger = withContext(styled(ArkTab.Trigger), 'trigger')\nexport const TabsChip = styled(ark.span, tabsChip)\n\nconst TabsIndicator = withContext(styled(ArkTab.Indicator), 'indicator')\n\nconst List = forwardRef<ElementRef<typeof ArkTab.List>, ComponentPropsWithoutRef<typeof ArkTab.List>>(\n ({ children, ...props }, ref) => (\n <ArkTab.List ref={ref} {...props}>\n {children}\n <TabsIndicator />\n </ArkTab.List>\n ),\n)\nList.displayName = ArkTab.List.displayName\n\nexport const TabsList = withContext(styled(List), 'list')\n\nexport interface TabsProps extends ComponentProps<typeof Tabs> {}\n\nexport interface TabsContentProps extends ComponentProps<typeof TabsContent> {}\n\nexport interface TabsIndicatorProps extends ComponentProps<typeof TabsIndicator> {}\n\nexport interface TabsListProps extends ComponentProps<typeof TabsList> {}\n\nexport interface TabsTriggerProps extends ComponentProps<typeof TabsTrigger> {}\n\nexport interface TabsChipProps extends ComponentProps<typeof TabsChip> {}\n"],"mappings":";;;;;;;;AAMA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAI,GAEhD,IAAO,EAAa,EAAO,EAAO,IAAI,GAAG,QAAQ,EAC5D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GACY,IAAc,EAAY,EAAO,EAAO,OAAO,GAAG,SAAS,GAC3D,IAAc,EAAY,EAAO,EAAO,OAAO,GAAG,SAAS,GAC3D,IAAW,EAAO,EAAI,MAAM,CAAQ,GAE3C,IAAgB,EAAY,EAAO,EAAO,SAAS,GAAG,WAAW,GAEjE,IAAO,GACV,EAAE,aAAU,GAAG,KAAS,MACvB,kBAAC,EAAO,MAAR;CAAkB;CAAK,GAAI;WAA3B,CACG,GACD,kBAAC,GAAD,CAAgB,CAAA,CACL;EAEjB;AACA,EAAK,cAAc,EAAO,KAAK;AAE/B,IAAa,IAAW,EAAY,EAAO,CAAI,GAAG,MAAM"}
1
+ {"version":3,"file":"Tabs.js","names":[],"sources":["../../../src/components/tabs/Tabs.tsx"],"sourcesContent":["import { ark, Tabs as ArkTab } from '@ark-ui/react'\nimport { Children, ComponentProps, type ComponentPropsWithoutRef, type ElementRef, forwardRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { tabs, tabsChip } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots.tsx'\n\nconst { withProvider, withContext } = createStyleContext(tabs)\n\nexport const Tabs = withProvider(styled(ArkTab.Root), 'root', {\n defaultProps: {\n lazyMount: true,\n },\n})\nexport const TabsContent = withContext(styled(ArkTab.Content), 'content')\n\n// Hover and selection render a trigger bold, which widens its label. The recipe\n// reserves the bold width on every [data-label] element, so string labels are\n// wrapped here and a weight change never moves a tab. Wrap a JSX label yourself\n// with `<span data-label={label}>{label}</span>` to get the same guarantee.\nconst Trigger = forwardRef<ElementRef<typeof ArkTab.Trigger>, ComponentPropsWithoutRef<typeof ArkTab.Trigger>>(\n ({ children, ...props }, ref) => (\n <ArkTab.Trigger ref={ref} {...props}>\n {Children.map(children, child =>\n (typeof child === 'string' && child.trim() !== '') || typeof child === 'number' ? (\n <span data-label={child}>{child}</span>\n ) : (\n child\n ),\n )}\n </ArkTab.Trigger>\n ),\n)\nTrigger.displayName = ArkTab.Trigger.displayName\n\nexport const TabsTrigger = withContext(styled(Trigger), 'trigger')\nexport const TabsChip = styled(ark.span, tabsChip)\n\nconst TabsIndicator = withContext(styled(ArkTab.Indicator), 'indicator')\n\nconst List = forwardRef<ElementRef<typeof ArkTab.List>, ComponentPropsWithoutRef<typeof ArkTab.List>>(\n ({ children, ...props }, ref) => (\n <ArkTab.List ref={ref} {...props}>\n {children}\n <TabsIndicator />\n </ArkTab.List>\n ),\n)\nList.displayName = ArkTab.List.displayName\n\nexport const TabsList = withContext(styled(List), 'list')\n\nexport interface TabsProps extends ComponentProps<typeof Tabs> {}\n\nexport interface TabsContentProps extends ComponentProps<typeof TabsContent> {}\n\nexport interface TabsIndicatorProps extends ComponentProps<typeof TabsIndicator> {}\n\nexport interface TabsListProps extends ComponentProps<typeof TabsList> {}\n\nexport interface TabsTriggerProps extends ComponentProps<typeof TabsTrigger> {}\n\nexport interface TabsChipProps extends ComponentProps<typeof TabsChip> {}\n"],"mappings":";;;;;;;;AAMA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAI,GAEhD,IAAO,EAAa,EAAO,EAAO,IAAI,GAAG,QAAQ,EAC5D,cAAc,EACZ,WAAW,GACb,EACF,CAAC,GACY,IAAc,EAAY,EAAO,EAAO,OAAO,GAAG,SAAS,GAMlE,IAAU,GACb,EAAE,aAAU,GAAG,KAAS,MACvB,kBAAC,EAAO,SAAR;CAAqB;CAAK,GAAI;WAC3B,EAAS,IAAI,IAAU,MACrB,OAAO,KAAU,YAAY,EAAM,KAAK,MAAM,MAAO,OAAO,KAAU,WACrE,kBAAC,QAAD;EAAM,cAAY;YAAQ;CAAY,CAAA,IAEtC,CAEJ;AACc,CAAA,CAEpB;AACA,EAAQ,cAAc,EAAO,QAAQ;AAErC,IAAa,IAAc,EAAY,EAAO,CAAO,GAAG,SAAS,GACpD,IAAW,EAAO,EAAI,MAAM,CAAQ,GAE3C,IAAgB,EAAY,EAAO,EAAO,SAAS,GAAG,WAAW,GAEjE,IAAO,GACV,EAAE,aAAU,GAAG,KAAS,MACvB,kBAAC,EAAO,MAAR;CAAkB;CAAK,GAAI;WAA3B,CACG,GACD,kBAAC,GAAD,CAAgB,CAAA,CACL;EAEjB;AACA,EAAK,cAAc,EAAO,KAAK;AAE/B,IAAa,IAAW,EAAY,EAAO,CAAI,GAAG,MAAM"}
@@ -1,2 +1,2 @@
1
- "use client";let e=require("@ark-ui/react");var t=(0,require("@pandacss/dev").defineSlotRecipe)({className:`tabs`,slots:[...e.tabsAnatomy.keys()],base:{root:{isolation:`isolate`,display:`flex`,fontFamily:`satoshi`,_horizontal:{flexDirection:`column`},_vertical:{flexDirection:`row`}},list:{display:`flex`,flexShrink:`0`,_horizontal:{flexDirection:`row`},_vertical:{flexDirection:`column`},overflow:`auto`,position:`relative`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}},trigger:{alignItems:`center`,color:`grey.400`,cursor:`pointer`,display:`inline-flex`,flexShrink:`0`,textStyle:`body.md`,gap:`space-4`,justifyContent:`center`,transitionDuration:`normal`,transitionProperty:`color, background, border-color`,transitionTimingFunction:`default`,whiteSpace:`nowrap`,zIndex:1,_disabled:{color:`grey.100`,cursor:`not-allowed`,_hover:{color:`grey.100`}},_hover:{color:`secondary.500`,fontWeight:`bold`},_selected:{color:`secondary.500`,fontWeight:`bold`,_hover:{color:`secondary.500`}},_vertical:{justifyContent:`flex-start`}}},defaultVariants:{variant:`line`,lineVariant:`primary`},variants:{lineVariant:{primary:{list:{color:`{colors.primary.100}`}},white:{list:{color:`white`}}},variant:{line:{list:{_horizontal:{boxShadow:`0 -2px 0 0 inset`},_vertical:{boxShadow:`2px 0 0 0 inset`}},indicator:{background:`secondary.500`,_horizontal:{bottom:0,height:`2px`,width:`var(--width)`},_vertical:{height:`var(--height)`,left:0,width:`2px`}},content:{pt:`space-4`},trigger:{_horizontal:{px:`space-24`,pb:`space-8`}}}}}});exports.tabsRecipe=t;
1
+ "use client";let e=require("@ark-ui/react");var t=(0,require("@pandacss/dev").defineSlotRecipe)({className:`tabs`,slots:[...e.tabsAnatomy.keys()],base:{root:{isolation:`isolate`,display:`flex`,fontFamily:`satoshi`,_horizontal:{flexDirection:`column`},_vertical:{flexDirection:`row`}},list:{display:`flex`,flexShrink:`0`,_horizontal:{flexDirection:`row`},_vertical:{flexDirection:`column`},overflow:`auto`,position:`relative`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}},trigger:{alignItems:`center`,color:`grey.400`,cursor:`pointer`,display:`inline-flex`,flexShrink:`0`,textStyle:`body.md`,gap:`space-4`,justifyContent:`center`,transitionDuration:`normal`,transitionProperty:`color, background, border-color`,transitionTimingFunction:`default`,whiteSpace:`nowrap`,zIndex:1,_disabled:{color:`grey.100`,cursor:`not-allowed`,_hover:{color:`grey.100`}},_hover:{color:`secondary.500`,fontWeight:`bold`},_selected:{color:`secondary.500`,fontWeight:`bold`,_hover:{color:`secondary.500`}},_vertical:{justifyContent:`flex-start`,"& [data-label]":{textAlign:`start`}},"& [data-label]":{textAlign:`center`,_after:{content:`attr(data-label)`,display:`block`,fontWeight:`bold`,height:0,overflow:`hidden`,visibility:`hidden`}}}},defaultVariants:{variant:`line`,lineVariant:`primary`},variants:{lineVariant:{primary:{list:{color:`{colors.primary.100}`}},white:{list:{color:`white`}}},variant:{line:{list:{_horizontal:{boxShadow:`0 -2px 0 0 inset`},_vertical:{boxShadow:`2px 0 0 0 inset`}},indicator:{background:`secondary.500`,_horizontal:{bottom:0,height:`2px`,width:`var(--width)`},_vertical:{height:`var(--height)`,left:0,width:`2px`}},content:{pt:`space-4`},trigger:{_horizontal:{px:`space-24`,pb:`space-8`}}}}}});exports.tabsRecipe=t;
2
2
  //# sourceMappingURL=tabs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.cjs","names":[],"sources":["../../../src/theme/recipes/tabs.ts"],"sourcesContent":["import { tabsAnatomy } from '@ark-ui/react'\nimport { defineSlotRecipe } from '@pandacss/dev'\n\nexport const tabsRecipe = defineSlotRecipe({\n className: 'tabs',\n slots: [...tabsAnatomy.keys()],\n base: {\n root: {\n isolation: 'isolate',\n display: 'flex',\n fontFamily: 'satoshi',\n _horizontal: {\n flexDirection: 'column',\n },\n _vertical: {\n flexDirection: 'row',\n },\n },\n list: {\n display: 'flex',\n flexShrink: '0',\n _horizontal: {\n flexDirection: 'row',\n },\n _vertical: {\n flexDirection: 'column',\n },\n overflow: 'auto',\n position: 'relative',\n scrollbarWidth: 'none',\n '&::-webkit-scrollbar': {\n display: 'none',\n },\n },\n trigger: {\n alignItems: 'center',\n color: 'grey.400',\n cursor: 'pointer',\n display: 'inline-flex',\n flexShrink: '0',\n textStyle: 'body.md',\n gap: 'space-4',\n justifyContent: 'center',\n transitionDuration: 'normal',\n transitionProperty: 'color, background, border-color',\n transitionTimingFunction: 'default',\n whiteSpace: 'nowrap',\n zIndex: 1,\n _disabled: {\n color: 'grey.100',\n cursor: 'not-allowed',\n _hover: {\n color: 'grey.100',\n },\n },\n _hover: {\n color: 'secondary.500',\n fontWeight: 'bold',\n },\n _selected: {\n color: 'secondary.500',\n fontWeight: 'bold',\n _hover: {\n color: 'secondary.500',\n },\n },\n _vertical: {\n justifyContent: 'flex-start',\n },\n },\n },\n defaultVariants: {\n variant: 'line',\n lineVariant: 'primary',\n },\n variants: {\n lineVariant: {\n primary: {\n list: {\n color: '{colors.primary.100}',\n },\n },\n white: {\n list: {\n color: 'white',\n },\n },\n },\n variant: {\n line: {\n list: {\n _horizontal: {\n boxShadow: '0 -2px 0 0 inset',\n },\n _vertical: {\n boxShadow: '2px 0 0 0 inset',\n },\n },\n indicator: {\n background: 'secondary.500',\n _horizontal: {\n bottom: 0,\n height: '2px',\n width: 'var(--width)',\n },\n _vertical: {\n height: 'var(--height)',\n left: 0,\n width: '2px',\n },\n },\n content: {\n pt: 'space-4',\n },\n trigger: {\n _horizontal: {\n px: 'space-24',\n pb: 'space-8',\n },\n },\n },\n },\n },\n})\n"],"mappings":"4CAGA,IAAa,GAAA,yBAAA,EAAA,kBAA8B,CACzC,UAAW,OACX,MAAO,CAAC,GAAG,EAAA,YAAY,KAAK,CAAC,EAC7B,KAAM,CACJ,KAAM,CACJ,UAAW,UACX,QAAS,OACT,WAAY,UACZ,YAAa,CACX,cAAe,QACjB,EACA,UAAW,CACT,cAAe,KACjB,CACF,EACA,KAAM,CACJ,QAAS,OACT,WAAY,IACZ,YAAa,CACX,cAAe,KACjB,EACA,UAAW,CACT,cAAe,QACjB,EACA,SAAU,OACV,SAAU,WACV,eAAgB,OAChB,uBAAwB,CACtB,QAAS,MACX,CACF,EACA,QAAS,CACP,WAAY,SACZ,MAAO,WACP,OAAQ,UACR,QAAS,cACT,WAAY,IACZ,UAAW,UACX,IAAK,UACL,eAAgB,SAChB,mBAAoB,SACpB,mBAAoB,kCACpB,yBAA0B,UAC1B,WAAY,SACZ,OAAQ,EACR,UAAW,CACT,MAAO,WACP,OAAQ,cACR,OAAQ,CACN,MAAO,UACT,CACF,EACA,OAAQ,CACN,MAAO,gBACP,WAAY,MACd,EACA,UAAW,CACT,MAAO,gBACP,WAAY,OACZ,OAAQ,CACN,MAAO,eACT,CACF,EACA,UAAW,CACT,eAAgB,YAClB,CACF,CACF,EACA,gBAAiB,CACf,QAAS,OACT,YAAa,SACf,EACA,SAAU,CACR,YAAa,CACX,QAAS,CACP,KAAM,CACJ,MAAO,sBACT,CACF,EACA,MAAO,CACL,KAAM,CACJ,MAAO,OACT,CACF,CACF,EACA,QAAS,CACP,KAAM,CACJ,KAAM,CACJ,YAAa,CACX,UAAW,kBACb,EACA,UAAW,CACT,UAAW,iBACb,CACF,EACA,UAAW,CACT,WAAY,gBACZ,YAAa,CACX,OAAQ,EACR,OAAQ,MACR,MAAO,cACT,EACA,UAAW,CACT,OAAQ,gBACR,KAAM,EACN,MAAO,KACT,CACF,EACA,QAAS,CACP,GAAI,SACN,EACA,QAAS,CACP,YAAa,CACX,GAAI,WACJ,GAAI,SACN,CACF,CACF,CACF,CACF,CACF,CAAC"}
1
+ {"version":3,"file":"tabs.cjs","names":[],"sources":["../../../src/theme/recipes/tabs.ts"],"sourcesContent":["import { tabsAnatomy } from '@ark-ui/react'\nimport { defineSlotRecipe } from '@pandacss/dev'\n\nexport const tabsRecipe = defineSlotRecipe({\n className: 'tabs',\n slots: [...tabsAnatomy.keys()],\n base: {\n root: {\n isolation: 'isolate',\n display: 'flex',\n fontFamily: 'satoshi',\n _horizontal: {\n flexDirection: 'column',\n },\n _vertical: {\n flexDirection: 'row',\n },\n },\n list: {\n display: 'flex',\n flexShrink: '0',\n _horizontal: {\n flexDirection: 'row',\n },\n _vertical: {\n flexDirection: 'column',\n },\n overflow: 'auto',\n position: 'relative',\n scrollbarWidth: 'none',\n '&::-webkit-scrollbar': {\n display: 'none',\n },\n },\n trigger: {\n alignItems: 'center',\n color: 'grey.400',\n cursor: 'pointer',\n display: 'inline-flex',\n flexShrink: '0',\n textStyle: 'body.md',\n gap: 'space-4',\n justifyContent: 'center',\n transitionDuration: 'normal',\n transitionProperty: 'color, background, border-color',\n transitionTimingFunction: 'default',\n whiteSpace: 'nowrap',\n zIndex: 1,\n _disabled: {\n color: 'grey.100',\n cursor: 'not-allowed',\n _hover: {\n color: 'grey.100',\n },\n },\n _hover: {\n color: 'secondary.500',\n fontWeight: 'bold',\n },\n _selected: {\n color: 'secondary.500',\n fontWeight: 'bold',\n _hover: {\n color: 'secondary.500',\n },\n },\n _vertical: {\n justifyContent: 'flex-start',\n '& [data-label]': {\n textAlign: 'start',\n },\n },\n // Hover and selection go bold, which widens the label. Reserve the bold\n // width with a hidden bold copy so a weight change never moves a tab.\n '& [data-label]': {\n textAlign: 'center',\n _after: {\n content: 'attr(data-label)',\n display: 'block',\n fontWeight: 'bold',\n height: 0,\n overflow: 'hidden',\n visibility: 'hidden',\n },\n },\n },\n },\n defaultVariants: {\n variant: 'line',\n lineVariant: 'primary',\n },\n variants: {\n lineVariant: {\n primary: {\n list: {\n color: '{colors.primary.100}',\n },\n },\n white: {\n list: {\n color: 'white',\n },\n },\n },\n variant: {\n line: {\n list: {\n _horizontal: {\n boxShadow: '0 -2px 0 0 inset',\n },\n _vertical: {\n boxShadow: '2px 0 0 0 inset',\n },\n },\n indicator: {\n background: 'secondary.500',\n _horizontal: {\n bottom: 0,\n height: '2px',\n width: 'var(--width)',\n },\n _vertical: {\n height: 'var(--height)',\n left: 0,\n width: '2px',\n },\n },\n content: {\n pt: 'space-4',\n },\n trigger: {\n _horizontal: {\n px: 'space-24',\n pb: 'space-8',\n },\n },\n },\n },\n },\n})\n"],"mappings":"4CAGA,IAAa,GAAA,yBAAA,EAAA,kBAA8B,CACzC,UAAW,OACX,MAAO,CAAC,GAAG,EAAA,YAAY,KAAK,CAAC,EAC7B,KAAM,CACJ,KAAM,CACJ,UAAW,UACX,QAAS,OACT,WAAY,UACZ,YAAa,CACX,cAAe,QACjB,EACA,UAAW,CACT,cAAe,KACjB,CACF,EACA,KAAM,CACJ,QAAS,OACT,WAAY,IACZ,YAAa,CACX,cAAe,KACjB,EACA,UAAW,CACT,cAAe,QACjB,EACA,SAAU,OACV,SAAU,WACV,eAAgB,OAChB,uBAAwB,CACtB,QAAS,MACX,CACF,EACA,QAAS,CACP,WAAY,SACZ,MAAO,WACP,OAAQ,UACR,QAAS,cACT,WAAY,IACZ,UAAW,UACX,IAAK,UACL,eAAgB,SAChB,mBAAoB,SACpB,mBAAoB,kCACpB,yBAA0B,UAC1B,WAAY,SACZ,OAAQ,EACR,UAAW,CACT,MAAO,WACP,OAAQ,cACR,OAAQ,CACN,MAAO,UACT,CACF,EACA,OAAQ,CACN,MAAO,gBACP,WAAY,MACd,EACA,UAAW,CACT,MAAO,gBACP,WAAY,OACZ,OAAQ,CACN,MAAO,eACT,CACF,EACA,UAAW,CACT,eAAgB,aAChB,iBAAkB,CAChB,UAAW,OACb,CACF,EAGA,iBAAkB,CAChB,UAAW,SACX,OAAQ,CACN,QAAS,mBACT,QAAS,QACT,WAAY,OACZ,OAAQ,EACR,SAAU,SACV,WAAY,QACd,CACF,CACF,CACF,EACA,gBAAiB,CACf,QAAS,OACT,YAAa,SACf,EACA,SAAU,CACR,YAAa,CACX,QAAS,CACP,KAAM,CACJ,MAAO,sBACT,CACF,EACA,MAAO,CACL,KAAM,CACJ,MAAO,OACT,CACF,CACF,EACA,QAAS,CACP,KAAM,CACJ,KAAM,CACJ,YAAa,CACX,UAAW,kBACb,EACA,UAAW,CACT,UAAW,iBACb,CACF,EACA,UAAW,CACT,WAAY,gBACZ,YAAa,CACX,OAAQ,EACR,OAAQ,MACR,MAAO,cACT,EACA,UAAW,CACT,OAAQ,gBACR,KAAM,EACN,MAAO,KACT,CACF,EACA,QAAS,CACP,GAAI,SACN,EACA,QAAS,CACP,YAAa,CACX,GAAI,WACJ,GAAI,SACN,CACF,CACF,CACF,CACF,CACF,CAAC"}
@@ -51,7 +51,21 @@ var n = t({
51
51
  fontWeight: "bold",
52
52
  _hover: { color: "secondary.500" }
53
53
  },
54
- _vertical: { justifyContent: "flex-start" }
54
+ _vertical: {
55
+ justifyContent: "flex-start",
56
+ "& [data-label]": { textAlign: "start" }
57
+ },
58
+ "& [data-label]": {
59
+ textAlign: "center",
60
+ _after: {
61
+ content: "attr(data-label)",
62
+ display: "block",
63
+ fontWeight: "bold",
64
+ height: 0,
65
+ overflow: "hidden",
66
+ visibility: "hidden"
67
+ }
68
+ }
55
69
  }
56
70
  },
57
71
  defaultVariants: {