@stokelp/ui 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/Alert.cjs +1 -1
- package/dist/components/alert/Alert.cjs.map +1 -1
- package/dist/components/alert/Alert.d.ts +1 -1
- package/dist/components/alert/Alert.js +57 -53
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/app/navigation/AppNavigation.cjs.map +1 -1
- package/dist/components/app/navigation/AppNavigation.d.ts +2 -1
- package/dist/components/app/navigation/AppNavigation.js.map +1 -1
- package/dist/components/chat/ChatDocumentMessage.cjs.map +1 -1
- package/dist/components/chat/ChatDocumentMessage.js.map +1 -1
- package/dist/components/chat/ChatProfileAvatar.cjs.map +1 -1
- package/dist/components/chat/ChatProfileAvatar.js.map +1 -1
- package/dist/components/chat/ChatScoreBreakdown.cjs.map +1 -1
- package/dist/components/chat/ChatScoreBreakdown.js.map +1 -1
- package/dist/components/chat/ChatTextInput.cjs.map +1 -1
- package/dist/components/chat/ChatTextInput.d.ts +1 -1
- package/dist/components/chat/ChatTextInput.js.map +1 -1
- package/dist/components/combobox/Combobox.cjs +2 -2
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.js +17 -17
- package/dist/components/date-picker/DatePicker.cjs +1 -1
- package/dist/components/date-picker/DatePicker.cjs.map +1 -1
- package/dist/components/date-picker/DatePicker.js +68 -53
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/dialog/styled.cjs +1 -1
- package/dist/components/dialog/styled.cjs.map +1 -1
- package/dist/components/dialog/styled.js +58 -54
- package/dist/components/dialog/styled.js.map +1 -1
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.cjs.map +1 -1
- package/dist/components/drawer/Drawer.js +46 -42
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/input/HighlightedInput.cjs.map +1 -1
- package/dist/components/input/HighlightedInput.js.map +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.cjs.map +1 -1
- package/dist/components/pagination/Pagination.js +37 -36
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.js +15 -15
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.js +4 -4
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.js.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js +33 -33
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js.map +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.cjs +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.cjs.map +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.d.ts +34 -2
- package/dist/components/ui-labels/UiLabelsProvider.js +32 -7
- package/dist/components/ui-labels/UiLabelsProvider.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +69 -69
- package/package.json +20 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../utils/slots.cjs"),t=require("../icon-button/IconButton.cjs");let
|
|
1
|
+
"use client";const e=require("../../utils/slots.cjs"),t=require("../ui-labels/UiLabelsProvider.cjs"),n=require("../icon-button/IconButton.cjs");let r=require("@ark-ui/react"),i=require("@stokelp/styled-system/jsx"),a=require("@stokelp/styled-system/recipes"),o=require("react"),s=require("react/jsx-runtime"),c=require("usehooks-ts"),l=require("@stokelp/styled-system/tokens");var{withProvider:u,withContext:d}=e.createStyleContext(a.drawer),f=u(r.Dialog.Root,void 0,{defaultProps:{unmountOnExit:!0,lazyMount:!0}}),p=d((0,i.styled)(r.ark.main),`body`),m=d((0,i.styled)(r.Dialog.CloseTrigger),`closeTrigger`),h=d((0,i.styled)(r.ark.footer),`footer`),g=(0,o.forwardRef)(({children:e,showCloseTrigger:i=!0,...a},o)=>{let c=t.useUiLabels();return(0,s.jsxs)(r.ark.header,{...a,ref:o,children:[e,i&&(0,s.jsx)(m,{asChild:!0,children:(0,s.jsx)(n.IconButton,{ml:`auto`,"aria-label":c.close,variant:`tertiary`,children:(0,s.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,s.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z`,fill:`currentColor`})})})})]})});g.displayName=`DrawerHeader`;var _=d(g,`header`),v=d((0,i.styled)(r.Dialog.Title),`title`),y=d((0,i.styled)(r.Dialog.Trigger),`trigger`),b=d((0,i.styled)(r.Dialog.Positioner),`positioner`),x=d((0,i.styled)(r.Dialog.Backdrop),`backdrop`),S=(0,o.forwardRef)(({children:e,...t},n)=>{let i=(0,c.useMediaQuery)(`(max-width: ${(0,l.token)(`breakpoints.md`)})`,{defaultValue:!1}),{open:a,getContentProps:u}=(0,r.useDialogContext)();return(0,o.useLayoutEffect)(()=>{if(!a)return;let{id:e}=u();if(!e)return;let t=document.getElementById(e);if(t){let e=t.querySelector(`footer`);e&&(i?t.style.setProperty(`--footer-height`,`${Math.ceil(e.clientHeight)}px`):t.style.setProperty(`--footer-height`,`70px`))}},[a,i]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x,{}),(0,s.jsx)(b,{children:(0,s.jsx)(r.Dialog.Content,{ref:n,...t,children:e})})]})});S.displayName=r.Dialog.Content.displayName;var C=d((0,i.styled)(S),`content`),w=r.Dialog.Context;exports.Drawer=f,exports.DrawerBody=p,exports.DrawerCloseTrigger=m,exports.DrawerContent=C,exports.DrawerContext=w,exports.DrawerFooter=h,exports.DrawerHeader=_,exports.DrawerTitle=v,exports.DrawerTrigger=y;
|
|
2
2
|
//# sourceMappingURL=Drawer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","names":["createStyleContext","drawer","ArkDrawer","styled","ark","forwardRef","IconButton","useMediaQuery","token","useDialogContext","_Fragment","require_slots","require_IconButton","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","usehooks_ts","_stokelp_styled_system_tokens","Drawer","withProvider","DrawerBody","withContext","DrawerCloseTrigger","DrawerFooter","Header","props","children","showCloseTrigger","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","open","getContentProps","id","$content","$footer","DrawerContent","DrawerContext"],"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","names":["createStyleContext","drawer","ArkDrawer","styled","ark","forwardRef","useUiLabels","IconButton","useMediaQuery","token","useDialogContext","_Fragment","require_slots","require_UiLabelsProvider","require_IconButton","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","usehooks_ts","_stokelp_styled_system_tokens","Drawer","withProvider","DrawerBody","withContext","DrawerCloseTrigger","DrawerFooter","Header","props","labels","children","showCloseTrigger","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","open","getContentProps","id","$content","$footer","DrawerContent","DrawerContext"],"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => {\n const labels = useUiLabels()\n return (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label={labels.close} variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n )\n },\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n return (\n <>\n <DrawerBackdrop />\n <DrawerPositioner>\n <ArkDrawer.Content ref={ref} {...props}>\n {children}\n </ArkDrawer.Content>\n </DrawerPositioner>\n </>\n )\n },\n)\nContent.displayName = ArkDrawer.Content.displayName\n\nexport const DrawerContent = withContext(styled(Content), 'content')\nexport const DrawerContext = ArkDrawer.Context\n\nexport interface DrawerProps extends ComponentProps<typeof Drawer> {}\nexport interface DrawerBackdropProps extends ComponentProps<typeof DrawerBackdrop> {}\nexport interface DrawerBodyProps extends ComponentProps<typeof DrawerBody> {}\nexport interface DrawerCloseTriggerProps extends ComponentProps<typeof DrawerCloseTrigger> {}\nexport interface DrawerContentProps extends ComponentProps<typeof DrawerContent> {}\nexport interface DrawerFooterProps extends ComponentProps<typeof DrawerFooter> {}\nexport interface DrawerHeaderProps extends ComponentProps<typeof DrawerHeader> {}\nexport interface DrawerPositionerProps extends ComponentProps<typeof DrawerPositioner> {}\nexport interface DrawerTitleProps extends ComponentProps<typeof DrawerTitle> {}\nexport interface DrawerTriggerProps extends ComponentProps<typeof DrawerTrigger> {}\nexport interface DrawerContextProps extends ComponentProps<typeof DrawerContext> {}\n"],"mappings":"A,yXAWA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmB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AG,SAAS,EACtDQ,EAAgB5C,EAAAA,OAAU,Q"}
|
|
@@ -1,62 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStyleContext as e } from "../../utils/slots.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { useUiLabels as t } from "../ui-labels/UiLabelsProvider.js";
|
|
4
|
+
import { IconButton as n } from "../icon-button/IconButton.js";
|
|
5
|
+
import { Dialog as r, ark as i, useDialogContext as a } from "@ark-ui/react";
|
|
6
|
+
import { styled as o } from "@stokelp/styled-system/jsx";
|
|
7
|
+
import { drawer as s } from "@stokelp/styled-system/recipes";
|
|
8
|
+
import { forwardRef as c, useLayoutEffect as l } from "react";
|
|
9
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
|
+
import { useMediaQuery as p } from "usehooks-ts";
|
|
11
|
+
import { token as m } from "@stokelp/styled-system/tokens";
|
|
11
12
|
// src/components/drawer/Drawer.tsx
|
|
12
|
-
var { withProvider:
|
|
13
|
+
var { withProvider: h, withContext: g } = e(s), _ = h(r.Root, void 0, { defaultProps: {
|
|
13
14
|
unmountOnExit: !0,
|
|
14
15
|
lazyMount: !0
|
|
15
|
-
} }),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
children: /* @__PURE__ */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
} }), v = g(o(i.main), "body"), y = g(o(r.CloseTrigger), "closeTrigger"), b = g(o(i.footer), "footer"), x = c(({ children: e, showCloseTrigger: r = !0, ...a }, o) => {
|
|
17
|
+
let s = t();
|
|
18
|
+
return /* @__PURE__ */ f(i.header, {
|
|
19
|
+
...a,
|
|
20
|
+
ref: o,
|
|
21
|
+
children: [e, r && /* @__PURE__ */ d(y, {
|
|
22
|
+
asChild: !0,
|
|
23
|
+
children: /* @__PURE__ */ d(n, {
|
|
24
|
+
ml: "auto",
|
|
25
|
+
"aria-label": s.close,
|
|
26
|
+
variant: "tertiary",
|
|
27
|
+
children: /* @__PURE__ */ d("svg", {
|
|
28
|
+
width: "16",
|
|
29
|
+
height: "16",
|
|
30
|
+
viewBox: "0 0 16 16",
|
|
31
|
+
fill: "none",
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
children: /* @__PURE__ */ d("path", {
|
|
34
|
+
fillRule: "evenodd",
|
|
35
|
+
clipRule: "evenodd",
|
|
36
|
+
d: "M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z",
|
|
37
|
+
fill: "currentColor"
|
|
38
|
+
})
|
|
35
39
|
})
|
|
36
40
|
})
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
let
|
|
43
|
-
return
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
x.displayName = "DrawerHeader";
|
|
45
|
+
var S = g(x, "header"), C = g(o(r.Title), "title"), w = g(o(r.Trigger), "trigger"), T = g(o(r.Positioner), "positioner"), E = g(o(r.Backdrop), "backdrop"), D = c(({ children: e, ...t }, n) => {
|
|
46
|
+
let i = p(`(max-width: ${m("breakpoints.md")})`, { defaultValue: !1 }), { open: o, getContentProps: s } = a();
|
|
47
|
+
return l(() => {
|
|
44
48
|
if (!o) return;
|
|
45
49
|
let { id: e } = s();
|
|
46
50
|
if (!e) return;
|
|
47
51
|
let t = document.getElementById(e);
|
|
48
52
|
if (t) {
|
|
49
53
|
let e = t.querySelector("footer");
|
|
50
|
-
e && (
|
|
54
|
+
e && (i ? t.style.setProperty("--footer-height", `${Math.ceil(e.clientHeight)}px`) : t.style.setProperty("--footer-height", "70px"));
|
|
51
55
|
}
|
|
52
|
-
}, [o,
|
|
53
|
-
ref:
|
|
56
|
+
}, [o, i]), /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(E, {}), /* @__PURE__ */ d(T, { children: /* @__PURE__ */ d(r.Content, {
|
|
57
|
+
ref: n,
|
|
54
58
|
...t,
|
|
55
59
|
children: e
|
|
56
60
|
}) })] });
|
|
57
61
|
});
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
export {
|
|
62
|
+
D.displayName = r.Content.displayName;
|
|
63
|
+
var O = g(o(D), "content"), k = r.Context;
|
|
64
|
+
export { _ as Drawer, v as DrawerBody, y as DrawerCloseTrigger, O as DrawerContent, k as DrawerContext, b as DrawerFooter, S as DrawerHeader, C as DrawerTitle, w as DrawerTrigger };
|
|
61
65
|
|
|
62
66
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","names":["ArkDrawer","_Fragment","Fragment$1","createStyleContext","drawer","Drawer","withProvider","Dialog","DrawerBody","withContext","styled","ark","DrawerCloseTrigger","DrawerFooter","Header","forwardRef","props","children","showCloseTrigger","IconButton","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","useMediaQuery","token","useDialogContext","useLayoutEffect","open","getContentProps","id","$content","$footer","DrawerContent","DrawerContext"],"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["ArkDrawer","_Fragment","Fragment$1","createStyleContext","drawer","Drawer","withProvider","Dialog","DrawerBody","withContext","styled","ark","DrawerCloseTrigger","DrawerFooter","Header","forwardRef","props","labels","useUiLabels","children","showCloseTrigger","IconButton","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","useMediaQuery","token","useDialogContext","useLayoutEffect","open","getContentProps","id","$content","$footer","DrawerContent","DrawerContext"],"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => {\n const labels = useUiLabels()\n return (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label={labels.close} variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n )\n },\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n return (\n <>\n <DrawerBackdrop />\n <DrawerPositioner>\n <ArkDrawer.Content ref={ref} {...props}>\n {children}\n </ArkDrawer.Content>\n </DrawerPositioner>\n </>\n )\n },\n)\nContent.displayName = ArkDrawer.Content.displayName\n\nexport const DrawerContent = withContext(styled(Content), 'content')\nexport const DrawerContext = ArkDrawer.Context\n\nexport interface DrawerProps extends ComponentProps<typeof Drawer> {}\nexport interface DrawerBackdropProps extends ComponentProps<typeof DrawerBackdrop> {}\nexport interface DrawerBodyProps extends ComponentProps<typeof DrawerBody> {}\nexport interface DrawerCloseTriggerProps extends ComponentProps<typeof DrawerCloseTrigger> {}\nexport interface DrawerContentProps extends ComponentProps<typeof DrawerContent> {}\nexport interface DrawerFooterProps extends ComponentProps<typeof DrawerFooter> {}\nexport interface DrawerHeaderProps extends ComponentProps<typeof DrawerHeader> {}\nexport interface DrawerPositionerProps extends ComponentProps<typeof DrawerPositioner> {}\nexport interface DrawerTitleProps extends ComponentProps<typeof DrawerTitle> {}\nexport interface DrawerTriggerProps extends ComponentProps<typeof DrawerTrigger> {}\nexport interface DrawerContextProps extends ComponentProps<typeof DrawerContext> {}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAM,EAAE,iBAAc,mBAAgBG,EAAmBC,CAAM,GAElDC,IAASC,EAAaN,EAAU,MAAM,KAAA,GAAW,EAC5D,cAAc;CACZ,eAAe;CACf,WAAW;AACb,EACF,CAAC,GACYQ,IAAaC,EAAYC,EAAOC,EAAI,IAAI,GAAG,MAAM,GACjDC,IAAqBH,EAAYC,EAAOV,EAAU,YAAY,GAAG,cAAc,GAC/Ea,IAAeJ,EAAYC,EAAOC,EAAI,MAAM,GAAG,QAAQ,GAM9DG,IAASC,GACZ,EAAE,aAAU,sBAAmB,IAAM,GAAGC,KAAS,MAAQ;CACxD,IAAMC,IAASC,EAAY;CAC3B,OACE,kBAACP,EAAI,QAAL;EAAY,GAAIK;EAAY;EAA5B,UAAA,CACGG,GACAC,KACC,kBAACR,GAAD;GAAoB,SAAA;GAClB,UAAA,kBAACS,GAAD;IAAY,IAAG;IAAO,cAAYJ,EAAO;IAAO,SAAQ;IACtD,UAAA,kBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAK,SAAQ;KAAY,MAAK;KAAO,OAAM;KAChE,UAAA,kBAAC,QAAD;MACE,UAAS;MACT,UAAS;MACT,GAAE;MACF,MAAK;KACN,CAAA;IACE,CAAA;GACK,CAAA;EACM,CAAA,CAEZ;;AAEhB,CACF;AACA,EAAO,cAAc;AAErB,IAAaK,IAAeb,EAAYK,GAAQ,QAAQ,GAC3CS,IAAcd,EAAYC,EAAOV,EAAU,KAAK,GAAG,OAAO,GAC1DwB,IAAgBf,EAAYC,EAAOV,EAAU,OAAO,GAAG,SAAS,GAEvEyB,IAAmBhB,EAAYC,EAAOV,EAAU,UAAU,GAAG,YAAY,GACzE0B,IAAiBjB,EAAYC,EAAOV,EAAU,QAAQ,GAAG,UAAU,GAEnE2B,IAAUZ,GACb,EAAE,aAAU,GAAGC,KAAS,MAAQ;CAC/B,IAAMY,IAAWC,EAAc,eAAeC,EAAM,gBAAgB,EAAE,IAAI,EACxE,cAAc,GAChB,CAAC,GACK,EAAE,SAAM,uBAAoBC,EAAiB;CAmBnD,OAjBAC,QAAsB;EACpB,IAAI,CAACC,GAAM;EACX,IAAM,EAAE,UAAOC,EAAgB;EAC/B,IAAI,CAACC,GAAI;EACT,IAAMC,IAAW,SAAS,eAAeD,CAAE;EAC3C,IAAIC,GAAU;GACZ,IAAMC,IAAUD,EAAS,cAAc,QAAQ;GAC/C,AAAIC,MACET,IACFQ,EAAS,MAAM,YAAY,mBAAmB,GAAG,KAAK,KAAKC,EAAQ,YAAY,EAAE,GAAG,IAEpFD,EAAS,MAAM,YAAY,mBAAmB,MAAM;EAG1D;CACF,GAAG,CAACH,GAAML,CAAQ,CAAC,GAGjB,kBAAA3B,GAAA,EAAA,UAAA,CACE,kBAACyB,GAAD,CAAiB,CAAA,GACjB,kBAACD,GAAD,EAAA,UACE,kBAACzB,EAAU,SAAX;EAAwB;EAAK,GAAIgB;EAC9B;CACgB,CAAA,EACH,CAAA,CAClB,EAAA,CAAA;AAEN,CACF;AACA,EAAQ,cAAchB,EAAU,QAAQ;AAExC,IAAasC,IAAgB7B,EAAYC,EAAOiB,CAAO,GAAG,SAAS,GACtDY,IAAgBvC,EAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightedInput.cjs","names":["createStyleContext","highlightedInput","styled","Input","useState","useRef","require_slots","require_Input","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","Root","withProvider","InputSlot","withContext","Renderer","Highlight","HighlightedInput","controlledValue","inputProps","isControlled","uncontrolledValue","setUncontrolledValue","defaultValue","value","textBlockRef","scrollValue","setScrollValue","handleScroll","onScroll","combinedRegex","patterns","p","renderHighlightedText","nodes","lastIndex","match","start","end","matchedPattern","onChange"],"sources":["../../../src/components/input/HighlightedInput.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { highlightedInput } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input } from '~/components'\nimport { ComponentProps, type ElementRef, FC, ReactNode, useEffect, useRef, useState } from 'react'\n\nconst { withProvider, withContext } = createStyleContext(highlightedInput, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(styled('div'), 'root')\nexport const InputSlot = withContext(Input, 'input')\nexport const Renderer = withContext(styled('p'), 'renderer')\nexport const Highlight = withContext(styled('span'), 'highlight')\n\nexport type HighlightedInputRootProps = ComponentProps<typeof Root>\nexport type HighlightedInputInputProps = ComponentProps<typeof InputSlot>\nexport type HighlightedInputRendererProps = ComponentProps<typeof Renderer>\nexport type HighlightedInputHighlightProps = ComponentProps<typeof Highlight>\n\ntype HighlightPattern = { regex: RegExp; color: string }\n\ntype HighlightedInputProps = {\n patterns: HighlightPattern[]\n placeholder?: string\n} & HighlightedInputInputProps\n\nexport const HighlightedInput: FC<HighlightedInputProps> = ({\n patterns,\n value: controlledValue,\n defaultValue,\n onChange,\n onScroll,\n ...inputProps\n}) => {\n const isControlled = controlledValue !== undefined\n\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue?.toString() ?? '')\n\n const value = isControlled ? String(controlledValue) : uncontrolledValue\n\n const textBlockRef = useRef<ElementRef<typeof Renderer>>(null)\n const [scrollValue, setScrollValue] = useState(0)\n\n const handleScroll = (e: { currentTarget: { scrollLeft: number } }) => {\n setScrollValue(e.currentTarget.scrollLeft)\n onScroll?.(e as React.UIEvent<HTMLInputElement>)\n }\n\n useEffect(() => {\n if (textBlockRef.current) {\n textBlockRef.current.scrollLeft = scrollValue\n }\n }, [scrollValue])\n\n const combinedRegex = new RegExp(patterns.map((p: HighlightPattern) => p.regex.source).join('|'), 'gi')\n\n const renderHighlightedText = () => {\n const nodes: ReactNode[] = []\n let lastIndex = 0\n\n for (const match of value.matchAll(combinedRegex)) {\n const start = match.index ?? 0\n const end = start + match[0].length\n\n if (start > lastIndex) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex, start)}</span>)\n }\n\n const matchedPattern = patterns.find((p: HighlightPattern) => p.regex.test(match[0]))\n patterns.forEach((p: HighlightPattern) => (p.regex.lastIndex = 0))\n\n nodes.push(\n matchedPattern ? (\n <Highlight key={`highlight-${start}`} style={{ color: matchedPattern.color ?? 'secondary.500' }}>\n {match[0]}\n </Highlight>\n ) : (\n <span key={`text-${start}`}>{match[0]}</span>\n ),\n )\n\n lastIndex = end\n }\n\n if (lastIndex < value.length) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex)}</span>)\n }\n\n return nodes\n }\n\n return (\n <Root>\n <InputSlot\n {...inputProps}\n value={value}\n defaultValue={undefined} // prevent React warning\n onScroll={handleScroll}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) {\n setUncontrolledValue(e.target.value)\n }\n onChange?.(e)\n }}\n />\n\n <Renderer ref={textBlockRef}>{renderHighlightedText()}</Renderer>\n </Root>\n )\n}\n"],"mappings":"A,yNAMA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,iBAAkB,CACzE,SAAU,EACZ,CAAC,EAEYW,EAAOC,GAAA,EAAaX,EAAAA,OAAAA,CAAO,KAAK,EAAG,MAAM,EACzCY,EAAYC,EAAYZ,EAAAA,MAAO,OAAO,EACtCa,EAAWD,GAAA,EAAYb,EAAAA,OAAAA,CAAO,GAAG,EAAG,UAAU,EAC9Ce,EAAYF,GAAA,EAAYb,EAAAA,OAAAA,CAAO,MAAM,EAAG,WAAW,EAcnDgB,GAA+C,CAC1D,WACA,MAAOC,EACP,eACA,WACA,WACA,GAAGC,KACC,CACJ,IAAMC,EAAeF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B,CAEhD,EAEA,EAAYC,CACd,CAMA,OAJIH,EAAYX,EAAM,QACpBU,EAAM,MAAK,EAAAxB,EAAA,IAAA,CAAC,OAAD,CAAA,SAAiCc,EAAM,MAAMW,CAAS,CAAQ,EAAnD,QAAQA,GAA2C,CAAC,EAGrED,CACT,EAEA,OACE,EAAAxB,EAAA,KAAA,CAACC,EAAD,CAAA,SAAA,EACE,EAAAD,EAAA,IAAA,CAACG,EAAD,CACE,GAAIM,EACG,QACP,aAAc,IAAA,GACd,SAAUS,EACV,SAAW,GAA2C,CAC/CR,GACHE,EAAqB,EAAE,OAAO,KAAK,EAErCkB,IAAW,CAAC,CACd,CACD,CAAA,GAED,EAAA9B,EAAA,IAAA,CAACK,EAAD,CAAU,IAAKU,EAAe,SAAAQ,EAAsB,CAAY,CAAA,CAC5D,CAAA,CAAA,CAEV,E"}
|
|
1
|
+
{"version":3,"file":"HighlightedInput.cjs","names":["createStyleContext","highlightedInput","styled","Input","useState","useRef","require_slots","require_Input","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","Root","withProvider","InputSlot","withContext","Renderer","Highlight","HighlightedInput","controlledValue","inputProps","isControlled","uncontrolledValue","setUncontrolledValue","defaultValue","value","textBlockRef","scrollValue","setScrollValue","handleScroll","onScroll","combinedRegex","patterns","p","renderHighlightedText","nodes","lastIndex","match","start","end","matchedPattern","onChange"],"sources":["../../../src/components/input/HighlightedInput.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { highlightedInput } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input } from '~/components/input/Input'\nimport { ComponentProps, type ElementRef, FC, ReactNode, useEffect, useRef, useState } from 'react'\n\nconst { withProvider, withContext } = createStyleContext(highlightedInput, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(styled('div'), 'root')\nexport const InputSlot = withContext(Input, 'input')\nexport const Renderer = withContext(styled('p'), 'renderer')\nexport const Highlight = withContext(styled('span'), 'highlight')\n\nexport type HighlightedInputRootProps = ComponentProps<typeof Root>\nexport type HighlightedInputInputProps = ComponentProps<typeof InputSlot>\nexport type HighlightedInputRendererProps = ComponentProps<typeof Renderer>\nexport type HighlightedInputHighlightProps = ComponentProps<typeof Highlight>\n\ntype HighlightPattern = { regex: RegExp; color: string }\n\ntype HighlightedInputProps = {\n patterns: HighlightPattern[]\n placeholder?: string\n} & HighlightedInputInputProps\n\nexport const HighlightedInput: FC<HighlightedInputProps> = ({\n patterns,\n value: controlledValue,\n defaultValue,\n onChange,\n onScroll,\n ...inputProps\n}) => {\n const isControlled = controlledValue !== undefined\n\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue?.toString() ?? '')\n\n const value = isControlled ? String(controlledValue) : uncontrolledValue\n\n const textBlockRef = useRef<ElementRef<typeof Renderer>>(null)\n const [scrollValue, setScrollValue] = useState(0)\n\n const handleScroll = (e: { currentTarget: { scrollLeft: number } }) => {\n setScrollValue(e.currentTarget.scrollLeft)\n onScroll?.(e as React.UIEvent<HTMLInputElement>)\n }\n\n useEffect(() => {\n if (textBlockRef.current) {\n textBlockRef.current.scrollLeft = scrollValue\n }\n }, [scrollValue])\n\n const combinedRegex = new RegExp(patterns.map((p: HighlightPattern) => p.regex.source).join('|'), 'gi')\n\n const renderHighlightedText = () => {\n const nodes: ReactNode[] = []\n let lastIndex = 0\n\n for (const match of value.matchAll(combinedRegex)) {\n const start = match.index ?? 0\n const end = start + match[0].length\n\n if (start > lastIndex) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex, start)}</span>)\n }\n\n const matchedPattern = patterns.find((p: HighlightPattern) => p.regex.test(match[0]))\n patterns.forEach((p: HighlightPattern) => (p.regex.lastIndex = 0))\n\n nodes.push(\n matchedPattern ? (\n <Highlight key={`highlight-${start}`} style={{ color: matchedPattern.color ?? 'secondary.500' }}>\n {match[0]}\n </Highlight>\n ) : (\n <span key={`text-${start}`}>{match[0]}</span>\n ),\n )\n\n lastIndex = end\n }\n\n if (lastIndex < value.length) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex)}</span>)\n }\n\n return nodes\n }\n\n return (\n <Root>\n <InputSlot\n {...inputProps}\n value={value}\n defaultValue={undefined} // prevent React warning\n onScroll={handleScroll}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) {\n setUncontrolledValue(e.target.value)\n }\n onChange?.(e)\n }}\n />\n\n <Renderer ref={textBlockRef}>{renderHighlightedText()}</Renderer>\n </Root>\n )\n}\n"],"mappings":"A,yNAMA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,iBAAkB,CACzE,SAAU,EACZ,CAAC,EAEYW,EAAOC,GAAA,EAAaX,EAAAA,OAAAA,CAAO,KAAK,EAAG,MAAM,EACzCY,EAAYC,EAAYZ,EAAAA,MAAO,OAAO,EACtCa,EAAWD,GAAA,EAAYb,EAAAA,OAAAA,CAAO,GAAG,EAAG,UAAU,EAC9Ce,EAAYF,GAAA,EAAYb,EAAAA,OAAAA,CAAO,MAAM,EAAG,WAAW,EAcnDgB,GAA+C,CAC1D,WACA,MAAOC,EACP,eACA,WACA,WACA,GAAGC,KACC,CACJ,IAAMC,EAAeF,IAAoB,IAAA,GAEnC,CAACG,EAAmBC,IAAA,EAAwBnB,EAAAA,SAAAA,CAASoB,GAAc,SAAS,GAAK,EAAE,EAEnFC,EAAQJ,EAAe,OAAOF,CAAe,EAAIG,EAEjDI,GAAA,EAAerB,EAAAA,OAAAA,CAAoC,IAAI,EACvD,CAACsB,EAAaC,IAAA,EAAkBxB,EAAAA,SAAAA,CAAS,CAAC,EAE1CyB,EAAgB,GAAiD,CACrED,EAAe,EAAE,cAAc,UAAU,EACzCE,IAAW,CAAoC,CACjD,GAEA,EAAApB,EAAA,UAAA,KAAgB,CACVgB,EAAa,UACf,EAAa,QAAQ,WAAaC,EAEtC,EAAG,CAACA,CAAW,CAAC,EAEhB,IAAMI,EAAgB,IAAI,OAAO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EAAe,SAAAQ,EAAsB,CAAY,CAAA,CAC5D,CAAA,CAAA,CAEV,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightedInput.js","names":["createStyleContext","highlightedInput","Root","withProvider","styled","InputSlot","withContext","Input","Renderer","Highlight","HighlightedInput","controlledValue","inputProps","isControlled","uncontrolledValue","setUncontrolledValue","useState","defaultValue","value","textBlockRef","useRef","scrollValue","setScrollValue","handleScroll","onScroll","combinedRegex","patterns","p","renderHighlightedText","nodes","lastIndex","match","start","end","matchedPattern","onChange"],"sources":["../../../src/components/input/HighlightedInput.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { highlightedInput } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input } from '~/components'\nimport { ComponentProps, type ElementRef, FC, ReactNode, useEffect, useRef, useState } from 'react'\n\nconst { withProvider, withContext } = createStyleContext(highlightedInput, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(styled('div'), 'root')\nexport const InputSlot = withContext(Input, 'input')\nexport const Renderer = withContext(styled('p'), 'renderer')\nexport const Highlight = withContext(styled('span'), 'highlight')\n\nexport type HighlightedInputRootProps = ComponentProps<typeof Root>\nexport type HighlightedInputInputProps = ComponentProps<typeof InputSlot>\nexport type HighlightedInputRendererProps = ComponentProps<typeof Renderer>\nexport type HighlightedInputHighlightProps = ComponentProps<typeof Highlight>\n\ntype HighlightPattern = { regex: RegExp; color: string }\n\ntype HighlightedInputProps = {\n patterns: HighlightPattern[]\n placeholder?: string\n} & HighlightedInputInputProps\n\nexport const HighlightedInput: FC<HighlightedInputProps> = ({\n patterns,\n value: controlledValue,\n defaultValue,\n onChange,\n onScroll,\n ...inputProps\n}) => {\n const isControlled = controlledValue !== undefined\n\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue?.toString() ?? '')\n\n const value = isControlled ? String(controlledValue) : uncontrolledValue\n\n const textBlockRef = useRef<ElementRef<typeof Renderer>>(null)\n const [scrollValue, setScrollValue] = useState(0)\n\n const handleScroll = (e: { currentTarget: { scrollLeft: number } }) => {\n setScrollValue(e.currentTarget.scrollLeft)\n onScroll?.(e as React.UIEvent<HTMLInputElement>)\n }\n\n useEffect(() => {\n if (textBlockRef.current) {\n textBlockRef.current.scrollLeft = scrollValue\n }\n }, [scrollValue])\n\n const combinedRegex = new RegExp(patterns.map((p: HighlightPattern) => p.regex.source).join('|'), 'gi')\n\n const renderHighlightedText = () => {\n const nodes: ReactNode[] = []\n let lastIndex = 0\n\n for (const match of value.matchAll(combinedRegex)) {\n const start = match.index ?? 0\n const end = start + match[0].length\n\n if (start > lastIndex) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex, start)}</span>)\n }\n\n const matchedPattern = patterns.find((p: HighlightPattern) => p.regex.test(match[0]))\n patterns.forEach((p: HighlightPattern) => (p.regex.lastIndex = 0))\n\n nodes.push(\n matchedPattern ? (\n <Highlight key={`highlight-${start}`} style={{ color: matchedPattern.color ?? 'secondary.500' }}>\n {match[0]}\n </Highlight>\n ) : (\n <span key={`text-${start}`}>{match[0]}</span>\n ),\n )\n\n lastIndex = end\n }\n\n if (lastIndex < value.length) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex)}</span>)\n }\n\n return nodes\n }\n\n return (\n <Root>\n <InputSlot\n {...inputProps}\n value={value}\n defaultValue={undefined} // prevent React warning\n onScroll={handleScroll}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) {\n setUncontrolledValue(e.target.value)\n }\n onChange?.(e)\n }}\n />\n\n <Renderer ref={textBlockRef}>{renderHighlightedText()}</Renderer>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;AAMA,IAAM,EAAE,iBAAc,mBAAgBA,EAAmBC,GAAkB,EACzE,UAAU,GACZ,CAAC,GAEYC,IAAOC,EAAaC,EAAO,KAAK,GAAG,MAAM,GACzCC,IAAYC,EAAYC,GAAO,OAAO,GACtCC,IAAWF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AA,UAA6BD,EAAM,GAAS,GAAjC,QAAQC,GAAyB,CAEhD,GAEA,IAAYC;EACd;EAMA,OAJIH,IAAYZ,EAAM,UACpBW,EAAM,KAAK,kBAAC,QAAD,EAAA,UAAiCX,EAAM,MAAMY,CAAS,EAAQ,GAAnD,QAAQA,GAA2C,CAAC,GAGrED;CACT;CAEA,OACE,kBAAC3B,GAAD,EAAA,UAAA,CACE,kBAACG,GAAD;EACE,GAAIO;EACG;EACP,cAAc,KAAA;EACd,UAAUW;EACV,WAAW,MAA2C;GAIpD,AAHKV,KACHE,EAAqB,EAAE,OAAO,KAAK,GAErCoB,IAAW,CAAC;EACd;CACD,CAAA,GAED,kBAAC3B,GAAD;EAAU,KAAKW;EAAe,UAAAS,EAAsB;CAAY,CAAA,CAC5D,EAAA,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"HighlightedInput.js","names":["createStyleContext","highlightedInput","Root","withProvider","styled","InputSlot","withContext","Input","Renderer","Highlight","HighlightedInput","controlledValue","inputProps","isControlled","uncontrolledValue","setUncontrolledValue","useState","defaultValue","value","textBlockRef","useRef","scrollValue","setScrollValue","handleScroll","onScroll","combinedRegex","patterns","p","renderHighlightedText","nodes","lastIndex","match","start","end","matchedPattern","onChange"],"sources":["../../../src/components/input/HighlightedInput.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { highlightedInput } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { Input } from '~/components/input/Input'\nimport { ComponentProps, type ElementRef, FC, ReactNode, useEffect, useRef, useState } from 'react'\n\nconst { withProvider, withContext } = createStyleContext(highlightedInput, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(styled('div'), 'root')\nexport const InputSlot = withContext(Input, 'input')\nexport const Renderer = withContext(styled('p'), 'renderer')\nexport const Highlight = withContext(styled('span'), 'highlight')\n\nexport type HighlightedInputRootProps = ComponentProps<typeof Root>\nexport type HighlightedInputInputProps = ComponentProps<typeof InputSlot>\nexport type HighlightedInputRendererProps = ComponentProps<typeof Renderer>\nexport type HighlightedInputHighlightProps = ComponentProps<typeof Highlight>\n\ntype HighlightPattern = { regex: RegExp; color: string }\n\ntype HighlightedInputProps = {\n patterns: HighlightPattern[]\n placeholder?: string\n} & HighlightedInputInputProps\n\nexport const HighlightedInput: FC<HighlightedInputProps> = ({\n patterns,\n value: controlledValue,\n defaultValue,\n onChange,\n onScroll,\n ...inputProps\n}) => {\n const isControlled = controlledValue !== undefined\n\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue?.toString() ?? '')\n\n const value = isControlled ? String(controlledValue) : uncontrolledValue\n\n const textBlockRef = useRef<ElementRef<typeof Renderer>>(null)\n const [scrollValue, setScrollValue] = useState(0)\n\n const handleScroll = (e: { currentTarget: { scrollLeft: number } }) => {\n setScrollValue(e.currentTarget.scrollLeft)\n onScroll?.(e as React.UIEvent<HTMLInputElement>)\n }\n\n useEffect(() => {\n if (textBlockRef.current) {\n textBlockRef.current.scrollLeft = scrollValue\n }\n }, [scrollValue])\n\n const combinedRegex = new RegExp(patterns.map((p: HighlightPattern) => p.regex.source).join('|'), 'gi')\n\n const renderHighlightedText = () => {\n const nodes: ReactNode[] = []\n let lastIndex = 0\n\n for (const match of value.matchAll(combinedRegex)) {\n const start = match.index ?? 0\n const end = start + match[0].length\n\n if (start > lastIndex) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex, start)}</span>)\n }\n\n const matchedPattern = patterns.find((p: HighlightPattern) => p.regex.test(match[0]))\n patterns.forEach((p: HighlightPattern) => (p.regex.lastIndex = 0))\n\n nodes.push(\n matchedPattern ? (\n <Highlight key={`highlight-${start}`} style={{ color: matchedPattern.color ?? 'secondary.500' }}>\n {match[0]}\n </Highlight>\n ) : (\n <span key={`text-${start}`}>{match[0]}</span>\n ),\n )\n\n lastIndex = end\n }\n\n if (lastIndex < value.length) {\n nodes.push(<span key={`text-${lastIndex}`}>{value.slice(lastIndex)}</span>)\n }\n\n return nodes\n }\n\n return (\n <Root>\n <InputSlot\n {...inputProps}\n value={value}\n defaultValue={undefined} // prevent React warning\n onScroll={handleScroll}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n if (!isControlled) {\n setUncontrolledValue(e.target.value)\n }\n onChange?.(e)\n }}\n />\n\n <Renderer ref={textBlockRef}>{renderHighlightedText()}</Renderer>\n </Root>\n )\n}\n"],"mappings":";;;;;;;;AAMA,IAAM,EAAE,iBAAc,mBAAgBA,EAAmBC,GAAkB,EACzE,UAAU,GACZ,CAAC,GAEYC,IAAOC,EAAaC,EAAO,KAAK,GAAG,MAAM,GACzCC,IAAYC,EAAYC,GAAO,OAAO,GACtCC,IAAWF,EAAYF,EAAO,GAAG,GAAG,UAAU,GAC9CK,IAAYH,EAAYF,EAAO,MAAM,GAAG,WAAW,GAcnDM,KAA+C,EAC1D,aACA,OAAOC,GACP,iBACA,aACA,aACA,GAAGC,QACC;CACJ,IAAMC,IAAeF,MAAoB,KAAA,GAEnC,CAACG,GAAmBC,KAAwBC,EAASC,GAAc,SAAS,KAAK,EAAE,GAEnFC,IAAQL,IAAe,OAAOF,CAAe,IAAIG,GAEjDK,IAAeC,EAAoC,IAAI,GACvD,CAACC,GAAaC,KAAkBN,EAAS,CAAC,GAE1CO,KAAgB,MAAiD;EAErE,AADAD,EAAe,EAAE,cAAc,UAAU,GACzCE,IAAW,CAAoC;CACjD;CAEA,QAAgB;EACd,AAAIL,EAAa,YACf,EAAa,QAAQ,aAAaE;CAEtC,GAAG,CAACA,CAAW,CAAC;CAEhB,IAAMI,IAAgB,IAAI,OAAOC,EAAS,KAAK,MAAwBC,EAAE,MAAM,MAAM,CAAC,CAAC,KAAK,GAAG,GAAG,IAAI,GAEhGC,UAA8B;EAClC,IAAMC,IAAqB,CAAC,GACxBC,IAAY;EAEhB,KAAK,IAAMC,KAASb,EAAM,SAASO,CAAa,GAAG;GACjD,IAAMO,IAAQD,EAAM,SAAS,GACvBE,IAAMD,IAAQD,EAAM,EAAE,CAAC;GAE7B,AAAIC,IAAQF,KACVD,EAAM,KAAK,kBAAC,QAAD,EAAA,UAAiCX,EAAM,MAAMY,GAAWE,CAAK,EAAQ,GAA1D,QAAQF,GAAkD,CAAC;GAGnF,IAAMI,IAAiBR,EAAS,MAAM,MAAwBC,EAAE,MAAM,KAAKI,EAAM,EAAE,CAAC;GAapF,AAZAL,EAAS,SAAS,MAAyB,EAAE,MAAM,YAAY,CAAE,GAEjEG,EAAM,KACJK,IACE,kBAACzB,GAAD;IAAsC,OAAO,EAAE,OAAOyB,EAAe,SAAS,gBAAgB;IAC3F,UAAAH,EAAM;GACE,GAFK,aAAaC,GAElB,IAEX,kBAAC,QAAD,EAAA,UAA6BD,EAAM,GAAS,GAAjC,QAAQC,GAAyB,CAEhD,GAEA,IAAYC;EACd;EAMA,OAJIH,IAAYZ,EAAM,UACpBW,EAAM,KAAK,kBAAC,QAAD,EAAA,UAAiCX,EAAM,MAAMY,CAAS,EAAQ,GAAnD,QAAQA,GAA2C,CAAC,GAGrED;CACT;CAEA,OACE,kBAAC3B,GAAD,EAAA,UAAA,CACE,kBAACG,GAAD;EACE,GAAIO;EACG;EACP,cAAc,KAAA;EACd,UAAUW;EACV,WAAW,MAA2C;GAIpD,AAHKV,KACHE,EAAqB,EAAE,OAAO,KAAK,GAErCoB,IAAW,CAAC;EACd;CACD,CAAA,GAED,kBAAC3B,GAAD;EAAU,KAAKW;EAAe,UAAAS,EAAsB;CAAY,CAAA,CAC5D,EAAA,CAAA;AAEV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../utils/slots.cjs"),t=require("../icon-button/IconButton.cjs"),
|
|
1
|
+
"use client";const e=require("../../utils/slots.cjs"),t=require("../ui-labels/UiLabelsProvider.cjs"),n=require("../icon-button/IconButton.cjs"),r=require("./use-pagination.cjs"),i=require("../../shared/utils/events.cjs");let a=require("@stokelp/styled-system/jsx"),o=require("@stokelp/styled-system/recipes"),s=require("react"),c=require("react/jsx-runtime");var{withProvider:l,withContext:u}=e.createStyleContext(o.pagination),d=l((0,a.styled)(`div`),`root`),f=u((0,a.styled)(`button`),`item`),p=u((0,a.styled)(`div`),`dots`),m=({total:e,value:a,defaultValue:o,onChange:l,disabled:u,onNextPage:m,onPrevPage:h,siblings:g=2,boundaries:_=1,...v})=>{let{range:y,setPage:b,next:x,previous:S,active:C}=r.usePagination({page:a,initialPage:o,onChange:l,total:e,siblings:g,boundaries:_}),w=t.useUiLabels(),T=i.createEventHandler(m,x),E=i.createEventHandler(h,S);return(0,c.jsxs)(d,{...v,children:[(0,c.jsx)(n.IconButton,{size:`md`,variant:`tertiary`,"aria-label":w.previousPage,disabled:u||C===1,onClick:E,children:(0,c.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,c.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L10.1464 2.64645C10.3417 2.45119 10.6583 2.45119 10.8536 2.64645C11.0488 2.84171 11.0488 3.15829 10.8536 3.35355L6.20711 8L10.8536 12.6464C11.0488 12.8417 11.0488 13.1583 10.8536 13.3536C10.6583 13.5488 10.3417 13.5488 10.1464 13.3536L5.14645 8.35355Z`,fill:`currentColor`})})}),y.map((e,t)=>e===r.DOTS?(0,s.createElement)(p,{...u?{"data-disabled":!0}:{},key:t},`...`):(0,c.jsx)(f,{disabled:u,...e===C?{"data-selected":!0}:{},onClick:()=>b(e),children:e},t)),(0,c.jsx)(n.IconButton,{size:`md`,variant:`tertiary`,"aria-label":w.nextPage,disabled:u||C===e,onClick:T,children:(0,c.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,c.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.8536 7.64645C11.0488 7.84171 11.0488 8.15829 10.8536 8.35355L5.85355 13.3536C5.65829 13.5488 5.34171 13.5488 5.14645 13.3536C4.95118 13.1583 4.95118 12.8417 5.14645 12.6464L9.79289 8L5.14645 3.35355C4.95118 3.15829 4.95118 2.84171 5.14645 2.64645C5.34171 2.45118 5.65829 2.45118 5.85355 2.64645L10.8536 7.64645Z`,fill:`currentColor`})})})]})};exports.Pagination=m;
|
|
2
2
|
//# sourceMappingURL=Pagination.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.cjs","names":["createStyleContext","pagination","styled","usePagination","createEventHandler","IconButton","DOTS","require_slots","require_IconButton","require_use_pagination","require_events","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledPagination","withProvider","PaginationItem","withContext","PaginationDots","Pagination","props","value","defaultValue","handleNextPage","onNextPage","next","handlePreviousPage","onPrevPage","previous","disabled","active","range","pageNumber","index","setPage","total"],"sources":["../../../src/components/pagination/Pagination.tsx"],"sourcesContent":["import type { ComponentProps, FC } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { pagination } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { DOTS, usePagination } from './use-pagination'\nimport { createEventHandler } from '~/shared/utils/events'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(pagination)\n\nconst StyledPagination = withProvider(styled('div'), 'root')\ntype StyledPaginationProps = ComponentProps<typeof StyledPagination>\n\nconst PaginationItem = withContext(styled('button'), 'item')\nconst PaginationDots = withContext(styled('div'), 'dots')\n\nexport interface PaginationProps extends Omit<StyledPaginationProps, 'children' | 'defaultValue' | 'onChange'> {\n total: number\n value?: number\n defaultValue?: number\n onChange?: (value: number) => void\n disabled?: boolean\n siblings?: number\n boundaries?: number\n onNextPage?: () => void\n onPrevPage?: () => void\n}\n\nexport const Pagination: FC<PaginationProps> = ({\n total,\n value,\n defaultValue,\n onChange,\n disabled,\n onNextPage,\n onPrevPage,\n siblings = 2,\n boundaries = 1,\n ...props\n}: PaginationProps) => {\n const { range, setPage, next, previous, active } = usePagination({\n page: value,\n initialPage: defaultValue,\n onChange,\n total,\n siblings,\n boundaries,\n })\n\n const handleNextPage = createEventHandler(onNextPage, next)\n const handlePreviousPage = createEventHandler(onPrevPage, previous)\n\n return (\n <StyledPagination {...props}>\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label
|
|
1
|
+
{"version":3,"file":"Pagination.cjs","names":["createStyleContext","pagination","styled","usePagination","useUiLabels","createEventHandler","IconButton","DOTS","require_slots","require_UiLabelsProvider","require_IconButton","require_use_pagination","require_events","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledPagination","withProvider","PaginationItem","withContext","PaginationDots","Pagination","props","value","defaultValue","labels","handleNextPage","onNextPage","next","handlePreviousPage","onPrevPage","previous","disabled","active","range","pageNumber","index","setPage","total"],"sources":["../../../src/components/pagination/Pagination.tsx"],"sourcesContent":["import type { ComponentProps, FC } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { pagination } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { DOTS, usePagination } from './use-pagination'\nimport { createEventHandler } from '~/shared/utils/events'\nimport { IconButton } from '~/components/icon-button'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\n\nconst { withProvider, withContext } = createStyleContext(pagination)\n\nconst StyledPagination = withProvider(styled('div'), 'root')\ntype StyledPaginationProps = ComponentProps<typeof StyledPagination>\n\nconst PaginationItem = withContext(styled('button'), 'item')\nconst PaginationDots = withContext(styled('div'), 'dots')\n\nexport interface PaginationProps extends Omit<StyledPaginationProps, 'children' | 'defaultValue' | 'onChange'> {\n total: number\n value?: number\n defaultValue?: number\n onChange?: (value: number) => void\n disabled?: boolean\n siblings?: number\n boundaries?: number\n onNextPage?: () => void\n onPrevPage?: () => void\n}\n\nexport const Pagination: FC<PaginationProps> = ({\n total,\n value,\n defaultValue,\n onChange,\n disabled,\n onNextPage,\n onPrevPage,\n siblings = 2,\n boundaries = 1,\n ...props\n}: PaginationProps) => {\n const { range, setPage, next, previous, active } = usePagination({\n page: value,\n initialPage: defaultValue,\n onChange,\n total,\n siblings,\n boundaries,\n })\n\n const labels = useUiLabels()\n const handleNextPage = createEventHandler(onNextPage, next)\n const handlePreviousPage = createEventHandler(onPrevPage, previous)\n\n return (\n <StyledPagination {...props}>\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label={labels.previousPage}\n disabled={disabled || active === 1}\n onClick={handlePreviousPage}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L10.1464 2.64645C10.3417 2.45119 10.6583 2.45119 10.8536 2.64645C11.0488 2.84171 11.0488 3.15829 10.8536 3.35355L6.20711 8L10.8536 12.6464C11.0488 12.8417 11.0488 13.1583 10.8536 13.3536C10.6583 13.5488 10.3417 13.5488 10.1464 13.3536L5.14645 8.35355Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n {range.map((pageNumber, index) => {\n if (pageNumber === DOTS) {\n return (\n <PaginationDots {...(disabled ? { 'data-disabled': true } : {})} key={index}>\n ...\n </PaginationDots>\n )\n }\n\n const isSelected = pageNumber === active\n\n return (\n <PaginationItem\n key={index}\n disabled={disabled}\n {...(isSelected\n ? {\n 'data-selected': true,\n }\n : {})}\n onClick={() => setPage(pageNumber)}\n >\n {pageNumber}\n </PaginationItem>\n )\n })}\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label={labels.nextPage}\n disabled={disabled || active === total}\n onClick={handleNextPage}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.8536 7.64645C11.0488 7.84171 11.0488 8.15829 10.8536 8.35355L5.85355 13.3536C5.65829 13.5488 5.34171 13.5488 5.14645 13.3536C4.95118 13.1583 4.95118 12.8417 5.14645 12.6464L9.79289 8L5.14645 3.35355C4.95118 3.15829 4.95118 2.84171 5.14645 2.64645C5.34171 2.45118 5.65829 2.45118 5.85355 2.64645L10.8536 7.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </StyledPagination>\n )\n}\n"],"mappings":"A,uWASA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,UAAU,EAE7DgB,EAAmBC,GAAA,EAAahB,EAAAA,OAAAA,CAAO,KAAK,EAAG,MAAM,EAGrDiB,EAAiBC,GAAA,EAAYlB,EAAAA,OAAAA,CAAO,QAAQ,EAAG,MAAM,EACrDmB,EAAiBD,GAAA,EAAYlB,EAAAA,OAAAA,CAAO,KAAK,EAAG,MAAM,EAc3CoB,GAAmC,CAC9C,QACA,QACA,eACA,WACA,WACA,aACA,aACA,WAAW,EACX,aAAa,EACb,GAAGC,KACkB,CACrB,GAAM,CAAE,QAAO,UAAS,OAAM,WAAU,UAAWpB,EAAAA,cAAc,CAC/D,KAAMqB,EACN,YAAaC,EACb,WACA,QACA,WACA,YACF,CAAC,EAEKC,EAAStB,EAAAA,YAAY,EACrBuB,EAAiBtB,EAAAA,mBAAmBuB,EAAYC,CAAI,EACpDC,EAAqBzB,EAAAA,mBAAmB0B,EAAYC,CAAQ,EAElE,OACE,EAAAhB,EAAA,KAAA,CAACC,EAAD,CAAkB,GAAIM,EAAtB,SAAA,EACE,EAAAP,EAAA,IAAA,CAACV,EAAAA,WAAD,CACE,KAAK,KACL,QAAQ,WACR,aAAYoB,EAAO,aACnB,SAAUO,GAAYC,IAAW,EACjC,QAASJ,EAET,UAAA,EAAAd,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,UAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,8TACF,KAAK,cACN,CAAA,CACE,CAAA,CACK,CAAA,EACXmB,EAAM,KAAK,EAAY,IAClBC,IAAe7B,EAAAA,MAEf,EAAAQ,EAAA,cAAA,CAACM,EAAD,CAAgB,GAAKY,EAAW,CAAE,gBAAiB,EAAK,EAAI,CAAC,EAAI,IAAKI,CAEtD,EAF6D,KAE7D,GAOlB,EAAArB,EAAA,IAAA,CAACG,EAAD,CAEY,WACV,GANeiB,IAAeF,EAO1B,CACE,gBAAiB,EACnB,EACA,CAAC,EACL,YAAeI,EAAQF,CAAU,EAEhC,SAAAA,CACa,EAVTC,CAUS,CAEnB,GACD,EAAArB,EAAA,IAAA,CAACV,EAAAA,WAAD,CACE,KAAK,KACL,QAAQ,WACR,aAAYoB,EAAO,SACnB,SAAUO,GAAYC,IAAWK,EACjC,QAASZ,EAET,UAAA,EAAAX,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,UAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,8TACF,KAAK,cACN,CAAA,CACE,CAAA,CACK,CAAA,CACI,C,EAEtB,E"}
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createStyleContext as e } from "../../utils/slots.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { useUiLabels as t } from "../ui-labels/UiLabelsProvider.js";
|
|
4
|
+
import { IconButton as n } from "../icon-button/IconButton.js";
|
|
5
|
+
import { DOTS as r, usePagination as i } from "./use-pagination.js";
|
|
6
|
+
import { createEventHandler as a } from "../../shared/utils/events.js";
|
|
7
|
+
import { styled as o } from "@stokelp/styled-system/jsx";
|
|
8
|
+
import { pagination as s } from "@stokelp/styled-system/recipes";
|
|
9
|
+
import { createElement as c } from "react";
|
|
10
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
11
|
// src/components/pagination/Pagination.tsx
|
|
11
|
-
var { withProvider:
|
|
12
|
-
let { range:
|
|
13
|
-
page:
|
|
14
|
-
initialPage:
|
|
15
|
-
onChange:
|
|
12
|
+
var { withProvider: d, withContext: f } = e(s), p = d(o("div"), "root"), m = f(o("button"), "item"), h = f(o("div"), "dots"), g = ({ total: e, value: o, defaultValue: s, onChange: d, disabled: f, onNextPage: g, onPrevPage: _, siblings: v = 2, boundaries: y = 1, ...b }) => {
|
|
13
|
+
let { range: x, setPage: S, next: C, previous: w, active: T } = i({
|
|
14
|
+
page: o,
|
|
15
|
+
initialPage: s,
|
|
16
|
+
onChange: d,
|
|
16
17
|
total: e,
|
|
17
|
-
siblings:
|
|
18
|
-
boundaries:
|
|
19
|
-
}),
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
...
|
|
18
|
+
siblings: v,
|
|
19
|
+
boundaries: y
|
|
20
|
+
}), E = t(), D = a(g, C), O = a(_, w);
|
|
21
|
+
return /* @__PURE__ */ u(p, {
|
|
22
|
+
...b,
|
|
22
23
|
children: [
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ l(n, {
|
|
24
25
|
size: "md",
|
|
25
26
|
variant: "tertiary",
|
|
26
|
-
"aria-label":
|
|
27
|
-
disabled:
|
|
28
|
-
onClick:
|
|
29
|
-
children: /* @__PURE__ */
|
|
27
|
+
"aria-label": E.previousPage,
|
|
28
|
+
disabled: f || T === 1,
|
|
29
|
+
onClick: O,
|
|
30
|
+
children: /* @__PURE__ */ l("svg", {
|
|
30
31
|
width: "16",
|
|
31
32
|
height: "16",
|
|
32
33
|
viewBox: "0 0 16 16",
|
|
33
34
|
fill: "none",
|
|
34
35
|
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
-
children: /* @__PURE__ */
|
|
36
|
+
children: /* @__PURE__ */ l("path", {
|
|
36
37
|
fillRule: "evenodd",
|
|
37
38
|
clipRule: "evenodd",
|
|
38
39
|
d: "M5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L10.1464 2.64645C10.3417 2.45119 10.6583 2.45119 10.8536 2.64645C11.0488 2.84171 11.0488 3.15829 10.8536 3.35355L6.20711 8L10.8536 12.6464C11.0488 12.8417 11.0488 13.1583 10.8536 13.3536C10.6583 13.5488 10.3417 13.5488 10.1464 13.3536L5.14645 8.35355Z",
|
|
@@ -40,28 +41,28 @@ var { withProvider: u, withContext: d } = e(o), f = u(a("div"), "root"), p = d(a
|
|
|
40
41
|
})
|
|
41
42
|
})
|
|
42
43
|
}),
|
|
43
|
-
|
|
44
|
-
...
|
|
44
|
+
x.map((e, t) => e === r ? /* @__PURE__ */ c(h, {
|
|
45
|
+
...f ? { "data-disabled": !0 } : {},
|
|
45
46
|
key: t
|
|
46
|
-
}, "...") : /* @__PURE__ */
|
|
47
|
-
disabled:
|
|
48
|
-
...e ===
|
|
49
|
-
onClick: () =>
|
|
47
|
+
}, "...") : /* @__PURE__ */ l(m, {
|
|
48
|
+
disabled: f,
|
|
49
|
+
...e === T ? { "data-selected": !0 } : {},
|
|
50
|
+
onClick: () => S(e),
|
|
50
51
|
children: e
|
|
51
52
|
}, t)),
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ l(n, {
|
|
53
54
|
size: "md",
|
|
54
55
|
variant: "tertiary",
|
|
55
|
-
"aria-label":
|
|
56
|
-
disabled:
|
|
57
|
-
onClick:
|
|
58
|
-
children: /* @__PURE__ */
|
|
56
|
+
"aria-label": E.nextPage,
|
|
57
|
+
disabled: f || T === e,
|
|
58
|
+
onClick: D,
|
|
59
|
+
children: /* @__PURE__ */ l("svg", {
|
|
59
60
|
width: "16",
|
|
60
61
|
height: "16",
|
|
61
62
|
viewBox: "0 0 16 16",
|
|
62
63
|
fill: "none",
|
|
63
64
|
xmlns: "http://www.w3.org/2000/svg",
|
|
64
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ l("path", {
|
|
65
66
|
fillRule: "evenodd",
|
|
66
67
|
clipRule: "evenodd",
|
|
67
68
|
d: "M10.8536 7.64645C11.0488 7.84171 11.0488 8.15829 10.8536 8.35355L5.85355 13.3536C5.65829 13.5488 5.34171 13.5488 5.14645 13.3536C4.95118 13.1583 4.95118 12.8417 5.14645 12.6464L9.79289 8L5.14645 3.35355C4.95118 3.15829 4.95118 2.84171 5.14645 2.64645C5.34171 2.45118 5.65829 2.45118 5.85355 2.64645L10.8536 7.64645Z",
|
|
@@ -72,6 +73,6 @@ var { withProvider: u, withContext: d } = e(o), f = u(a("div"), "root"), p = d(a
|
|
|
72
73
|
]
|
|
73
74
|
});
|
|
74
75
|
};
|
|
75
|
-
export {
|
|
76
|
+
export { g as Pagination };
|
|
76
77
|
|
|
77
78
|
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","names":["createStyleContext","pagination","StyledPagination","withProvider","styled","PaginationItem","withContext","PaginationDots","Pagination","props","usePagination","value","defaultValue","handleNextPage","createEventHandler","onNextPage","next","handlePreviousPage","onPrevPage","previous","IconButton","disabled","active","range","pageNumber","DOTS","index","setPage","total"],"sources":["../../../src/components/pagination/Pagination.tsx"],"sourcesContent":["import type { ComponentProps, FC } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { pagination } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { DOTS, usePagination } from './use-pagination'\nimport { createEventHandler } from '~/shared/utils/events'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(pagination)\n\nconst StyledPagination = withProvider(styled('div'), 'root')\ntype StyledPaginationProps = ComponentProps<typeof StyledPagination>\n\nconst PaginationItem = withContext(styled('button'), 'item')\nconst PaginationDots = withContext(styled('div'), 'dots')\n\nexport interface PaginationProps extends Omit<StyledPaginationProps, 'children' | 'defaultValue' | 'onChange'> {\n total: number\n value?: number\n defaultValue?: number\n onChange?: (value: number) => void\n disabled?: boolean\n siblings?: number\n boundaries?: number\n onNextPage?: () => void\n onPrevPage?: () => void\n}\n\nexport const Pagination: FC<PaginationProps> = ({\n total,\n value,\n defaultValue,\n onChange,\n disabled,\n onNextPage,\n onPrevPage,\n siblings = 2,\n boundaries = 1,\n ...props\n}: PaginationProps) => {\n const { range, setPage, next, previous, active } = usePagination({\n page: value,\n initialPage: defaultValue,\n onChange,\n total,\n siblings,\n boundaries,\n })\n\n const handleNextPage = createEventHandler(onNextPage, next)\n const handlePreviousPage = createEventHandler(onPrevPage, previous)\n\n return (\n <StyledPagination {...props}>\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label
|
|
1
|
+
{"version":3,"file":"Pagination.js","names":["createStyleContext","pagination","StyledPagination","withProvider","styled","PaginationItem","withContext","PaginationDots","Pagination","props","usePagination","value","defaultValue","labels","useUiLabels","handleNextPage","createEventHandler","onNextPage","next","handlePreviousPage","onPrevPage","previous","IconButton","disabled","active","range","pageNumber","DOTS","index","setPage","total"],"sources":["../../../src/components/pagination/Pagination.tsx"],"sourcesContent":["import type { ComponentProps, FC } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { pagination } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { DOTS, usePagination } from './use-pagination'\nimport { createEventHandler } from '~/shared/utils/events'\nimport { IconButton } from '~/components/icon-button'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\n\nconst { withProvider, withContext } = createStyleContext(pagination)\n\nconst StyledPagination = withProvider(styled('div'), 'root')\ntype StyledPaginationProps = ComponentProps<typeof StyledPagination>\n\nconst PaginationItem = withContext(styled('button'), 'item')\nconst PaginationDots = withContext(styled('div'), 'dots')\n\nexport interface PaginationProps extends Omit<StyledPaginationProps, 'children' | 'defaultValue' | 'onChange'> {\n total: number\n value?: number\n defaultValue?: number\n onChange?: (value: number) => void\n disabled?: boolean\n siblings?: number\n boundaries?: number\n onNextPage?: () => void\n onPrevPage?: () => void\n}\n\nexport const Pagination: FC<PaginationProps> = ({\n total,\n value,\n defaultValue,\n onChange,\n disabled,\n onNextPage,\n onPrevPage,\n siblings = 2,\n boundaries = 1,\n ...props\n}: PaginationProps) => {\n const { range, setPage, next, previous, active } = usePagination({\n page: value,\n initialPage: defaultValue,\n onChange,\n total,\n siblings,\n boundaries,\n })\n\n const labels = useUiLabels()\n const handleNextPage = createEventHandler(onNextPage, next)\n const handlePreviousPage = createEventHandler(onPrevPage, previous)\n\n return (\n <StyledPagination {...props}>\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label={labels.previousPage}\n disabled={disabled || active === 1}\n onClick={handlePreviousPage}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L10.1464 2.64645C10.3417 2.45119 10.6583 2.45119 10.8536 2.64645C11.0488 2.84171 11.0488 3.15829 10.8536 3.35355L6.20711 8L10.8536 12.6464C11.0488 12.8417 11.0488 13.1583 10.8536 13.3536C10.6583 13.5488 10.3417 13.5488 10.1464 13.3536L5.14645 8.35355Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n {range.map((pageNumber, index) => {\n if (pageNumber === DOTS) {\n return (\n <PaginationDots {...(disabled ? { 'data-disabled': true } : {})} key={index}>\n ...\n </PaginationDots>\n )\n }\n\n const isSelected = pageNumber === active\n\n return (\n <PaginationItem\n key={index}\n disabled={disabled}\n {...(isSelected\n ? {\n 'data-selected': true,\n }\n : {})}\n onClick={() => setPage(pageNumber)}\n >\n {pageNumber}\n </PaginationItem>\n )\n })}\n <IconButton\n size=\"md\"\n variant=\"tertiary\"\n aria-label={labels.nextPage}\n disabled={disabled || active === total}\n onClick={handleNextPage}\n >\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10.8536 7.64645C11.0488 7.84171 11.0488 8.15829 10.8536 8.35355L5.85355 13.3536C5.65829 13.5488 5.34171 13.5488 5.14645 13.3536C4.95118 13.1583 4.95118 12.8417 5.14645 12.6464L9.79289 8L5.14645 3.35355C4.95118 3.15829 4.95118 2.84171 5.14645 2.64645C5.34171 2.45118 5.65829 2.45118 5.85355 2.64645L10.8536 7.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </StyledPagination>\n )\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAM,EAAE,iBAAc,mBAAgBA,EAAmBC,CAAU,GAE7DC,IAAmBC,EAAaC,EAAO,KAAK,GAAG,MAAM,GAGrDC,IAAiBC,EAAYF,EAAO,QAAQ,GAAG,MAAM,GACrDG,IAAiBD,EAAYF,EAAO,KAAK,GAAG,MAAM,GAc3CI,KAAmC,EAC9C,UACA,UACA,iBACA,aACA,aACA,eACA,eACA,cAAW,GACX,gBAAa,GACb,GAAGC,QACkB;CACrB,IAAM,EAAE,UAAO,YAAS,SAAM,aAAU,cAAWC,EAAc;EAC/D,MAAMC;EACN,aAAaC;EACb;EACA;EACA;EACA;CACF,CAAC,GAEKC,IAASC,EAAY,GACrBC,IAAiBC,EAAmBC,GAAYC,CAAI,GACpDC,IAAqBH,EAAmBI,GAAYC,CAAQ;CAElE,OACE,kBAACnB,GAAD;EAAkB,GAAIO;EAAtB,UAAA;GACE,kBAACa,GAAD;IACE,MAAK;IACL,SAAQ;IACR,cAAYT,EAAO;IACnB,UAAUU,KAAYC,MAAW;IACjC,SAASL;IAET,UAAA,kBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAK,SAAQ;KAAY,MAAK;KAAO,OAAM;KAChE,UAAA,kBAAC,QAAD;MACE,UAAS;MACT,UAAS;MACT,GAAE;MACF,MAAK;KACN,CAAA;IACE,CAAA;GACK,CAAA;GACXM,EAAM,KAAK,GAAY,MAClBC,MAAeC,IAEf,kBAACpB,GAAD;IAAgB,GAAKgB,IAAW,EAAE,iBAAiB,GAAK,IAAI,CAAC;IAAI,KAAKK;GAEtD,GAF6D,KAE7D,IAOlB,kBAACvB,GAAD;IAEY;IACV,GANeqB,MAAeF,IAO1B,EACE,iBAAiB,GACnB,IACA,CAAC;IACL,eAAeK,EAAQH,CAAU;IAEhC,UAAAA;GACa,GAVTE,CAUS,CAEnB;GACD,kBAACN,GAAD;IACE,MAAK;IACL,SAAQ;IACR,cAAYT,EAAO;IACnB,UAAUU,KAAYC,MAAWM;IACjC,SAASf;IAET,UAAA,kBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAK,SAAQ;KAAY,MAAK;KAAO,OAAM;KAChE,UAAA,kBAAC,QAAD;MACE,UAAS;MACT,UAAS;MACT,GAAE;MACF,MAAK;KACN,CAAA;IACE,CAAA;GACK,CAAA;EACI;;AAEtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../utils/slots.cjs"),t=require("../
|
|
1
|
+
"use client";const e=require("../../utils/slots.cjs"),t=require("../ui-labels/UiLabelsProvider.cjs"),n=require("../tooltip/Tooltip.cjs"),r=require("../text/Text.cjs"),i=require("../../shared/ConditionalWrapper.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("@stokelp/styled-system/css"),d=require("react-window");var{withProvider:f,withContext:p}=e.createStyleContext(s.select),m=f((0,o.styled)(a.Select.Root),`root`,{defaultProps:{loopFocus:!0}}),h=p((0,o.styled)(a.Select.ClearTrigger),`clearTrigger`),g=p((0,o.styled)(a.Select.Content),`content`),_=p((0,o.styled)(a.Select.Control),`control`),v=p((0,o.styled)(a.Select.Indicator),`indicator`),y=p((0,o.styled)(a.Select.Item),`item`),b=p((0,o.styled)(a.Select.ItemGroup),`itemGroup`),x=p((0,o.styled)(a.Select.ItemGroupLabel),`itemGroupLabel`),S=p((0,o.styled)(a.Select.ItemText),`itemText`),C=p((0,o.styled)(a.Select.Positioner),`positioner`),w=p((0,o.styled)(a.Select.Trigger),`trigger`),T=p((0,o.styled)(a.Select.ValueText),`valueText`),E=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,fill:`white`}),(0,l.jsx)(`rect`,{x:`0.5`,y:`1`,width:`15`,height:`15`,rx:`3.5`,className:(0,u.css)({stroke:`grey.100`})})]}),D=()=>(0,l.jsxs)(`svg`,{width:`16`,height:`17`,viewBox:`0 0 16 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,l.jsx)(`rect`,{y:`0.5`,width:`16`,height:`16`,rx:`4`,className:(0,u.css)({fill:`primary.500`})}),(0,l.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 O({placeholder:e,allSelectedLabel:t}){let n=(0,a.useSelectContext)(),r=n.collection.items,i=n.selectedItems;return n.multiple&&i.filter(e=>!e.disabled).length>=r.filter(e=>!e.disabled).length&&t?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:t}):(0,l.jsx)(T,{truncate:!0,placeholder:e})}function k({renderTrigger:e,placeholder:t,allSelectedLabel:n}){let r=(0,a.useSelectContext)(),i=r.value&&r.value.length>0?r.collection.findMany(r.value):[];if(i.length===0)return(0,l.jsx)(T,{className:`custom`,truncate:!0,placeholder:t});let o=r.selectedItems;return r.multiple&&o.filter(e=>!e.disabled).length>=r.collection.items.filter(e=>!e.disabled).length&&n?(0,l.jsx)(T,{className:`custom`,truncate:!0,children:n}):(0,l.jsx)(T,{className:`custom`,placeholder:t,children:i.map(t=>(0,l.jsx)(`span`,{children:e(t)},t.value))})}function A({item:e,isMultiple:t,renderItem:n}){let r=(0,a.useSelectItemContext)();return(0,l.jsxs)(l.Fragment,{children:[t?r.selected?(0,l.jsx)(D,{}):(0,l.jsx)(E,{}):null,n?n(e):(0,l.jsx)(S,{truncate:!0,children:e.label})]})}function j({index:e,style:t,ariaAttributes:r,items:a,isMultiple:o,renderItem:s}){let c=a[e];return(0,l.jsx)(i.ConditionalWrapper,{when:!!c.tooltip,wrapper:e=>(0,l.jsx)(n.Tooltip,{label:c.tooltip,children:e}),children:(0,l.jsx)(y,{item:c,style:t,"aria-posinset":r[`aria-posinset`],"aria-setsize":r[`aria-setsize`],children:(0,l.jsx)(A,{renderItem:s,item:c,isMultiple:o})})})}function M(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.label===n.groupLabel?e.items.push(n):t.push({label:n.groupLabel,items:[n]})}return t}function N({items:e,placeholder:o,emptyLabel:s,usePortal:f=!0,positioning:p,renderItem:S,renderTrigger:T,virtualized:E,rowHeight:D=34,...N}){let P=t.useUiLabels(),F=(0,a.createListCollection)({items:e}),I=(0,c.useRef)(null),L=e=>(0,l.jsxs)(c.Fragment,{children:[(0,l.jsx)(i.ConditionalWrapper,{when:!!e.tooltip,wrapper:t=>(0,l.jsx)(n.Tooltip,{label:e.tooltip,children:t}),children:(0,l.jsx)(y,{item:e,children:(0,l.jsx)(A,{renderItem:S,item:e,isMultiple:N.multiple})},e.value)},e.value),e.separatorAfter&&(0,l.jsx)(`div`,{role:`separator`,className:(0,u.css)({height:`1px`,flexShrink:0,backgroundColor:`grey.100`,marginY:`space-4`,marginX:`space-8`})})]},e.value);return(0,l.jsxs)(m,{lazyMount:!0,unmountOnExit:!0,collection:F,positioning:{sameWidth:!0,gutter:0,...p},"data-recipe":`select`,...N,ref:e=>{e&&(I.current=e.closest(`[role="dialog"]`))},children:[(0,l.jsxs)(_,{children:[(0,l.jsxs)(w,{children:[T?(0,l.jsx)(k,{renderTrigger:T,placeholder:o,allSelectedLabel:N.allSelectedLabel}):(0,l.jsx)(O,{placeholder:o,allSelectedLabel:N.allSelectedLabel}),(0,l.jsx)(v,{asChild:!0,children:(0,l.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.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,l.jsx)(h,{disabled:N.readOnly,asChild:!0,children:(0,l.jsx)(`button`,{children:(0,l.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.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,l.jsx)(i.ConditionalWrapper,{when:f,wrapper:e=>(0,l.jsx)(a.Portal,{container:I,children:e}),children:(0,l.jsx)(C,{children:(0,l.jsx)(g,{children:e.length===0?(0,l.jsx)(r.Text,{px:`space-8`,textAlign:`center`,children:s??P.noResults}):E?(0,l.jsx)(d.List,{role:`presentation`,rowComponent:j,rowProps:{items:e,isMultiple:N.multiple,renderItem:S},rowCount:e.length,rowHeight:D,style:{height:Math.min(D*e.length,180)}}):M(e).map((e,t)=>e.label===void 0?(0,l.jsx)(c.Fragment,{children:e.items.map(L)},`group-${t}`):(0,l.jsxs)(b,{children:[(0,l.jsx)(x,{children:e.label}),e.items.map(L)]},`group-${t}`))})})}),(0,l.jsx)(a.Select.HiddenSelect,{})]})}exports.Select=N;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.map
|