@oneplatformdev/ui 0.1.99-beta.58 → 0.1.99-beta.59
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/AlertDialog/AlertDialog.stories.js +3 -2
- package/AlertDialog/AlertDialog.stories.js.map +1 -1
- package/AlertDialog/AlertDialogRoot.js +19 -18
- package/AlertDialog/AlertDialogRoot.js.map +1 -1
- package/Button/Button.d.ts.map +1 -1
- package/Button/Button.js +43 -43
- package/Button/Button.js.map +1 -1
- package/Button/Button.utils.d.ts +3 -0
- package/Button/Button.utils.d.ts.map +1 -0
- package/Button/Button.utils.js +14 -0
- package/Button/Button.utils.js.map +1 -0
- package/Button/index.d.ts +1 -0
- package/Button/index.d.ts.map +1 -1
- package/Button/index.js +8 -6
- package/Button/index.js.map +1 -1
- package/ButtonIcon/ButtonIcon.d.ts.map +1 -1
- package/ButtonIcon/ButtonIcon.js +41 -39
- package/ButtonIcon/ButtonIcon.js.map +1 -1
- package/ButtonIcon/ButtonIcon.stories.js +35 -33
- package/ButtonIcon/ButtonIcon.stories.js.map +1 -1
- package/CHANGELOG.md +34 -0
- package/Calendar/Calendar.js +5 -4
- package/Calendar/Calendar.js.map +1 -1
- package/DataTable/DataTable.js +16 -15
- package/DataTable/DataTable.js.map +1 -1
- package/Search/Search.js +33 -31
- package/Search/Search.js.map +1 -1
- package/TablePagination/TablePagination.js +9 -8
- package/TablePagination/TablePagination.js.map +1 -1
- package/index.js +330 -328
- package/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as i } from "react/jsx-runtime";
|
|
2
2
|
import { ButtonIcon as t } from "./ButtonIcon.js";
|
|
3
|
-
import { FileDownIcon as c, Trash2Icon as l, PlusIcon as a, MessageCircleMoreIcon as
|
|
3
|
+
import { MailIcon as p, FileDownIcon as c, Trash2Icon as l, PlusIcon as a, MessageCircleMoreIcon as B } from "lucide-react";
|
|
4
4
|
import { DashedWrapper as s } from "../.storybook/Wrappers.js";
|
|
5
5
|
const h = (e) => /* @__PURE__ */ o(t, { ...e });
|
|
6
6
|
h.args = {
|
|
@@ -37,19 +37,21 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
37
37
|
/* @__PURE__ */ o(r, { ...e, variant: "outlined", rounded: !0 }),
|
|
38
38
|
/* @__PURE__ */ o(r, { ...e, variant: "ghost", rounded: !0 })
|
|
39
39
|
] })
|
|
40
|
-
] }),
|
|
40
|
+
] }), f = ["contained", "outlined", "ghost"], g = ["primary", "secondary", "error"], d = ["xs", "sm", "md", "lg"], b = "contained", x = "primary", P = "lg", v = {
|
|
41
41
|
undefined: void 0,
|
|
42
42
|
"<PlusIcon />": /* @__PURE__ */ o(a, {}),
|
|
43
43
|
"<Trash2Icon />": /* @__PURE__ */ o(l, {}),
|
|
44
44
|
"<FileDownIcon />": /* @__PURE__ */ o(c, {}),
|
|
45
|
+
"<MailIcon />": /* @__PURE__ */ o(p, {}),
|
|
45
46
|
PlusIcon: a,
|
|
46
47
|
Trash2Icon: l,
|
|
47
|
-
FileDownIcon: c
|
|
48
|
-
|
|
48
|
+
FileDownIcon: c,
|
|
49
|
+
MailIcon: p
|
|
50
|
+
}, I = {
|
|
49
51
|
"<PlusIcon />": /* @__PURE__ */ o(a, {}),
|
|
50
52
|
"<Trash2Icon />": /* @__PURE__ */ o(l, {}),
|
|
51
53
|
"<FileDownIcon />": /* @__PURE__ */ o(c, {})
|
|
52
|
-
},
|
|
54
|
+
}, y = {
|
|
53
55
|
title: "ButtonIcon",
|
|
54
56
|
component: t,
|
|
55
57
|
render: h,
|
|
@@ -58,9 +60,9 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
58
60
|
disabled: !1,
|
|
59
61
|
loading: !1,
|
|
60
62
|
rounded: !1,
|
|
61
|
-
variant:
|
|
62
|
-
color:
|
|
63
|
-
size:
|
|
63
|
+
variant: b,
|
|
64
|
+
color: x,
|
|
65
|
+
size: P,
|
|
64
66
|
children: /* @__PURE__ */ o(a, {}),
|
|
65
67
|
icon: void 0,
|
|
66
68
|
message: void 0,
|
|
@@ -80,15 +82,15 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
80
82
|
variant: {
|
|
81
83
|
name: "variant",
|
|
82
84
|
description: "ButtonIcon variant",
|
|
83
|
-
defaultValue:
|
|
84
|
-
options:
|
|
85
|
+
defaultValue: f[0],
|
|
86
|
+
options: f,
|
|
85
87
|
control: { type: "inline-radio" }
|
|
86
88
|
},
|
|
87
89
|
color: {
|
|
88
90
|
name: "color",
|
|
89
91
|
description: "ButtonIcon color",
|
|
90
|
-
defaultValue:
|
|
91
|
-
options:
|
|
92
|
+
defaultValue: g[0],
|
|
93
|
+
options: g,
|
|
92
94
|
control: { type: "inline-radio" }
|
|
93
95
|
},
|
|
94
96
|
size: {
|
|
@@ -126,15 +128,15 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
126
128
|
icon: {
|
|
127
129
|
name: "icon",
|
|
128
130
|
description: "ButtonIcon icon from ButtonIconProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]",
|
|
129
|
-
options: Object.keys(
|
|
130
|
-
mapping:
|
|
131
|
+
options: Object.keys(v),
|
|
132
|
+
mapping: v,
|
|
131
133
|
control: { type: "inline-radio" }
|
|
132
134
|
},
|
|
133
135
|
children: {
|
|
134
136
|
name: "children",
|
|
135
137
|
description: "ButtonIcon children from ButtonIconProps [`ReactNode`]",
|
|
136
|
-
options: Object.keys(
|
|
137
|
-
mapping:
|
|
138
|
+
options: Object.keys(I),
|
|
139
|
+
mapping: I,
|
|
138
140
|
control: { type: "inline-radio" }
|
|
139
141
|
},
|
|
140
142
|
counter: {
|
|
@@ -157,13 +159,13 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
157
159
|
loading: !1,
|
|
158
160
|
rounded: !1,
|
|
159
161
|
children: /* @__PURE__ */ o(a, {})
|
|
160
|
-
},
|
|
162
|
+
}, j = {
|
|
161
163
|
args: {
|
|
162
|
-
...
|
|
164
|
+
...y.args,
|
|
163
165
|
icon: c,
|
|
164
166
|
children: void 0
|
|
165
167
|
}
|
|
166
|
-
},
|
|
168
|
+
}, E = {
|
|
167
169
|
render: (e) => /* @__PURE__ */ o("div", { className: "flex flex-col gap-3", children: d.map((n) => /* @__PURE__ */ i(s, { children: [
|
|
168
170
|
/* @__PURE__ */ o(t, { ...e, size: n, message: "from counter" }),
|
|
169
171
|
/* @__PURE__ */ o(t, { ...e, size: n, counter: 0, message: "count=0" }),
|
|
@@ -172,10 +174,10 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
172
174
|
/* @__PURE__ */ o(t, { ...e, size: n, counter: 999, message: "count=999" })
|
|
173
175
|
] }, n)) }),
|
|
174
176
|
args: {
|
|
175
|
-
...
|
|
177
|
+
...y.args,
|
|
176
178
|
variant: "ghost",
|
|
177
179
|
color: "secondary",
|
|
178
|
-
icon:
|
|
180
|
+
icon: B,
|
|
179
181
|
counter: 12,
|
|
180
182
|
title: "counter"
|
|
181
183
|
},
|
|
@@ -184,7 +186,7 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
184
186
|
include: ["counter", "variant", "color", "disabled", "loading", "rounded"]
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
|
-
},
|
|
189
|
+
}, C = {
|
|
188
190
|
args: {
|
|
189
191
|
...m,
|
|
190
192
|
color: "primary",
|
|
@@ -196,10 +198,10 @@ const r = (e) => /* @__PURE__ */ o(
|
|
|
196
198
|
},
|
|
197
199
|
render: u
|
|
198
200
|
};
|
|
199
|
-
|
|
201
|
+
C.parameters = {
|
|
200
202
|
controls: { exclude: ["variant", "color"] }
|
|
201
203
|
};
|
|
202
|
-
const
|
|
204
|
+
const T = {
|
|
203
205
|
args: {
|
|
204
206
|
...m,
|
|
205
207
|
color: "secondary",
|
|
@@ -211,10 +213,10 @@ const C = {
|
|
|
211
213
|
},
|
|
212
214
|
render: u
|
|
213
215
|
};
|
|
214
|
-
|
|
216
|
+
T.parameters = {
|
|
215
217
|
controls: { exclude: ["variant", "color"] }
|
|
216
218
|
};
|
|
217
|
-
const
|
|
219
|
+
const S = {
|
|
218
220
|
args: {
|
|
219
221
|
...m,
|
|
220
222
|
color: "error",
|
|
@@ -226,15 +228,15 @@ const T = {
|
|
|
226
228
|
},
|
|
227
229
|
render: u
|
|
228
230
|
};
|
|
229
|
-
|
|
231
|
+
S.parameters = {
|
|
230
232
|
controls: { exclude: ["variant", "color"] }
|
|
231
233
|
};
|
|
232
234
|
export {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
235
|
+
E as Counter,
|
|
236
|
+
j as Default,
|
|
237
|
+
S as Error,
|
|
238
|
+
C as Primary,
|
|
239
|
+
T as Secondary,
|
|
240
|
+
y as default
|
|
239
241
|
};
|
|
240
242
|
//# sourceMappingURL=ButtonIcon.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.stories.js","sources":["../../src/ButtonIcon/ButtonIcon.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { ButtonIcon } from './ButtonIcon';\nimport type { ButtonIconProps } from './ButtonIcon.types';\nimport React from 'react';\nimport { FileDownIcon, PlusIcon, Trash2Icon, MessageCircleMoreIcon } from 'lucide-react'\nimport { DashedWrapper } from \"../../.storybook/Wrappers\";\nimport { ButtonProps } from \"../Button\";\n\nconst Template = (props: ButtonIconProps) => <ButtonIcon {...props}/>\nTemplate.args = {\n onClick: { action: (e: React.MouseEvent<HTMLButtonElement>) => e },\n};\n\nconst States = (props: ButtonIconProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled' ]\n .map((state) => (\n <ButtonIcon\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n >\n {props.children}\n </ButtonIcon>\n ))}\n </div>\n);\n\nconst StateRender = (props: ButtonIconProps) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n <DashedWrapper>\n <States {...props} variant='contained' rounded/>\n <States {...props} variant='outlined' rounded/>\n <States {...props} variant='ghost' rounded/>\n </DashedWrapper>\n </div>\n);\n\nconst variants: ButtonIconProps['variant'][] = [ 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonIconProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonIconProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst variant_default: ButtonProps['variant'] = 'contained';\nconst color_default: ButtonProps['color'] = 'primary';\nconst size_default: ButtonProps['size'] = 'lg';\n\nconst iconMap = {\n 'undefined': undefined,\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n PlusIcon: PlusIcon,\n Trash2Icon: Trash2Icon,\n FileDownIcon: FileDownIcon,\n};\n\nconst iconChildrenMap = {\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n};\n\nconst meta = {\n title: 'ButtonIcon',\n component: ButtonIcon,\n render: Template,\n args: {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n variant: variant_default,\n color: color_default,\n size: size_default,\n children: <PlusIcon/>,\n icon: undefined,\n message: undefined,\n title: undefined,\n },\n argTypes: {\n tooltip: {\n name: 'tooltip',\n description: 'ButtonIcon tooltip from ButtonIconProps [deprecated, use title and message instead]',\n control: false,\n },\n asChild: {\n name: 'asChild',\n description: 'ButtonIcon asChild from ButtonIconProps [boolean]',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'ButtonIcon variant',\n defaultValue: variants[0],\n options: variants,\n control: { type: 'inline-radio', },\n },\n color: {\n name: 'color',\n description: 'ButtonIcon color',\n defaultValue: colors[0],\n options: colors,\n control: { type: 'inline-radio' },\n },\n size: {\n name: 'size',\n description: 'ButtonIcon size',\n defaultValue: sizes[0],\n options: sizes,\n control: { type: 'inline-radio' },\n },\n title: {\n name: 'title',\n description: \"ButtonIcon tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'ButtonIcon tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n disabled: {\n name: 'disabled',\n description: 'ButtonIcon disabled',\n control: { type: 'boolean' }\n },\n rounded: {\n name: 'rounded',\n description: 'ButtonIcon rounded',\n control: { type: 'boolean' }\n },\n loading: {\n name: 'loading',\n description: 'ButtonIcon loading',\n control: { type: 'boolean' }\n },\n icon: {\n name: 'icon',\n description: 'ButtonIcon icon from ButtonIconProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n children: {\n name: 'children',\n description: 'ButtonIcon children from ButtonIconProps [`ReactNode`]',\n options: Object.keys(iconChildrenMap),\n mapping: iconChildrenMap,\n control: { type: 'inline-radio' },\n },\n counter: {\n name: 'counter',\n description: 'ButtonIcon counter from ButtonIconProps [`number` | `ButtonCounterBadgeReaderOptions`]',\n control: { type: 'number' },\n }\n },\n parameters: {\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof ButtonIcon>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n children: <PlusIcon/>,\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n icon: FileDownIcon,\n children: undefined,\n }\n};\n\nexport const Counter: Story = {\n render: (props) => (\n <div className='flex flex-col gap-3'>\n {sizes.map((size) => (\n <DashedWrapper key={size}>\n <ButtonIcon {...props} size={size} message='from counter'/>\n <ButtonIcon {...props} size={size} counter={0} message='count=0'/>\n <ButtonIcon {...props} size={size} counter={9} message='count=9'/>\n <ButtonIcon {...props} size={size} counter={99} message='count=99'/>\n <ButtonIcon {...props} size={size} counter={999} message='count=999'/>\n </DashedWrapper>\n ))}\n </div>\n ),\n args: {\n ...meta.args,\n variant: 'ghost',\n color: 'secondary',\n icon: MessageCircleMoreIcon,\n counter: 12,\n title: 'counter',\n },\n parameters: {\n controls: {\n include: ['counter', 'variant', 'color', 'disabled', 'loading', 'rounded' ],\n },\n },\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nPrimary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nSecondary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nError.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n"],"names":["Template","props","jsx","ButtonIcon","States","state","StateRender","jsxs","DashedWrapper","variants","colors","sizes","variant_default","color_default","size_default","iconMap","PlusIcon","Trash2Icon","FileDownIcon","iconChildrenMap","meta","args","Default","Counter","size","MessageCircleMoreIcon","Primary","Secondary","Error"],"mappings":";;;;AASA,MAAMA,IAAW,CAACC,MAA2B,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAM;AACnED,EAAS,OAAO;AAAA,EACd,SAAS,EAAE,QAAQ,CAAC,MAA2C,EAAA;AACjE;AAEA,MAAMI,IAAS,CAACH,MACd,gBA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;AAC5C;AAEO,MAAMC,IAAmB;AAAA,EAC9B,MAAM;AAAA,IACJ,GAAGN;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQf;AACV;AACAqB,EAAU,aAAa;AAAA,EACrB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;AAEO,MAAMC,IAAe;AAAA,EAC1B,MAAM;AAAA,IACJ,GAAGP;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQf;AACV;AACAsB,EAAM,aAAa;AAAA,EACjB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;"}
|
|
1
|
+
{"version":3,"file":"ButtonIcon.stories.js","sources":["../../src/ButtonIcon/ButtonIcon.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { ButtonIcon } from './ButtonIcon';\nimport type { ButtonIconProps } from './ButtonIcon.types';\nimport React from 'react';\nimport { FileDownIcon, PlusIcon, Trash2Icon, MessageCircleMoreIcon, MailIcon } from 'lucide-react'\nimport { DashedWrapper } from \"../../.storybook/Wrappers\";\nimport { ButtonProps } from \"../Button\";\n\nconst Template = (props: ButtonIconProps) => <ButtonIcon {...props}/>\nTemplate.args = {\n onClick: { action: (e: React.MouseEvent<HTMLButtonElement>) => e },\n};\n\nconst States = (props: ButtonIconProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled' ]\n .map((state) => (\n <ButtonIcon\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n >\n {props.children}\n </ButtonIcon>\n ))}\n </div>\n);\n\nconst StateRender = (props: ButtonIconProps) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n <DashedWrapper>\n <States {...props} variant='contained' rounded/>\n <States {...props} variant='outlined' rounded/>\n <States {...props} variant='ghost' rounded/>\n </DashedWrapper>\n </div>\n);\n\nconst variants: ButtonIconProps['variant'][] = [ 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonIconProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonIconProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst variant_default: ButtonProps['variant'] = 'contained';\nconst color_default: ButtonProps['color'] = 'primary';\nconst size_default: ButtonProps['size'] = 'lg';\n\nconst iconMap = {\n 'undefined': undefined,\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n \"<MailIcon />\": <MailIcon/>,\n PlusIcon: PlusIcon,\n Trash2Icon: Trash2Icon,\n FileDownIcon: FileDownIcon,\n MailIcon: MailIcon,\n};\n\nconst iconChildrenMap = {\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n};\n\nconst meta = {\n title: 'ButtonIcon',\n component: ButtonIcon,\n render: Template,\n args: {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n variant: variant_default,\n color: color_default,\n size: size_default,\n children: <PlusIcon/>,\n icon: undefined,\n message: undefined,\n title: undefined,\n },\n argTypes: {\n tooltip: {\n name: 'tooltip',\n description: 'ButtonIcon tooltip from ButtonIconProps [deprecated, use title and message instead]',\n control: false,\n },\n asChild: {\n name: 'asChild',\n description: 'ButtonIcon asChild from ButtonIconProps [boolean]',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'ButtonIcon variant',\n defaultValue: variants[0],\n options: variants,\n control: { type: 'inline-radio', },\n },\n color: {\n name: 'color',\n description: 'ButtonIcon color',\n defaultValue: colors[0],\n options: colors,\n control: { type: 'inline-radio' },\n },\n size: {\n name: 'size',\n description: 'ButtonIcon size',\n defaultValue: sizes[0],\n options: sizes,\n control: { type: 'inline-radio' },\n },\n title: {\n name: 'title',\n description: \"ButtonIcon tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'ButtonIcon tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n disabled: {\n name: 'disabled',\n description: 'ButtonIcon disabled',\n control: { type: 'boolean' }\n },\n rounded: {\n name: 'rounded',\n description: 'ButtonIcon rounded',\n control: { type: 'boolean' }\n },\n loading: {\n name: 'loading',\n description: 'ButtonIcon loading',\n control: { type: 'boolean' }\n },\n icon: {\n name: 'icon',\n description: 'ButtonIcon icon from ButtonIconProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n children: {\n name: 'children',\n description: 'ButtonIcon children from ButtonIconProps [`ReactNode`]',\n options: Object.keys(iconChildrenMap),\n mapping: iconChildrenMap,\n control: { type: 'inline-radio' },\n },\n counter: {\n name: 'counter',\n description: 'ButtonIcon counter from ButtonIconProps [`number` | `ButtonCounterBadgeReaderOptions`]',\n control: { type: 'number' },\n }\n },\n parameters: {\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof ButtonIcon>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n children: <PlusIcon/>,\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n icon: FileDownIcon,\n children: undefined,\n }\n};\n\nexport const Counter: Story = {\n render: (props) => (\n <div className='flex flex-col gap-3'>\n {sizes.map((size) => (\n <DashedWrapper key={size}>\n <ButtonIcon {...props} size={size} message='from counter'/>\n <ButtonIcon {...props} size={size} counter={0} message='count=0'/>\n <ButtonIcon {...props} size={size} counter={9} message='count=9'/>\n <ButtonIcon {...props} size={size} counter={99} message='count=99'/>\n <ButtonIcon {...props} size={size} counter={999} message='count=999'/>\n </DashedWrapper>\n ))}\n </div>\n ),\n args: {\n ...meta.args,\n variant: 'ghost',\n color: 'secondary',\n icon: MessageCircleMoreIcon,\n counter: 12,\n title: 'counter',\n },\n parameters: {\n controls: {\n include: ['counter', 'variant', 'color', 'disabled', 'loading', 'rounded' ],\n },\n },\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nPrimary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nSecondary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nError.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n"],"names":["Template","props","jsx","ButtonIcon","States","state","StateRender","jsxs","DashedWrapper","variants","colors","sizes","variant_default","color_default","size_default","iconMap","PlusIcon","Trash2Icon","FileDownIcon","MailIcon","iconChildrenMap","meta","args","Default","Counter","size","MessageCircleMoreIcon","Primary","Secondary","Error"],"mappings":";;;;AASA,MAAMA,IAAW,CAACC,MAA2B,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAM;AACnED,EAAS,OAAO;AAAA,EACd,SAAS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AAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQhB;AACV;AACAqB,EAAQ,aAAa;AAAA,EACnB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;AAEO,MAAMC,IAAmB;AAAA,EAC9B,MAAM;AAAA,IACJ,GAAGN;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQhB;AACV;AACAsB,EAAU,aAAa;AAAA,EACrB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;AAEO,MAAMC,IAAe;AAAA,EAC1B,MAAM;AAAA,IACJ,GAAGP;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQhB;AACV;AACAuB,EAAM,aAAa;AAAA,EACjB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 0.1.99-beta.59 (2026-01-15)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **Search:** enhance search input with keyboard shortcuts and refactor state management ([041954b](https://github.com/oneplatformdev/core-web/commit/041954b))
|
|
6
|
+
- **App:** add routing for button and button-icon pages, enhance navigation ([ad89b21](https://github.com/oneplatformdev/core-web/commit/ad89b21))
|
|
7
|
+
- **Button:** enhance button component with new variants, adornments, and improved props ([0d373b8](https://github.com/oneplatformdev/core-web/commit/0d373b8))
|
|
8
|
+
- enhance FormSelect with onChangePrepare and updated onChange signature ([3b4402b](https://github.com/oneplatformdev/core-web/commit/3b4402b))
|
|
9
|
+
|
|
10
|
+
### 🩹 Fixes
|
|
11
|
+
|
|
12
|
+
- **FormSelect:** ensure default value is an empty string when undefined ([056631f](https://github.com/oneplatformdev/core-web/commit/056631f))
|
|
13
|
+
- update icon size for large button variant ([1e7c0a7](https://github.com/oneplatformdev/core-web/commit/1e7c0a7))
|
|
14
|
+
- add min-width to large button variant ([e34bc71](https://github.com/oneplatformdev/core-web/commit/e34bc71))
|
|
15
|
+
- handle undefined value in FormSelect component ([9c7ae4a](https://github.com/oneplatformdev/core-web/commit/9c7ae4a))
|
|
16
|
+
- minor alert dialog content ([#41](https://github.com/oneplatformdev/core-web/pull/41))
|
|
17
|
+
- update Dialog component title font size for better readability and add .env to .gitignore ([9646134](https://github.com/oneplatformdev/core-web/commit/9646134))
|
|
18
|
+
- adjust Dialog component styling for better alignment and update container size in CSS ([afaa5af](https://github.com/oneplatformdev/core-web/commit/afaa5af))
|
|
19
|
+
- update XIcon styling in Dialog component for improved visibility ([164338b](https://github.com/oneplatformdev/core-web/commit/164338b))
|
|
20
|
+
- update dialog primitive close ([5e7c577](https://github.com/oneplatformdev/core-web/commit/5e7c577))
|
|
21
|
+
- update dialog primitive close ([560b5ba](https://github.com/oneplatformdev/core-web/commit/560b5ba))
|
|
22
|
+
- update dialog primitive close ([f63b143](https://github.com/oneplatformdev/core-web/commit/f63b143))
|
|
23
|
+
|
|
24
|
+
### 🧱 Updated Dependencies
|
|
25
|
+
|
|
26
|
+
- Updated @oneplatformdev/utils to 0.1.99-beta.59
|
|
27
|
+
- Updated @oneplatformdev/hooks to 0.1.99-beta.59
|
|
28
|
+
- Updated @oneplatformdev/tokens to 0.1.99-beta.59
|
|
29
|
+
|
|
30
|
+
### ❤️ Thank You
|
|
31
|
+
|
|
32
|
+
- Bohdan Radchenko @BohdanRadchenko
|
|
33
|
+
- BohdanRadchenko
|
|
34
|
+
|
|
1
35
|
## 0.1.99-beta.57 (2026-01-15)
|
|
2
36
|
|
|
3
37
|
### 🚀 Features
|
package/Calendar/Calendar.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronRight as
|
|
2
|
+
import { ChevronRight as c, ChevronLeft as l } from "lucide-react";
|
|
3
3
|
import { DayPicker as m } from "react-day-picker";
|
|
4
4
|
import { cn as e } from "@oneplatformdev/utils";
|
|
5
5
|
import "../Button/Button.js";
|
|
6
6
|
import { buttonVariants as o } from "../Button/buttonVariants.js";
|
|
7
|
+
import "react";
|
|
7
8
|
function u({
|
|
8
9
|
className: n,
|
|
9
10
|
classNames: s,
|
|
10
|
-
showOutsideDays:
|
|
11
|
+
showOutsideDays: i = !0,
|
|
11
12
|
...d
|
|
12
13
|
}) {
|
|
13
14
|
return /* @__PURE__ */ r(
|
|
14
15
|
m,
|
|
15
16
|
{
|
|
16
|
-
showOutsideDays:
|
|
17
|
+
showOutsideDays: i,
|
|
17
18
|
className: e("p-3", n),
|
|
18
19
|
classNames: {
|
|
19
20
|
caption_dropdowns: "flex flex-col gap-1",
|
|
@@ -52,7 +53,7 @@ function u({
|
|
|
52
53
|
},
|
|
53
54
|
components: {
|
|
54
55
|
IconLeft: ({ className: a, ...t }) => /* @__PURE__ */ r(l, { className: e("h-4 w-4", a), ...t }),
|
|
55
|
-
IconRight: ({ className: a, ...t }) => /* @__PURE__ */ r(
|
|
56
|
+
IconRight: ({ className: a, ...t }) => /* @__PURE__ */ r(c, { className: e("h-4 w-4", a), ...t })
|
|
56
57
|
},
|
|
57
58
|
...d
|
|
58
59
|
}
|
package/Calendar/Calendar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sources":["../../src/Calendar/Calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport { DayPicker } from \"react-day-picker\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonVariants } from \"../Button\";\n\nexport type CalendarProps = React.ComponentProps<typeof DayPicker>\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: CalendarProps) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\"p-3\", className)}\n classNames={{\n caption_dropdowns:\"flex flex-col gap-1\",\n months: \"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0\",\n month: \"space-y-4\",\n caption: \"flex justify-center pt-1 relative items-center gap-4\",\n caption_label: \"text-sm font-medium hidden\",\n nav: \"space-x-1 flex items-center\",\n nav_button: cn(\n buttonVariants({ variant: \"outline-solid\" }),\n \"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100\"\n ),\n nav_button_previous: \"absolute left-1\",\n nav_button_next: \"absolute right-1\",\n table: \"w-full border-collapse space-y-1\",\n head_row: \"flex\",\n head_cell:\n \"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]\",\n row: \"flex w-full mt-2\",\n cell: cn(\n \"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md\",\n props.mode === \"range\"\n ? \"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md\"\n : \"[&:has([aria-selected])]:rounded-md\"\n ),\n day: cn(\n buttonVariants({ variant: \"ghost\" }),\n \"h-8 w-8 p-0 font-normal aria-selected:opacity-100\"\n ),\n day_range_start: \"day-range-start\",\n day_range_end: \"day-range-end\",\n day_selected:\n \"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground\",\n day_today: \"bg-accent text-accent-foreground\",\n day_outside:\n \"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground\",\n day_disabled: \"text-muted-foreground opacity-50\",\n day_range_middle:\n \"aria-selected:bg-accent aria-selected:text-accent-foreground\",\n day_hidden: \"invisible\",\n ...classNames,\n }}\n components={{\n IconLeft: ({ className, ...props }) => (\n <ChevronLeft className={cn(\"h-4 w-4\", className)} {...props} />\n ),\n IconRight: ({ className, ...props }) => (\n <ChevronRight className={cn(\"h-4 w-4\", className)} {...props} />\n ),\n }}\n {...props}\n />\n )\n}\nCalendar.displayName = \"Calendar\"\n\nexport { Calendar }\n"],"names":["Calendar","className","classNames","showOutsideDays","props","jsx","DayPicker","cn","buttonVariants","ChevronLeft","ChevronRight"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Calendar.js","sources":["../../src/Calendar/Calendar.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport { DayPicker } from \"react-day-picker\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonVariants } from \"../Button\";\n\nexport type CalendarProps = React.ComponentProps<typeof DayPicker>\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n ...props\n}: CalendarProps) {\n return (\n <DayPicker\n showOutsideDays={showOutsideDays}\n className={cn(\"p-3\", className)}\n classNames={{\n caption_dropdowns:\"flex flex-col gap-1\",\n months: \"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0\",\n month: \"space-y-4\",\n caption: \"flex justify-center pt-1 relative items-center gap-4\",\n caption_label: \"text-sm font-medium hidden\",\n nav: \"space-x-1 flex items-center\",\n nav_button: cn(\n buttonVariants({ variant: \"outline-solid\" }),\n \"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100\"\n ),\n nav_button_previous: \"absolute left-1\",\n nav_button_next: \"absolute right-1\",\n table: \"w-full border-collapse space-y-1\",\n head_row: \"flex\",\n head_cell:\n \"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]\",\n row: \"flex w-full mt-2\",\n cell: cn(\n \"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md\",\n props.mode === \"range\"\n ? \"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md\"\n : \"[&:has([aria-selected])]:rounded-md\"\n ),\n day: cn(\n buttonVariants({ variant: \"ghost\" }),\n \"h-8 w-8 p-0 font-normal aria-selected:opacity-100\"\n ),\n day_range_start: \"day-range-start\",\n day_range_end: \"day-range-end\",\n day_selected:\n \"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground\",\n day_today: \"bg-accent text-accent-foreground\",\n day_outside:\n \"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground\",\n day_disabled: \"text-muted-foreground opacity-50\",\n day_range_middle:\n \"aria-selected:bg-accent aria-selected:text-accent-foreground\",\n day_hidden: \"invisible\",\n ...classNames,\n }}\n components={{\n IconLeft: ({ className, ...props }) => (\n <ChevronLeft className={cn(\"h-4 w-4\", className)} {...props} />\n ),\n IconRight: ({ className, ...props }) => (\n <ChevronRight className={cn(\"h-4 w-4\", className)} {...props} />\n ),\n }}\n {...props}\n />\n )\n}\nCalendar.displayName = \"Calendar\"\n\nexport { Calendar }\n"],"names":["Calendar","className","classNames","showOutsideDays","props","jsx","DayPicker","cn","buttonVariants","ChevronLeft","ChevronRight"],"mappings":";;;;;;;AAWA,SAASA,EAAS;AAAA,EAChB,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,GAAkB;AAChB,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,iBAAAH;AAAA,MACA,WAAWI,EAAG,OAAON,CAAS;AAAA,MAC9B,YAAY;AAAA,QACV,mBAAkB;AAAA,QAClB,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,SAAS;AAAA,QACT,eAAe;AAAA,QACf,KAAK;AAAA,QACL,YAAYM;AAAA,UACVC,EAAe,EAAE,SAAS,iBAAiB;AAAA,UAC3C;AAAA,QAAA;AAAA,QAEF,qBAAqB;AAAA,QACrB,iBAAiB;AAAA,QACjB,OAAO;AAAA,QACP,UAAU;AAAA,QACV,WACE;AAAA,QACF,KAAK;AAAA,QACL,MAAMD;AAAA,UACJ;AAAA,UACAH,EAAM,SAAS,UACX,yKACA;AAAA,QAAA;AAAA,QAEN,KAAKG;AAAA,UACHC,EAAe,EAAE,SAAS,SAAS;AAAA,UACnC;AAAA,QAAA;AAAA,QAEF,iBAAiB;AAAA,QACjB,eAAe;AAAA,QACf,cACE;AAAA,QACF,WAAW;AAAA,QACX,aACE;AAAA,QACF,cAAc;AAAA,QACd,kBACE;AAAA,QACF,YAAY;AAAA,QACZ,GAAGN;AAAA,MAAA;AAAA,MAEL,YAAY;AAAA,QACV,UAAU,CAAC,EAAE,WAAAD,GAAW,GAAGG,EAAAA,MACzB,gBAAAC,EAACI,GAAA,EAAY,WAAWF,EAAG,WAAWN,CAAS,GAAI,GAAGG,GAAO;AAAA,QAE/D,WAAW,CAAC,EAAE,WAAAH,GAAW,GAAGG,EAAAA,MAC1B,gBAAAC,EAACK,GAAA,EAAa,WAAWH,EAAG,WAAWN,CAAS,GAAI,GAAGG,EAAAA,CAAO;AAAA,MAAA;AAAA,MAGjE,GAAGA;AAAA,IAAA;AAAA,EAAA;AAGV;AACAJ,EAAS,cAAc;"}
|
package/DataTable/DataTable.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsxs as i, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { Button as m } from "../Button/Button.js";
|
|
3
3
|
import "../Button/buttonVariants.js";
|
|
4
|
+
import "react";
|
|
4
5
|
import { DropdownMenu as h, DropdownMenuTrigger as p, DropdownMenuContent as g, DropdownMenuCheckboxItem as u } from "../DropdownMenu/DropdownMenu.js";
|
|
5
6
|
import { Table as C, TableHeader as f, TableRow as t, TableHead as w, TableBody as x, TableCell as o } from "../Table/Table.js";
|
|
6
7
|
import { flexRender as d } from "@tanstack/react-table";
|
|
7
8
|
import { ChevronDown as b } from "lucide-react";
|
|
8
|
-
const
|
|
9
|
-
table:
|
|
9
|
+
const y = ({
|
|
10
|
+
table: n,
|
|
10
11
|
ToolBar: a,
|
|
11
12
|
tColumns: s = "Columns",
|
|
12
13
|
tNoResults: c = "No results"
|
|
@@ -19,12 +20,12 @@ const k = ({
|
|
|
19
20
|
" ",
|
|
20
21
|
/* @__PURE__ */ l(b, { className: "ml-2 h-4 w-4" })
|
|
21
22
|
] }) }),
|
|
22
|
-
/* @__PURE__ */ l(g, { align: "end", children:
|
|
23
|
+
/* @__PURE__ */ l(g, { align: "end", children: n.getAllColumns().filter((e) => e.getCanHide()).map((e) => /* @__PURE__ */ l(
|
|
23
24
|
u,
|
|
24
25
|
{
|
|
25
26
|
className: "capitalize",
|
|
26
27
|
checked: e.getIsVisible(),
|
|
27
|
-
onCheckedChange: (
|
|
28
|
+
onCheckedChange: (r) => e.toggleVisibility(!!r),
|
|
28
29
|
children: e.id
|
|
29
30
|
},
|
|
30
31
|
e.id
|
|
@@ -32,24 +33,24 @@ const k = ({
|
|
|
32
33
|
] })
|
|
33
34
|
] }),
|
|
34
35
|
/* @__PURE__ */ l("div", { className: "rounded-md border", children: /* @__PURE__ */ i(C, { children: [
|
|
35
|
-
/* @__PURE__ */ l(f, { children:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
) },
|
|
39
|
-
/* @__PURE__ */ l(x, { children:
|
|
36
|
+
/* @__PURE__ */ l(f, { children: n.getHeaderGroups().map((e) => /* @__PURE__ */ l(t, { children: e.headers.map((r) => /* @__PURE__ */ l(w, { children: r.isPlaceholder ? null : d(
|
|
37
|
+
r.column.columnDef.header,
|
|
38
|
+
r.getContext()
|
|
39
|
+
) }, r.id)) }, e.id)) }),
|
|
40
|
+
/* @__PURE__ */ l(x, { children: n.getRowModel().rows?.length ? n.getRowModel().rows.map((e) => /* @__PURE__ */ l(
|
|
40
41
|
t,
|
|
41
42
|
{
|
|
42
43
|
"data-state": e.getIsSelected() && "selected",
|
|
43
|
-
children: e.getVisibleCells().map((
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
) },
|
|
44
|
+
children: e.getVisibleCells().map((r) => /* @__PURE__ */ l(o, { children: d(
|
|
45
|
+
r.column.columnDef.cell,
|
|
46
|
+
r.getContext()
|
|
47
|
+
) }, r.id))
|
|
47
48
|
},
|
|
48
49
|
e.id
|
|
49
50
|
)) : /* @__PURE__ */ l(t, { children: /* @__PURE__ */ l(
|
|
50
51
|
o,
|
|
51
52
|
{
|
|
52
|
-
colSpan:
|
|
53
|
+
colSpan: n.getAllColumns().length,
|
|
53
54
|
className: "h-24 text-center",
|
|
54
55
|
children: c
|
|
55
56
|
}
|
|
@@ -57,6 +58,6 @@ const k = ({
|
|
|
57
58
|
] }) })
|
|
58
59
|
] });
|
|
59
60
|
export {
|
|
60
|
-
|
|
61
|
+
y as DataTable
|
|
61
62
|
};
|
|
62
63
|
//# sourceMappingURL=DataTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.js","sources":["../../src/DataTable/DataTable.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../Button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '../DropdownMenu';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '../Table';\nimport { flexRender, type Table as ReactTable } from '@tanstack/react-table';\nimport { ChevronDown } from 'lucide-react';\nimport React, { FC } from 'react';\n\ninterface IProps {\n table: ReactTable<any>;\n ToolBar?: React.ReactNode;\n tColumns?: string;\n tNoResults?: string;\n}\n\nexport const DataTable: FC<IProps> = ({\n table,\n ToolBar,\n tColumns = 'Columns',\n tNoResults = 'No results',\n}) => {\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4\">\n {ToolBar}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n {tColumns} <ChevronDown className=\"ml-2 h-4 w-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"rounded-md border\">\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n return (\n <TableHead key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && 'selected'}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell key={cell.id}>\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n {tNoResults}\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </div>\n );\n};\n"],"names":["DataTable","table","ToolBar","tColumns","tNoResults","jsxs","DropdownMenu","jsx","DropdownMenuTrigger","Button","ChevronDown","DropdownMenuContent","column","DropdownMenuCheckboxItem","value","Table","TableHeader","headerGroup","TableRow","header","TableHead","flexRender","TableBody","row","cell","TableCell"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DataTable.js","sources":["../../src/DataTable/DataTable.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../Button';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuTrigger,\n} from '../DropdownMenu';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '../Table';\nimport { flexRender, type Table as ReactTable } from '@tanstack/react-table';\nimport { ChevronDown } from 'lucide-react';\nimport React, { FC } from 'react';\n\ninterface IProps {\n table: ReactTable<any>;\n ToolBar?: React.ReactNode;\n tColumns?: string;\n tNoResults?: string;\n}\n\nexport const DataTable: FC<IProps> = ({\n table,\n ToolBar,\n tColumns = 'Columns',\n tNoResults = 'No results',\n}) => {\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4\">\n {ToolBar}\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n {tColumns} <ChevronDown className=\"ml-2 h-4 w-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"rounded-md border\">\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n return (\n <TableHead key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </TableHead>\n );\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && 'selected'}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell key={cell.id}>\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={table.getAllColumns().length}\n className=\"h-24 text-center\"\n >\n {tNoResults}\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </div>\n );\n};\n"],"names":["DataTable","table","ToolBar","tColumns","tNoResults","jsxs","DropdownMenu","jsx","DropdownMenuTrigger","Button","ChevronDown","DropdownMenuContent","column","DropdownMenuCheckboxItem","value","Table","TableHeader","headerGroup","TableRow","header","TableHead","flexRender","TableBody","row","cell","TableCell"],"mappings":";;;;;;;;AA4BO,MAAMA,IAAwB,CAAC;AAAA,EACpC,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,YAAAC,IAAa;AACf,MAEI,gBAAAC,EAAC,OAAA,EAAI,WAAU,UACb,UAAA;AAAA,EAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,0BACZ,UAAA;AAAA,IAAAH;AAAA,sBACAI,GAAA,EACC,UAAA;AAAA,MAAA,gBAAAC,EAACC,GAAA,EAAoB,SAAO,IAC1B,UAAA,gBAAAH,EAACI,KAAO,SAAQ,WAAU,WAAU,WACjC,UAAA;AAAA,QAAAN;AAAA,QAAS;AAAA,QAAC,gBAAAI,EAACG,GAAA,EAAY,WAAU,eAAA,CAAe;AAAA,MAAA,EAAA,CACnD,EAAA,CACF;AAAA,wBACCC,GAAA,EAAoB,OAAM,OACxB,UAAAV,EACE,gBACA,OAAO,CAACW,MAAWA,EAAO,WAAA,CAAY,EACtC,IAAI,CAACA,MAEF,gBAAAL;AAAA,QAACM;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,SAASD,EAAO,aAAA;AAAA,UAChB,iBAAiB,CAACE,MAChBF,EAAO,iBAAiB,CAAC,CAACE,CAAK;AAAA,UAGhC,UA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|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Input as
|
|
4
|
-
import { useDebounceCallback as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { SearchIcon as
|
|
7
|
-
import { LoadedIcon as
|
|
8
|
-
const
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useRef as C, useEffect as k, useCallback as b } from "react";
|
|
3
|
+
import { Input as v } from "../Input/Input.js";
|
|
4
|
+
import { useDebounceCallback as x, useEventListener as D } from "@oneplatformdev/hooks";
|
|
5
|
+
import { cn as I } from "@oneplatformdev/utils";
|
|
6
|
+
import { SearchIcon as K } from "lucide-react";
|
|
7
|
+
import { LoadedIcon as L } from "../LoadedIcon/LoadedIcon.js";
|
|
8
|
+
const z = (s) => {
|
|
9
9
|
const {
|
|
10
10
|
search: o,
|
|
11
11
|
onChange: c,
|
|
12
|
-
onSearch:
|
|
13
|
-
placeholder:
|
|
14
|
-
className:
|
|
15
|
-
loading:
|
|
16
|
-
slotProps:
|
|
12
|
+
onSearch: l,
|
|
13
|
+
placeholder: i = "Search",
|
|
14
|
+
className: u,
|
|
15
|
+
loading: m = !1,
|
|
16
|
+
slotProps: r,
|
|
17
17
|
name: f = "search",
|
|
18
18
|
...p
|
|
19
|
-
} = s, [d,
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
} = s, [d, n] = y(o), h = x(l, 1e3), a = C(null), w = (e) => {
|
|
20
|
+
const g = e.target.value;
|
|
21
|
+
n(g), c?.(e), h(e.target.value);
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [o])
|
|
23
|
+
k(() => {
|
|
24
|
+
n(o ?? "");
|
|
25
|
+
}, [o]);
|
|
26
|
+
const S = b((e) => {
|
|
27
|
+
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), a.current?.focus());
|
|
28
|
+
}, []);
|
|
29
|
+
return D(
|
|
26
30
|
"keydown",
|
|
27
|
-
|
|
28
|
-
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), a.current?.focus());
|
|
29
|
-
},
|
|
31
|
+
S,
|
|
30
32
|
typeof window < "u" ? window : void 0
|
|
31
|
-
), /* @__PURE__ */
|
|
32
|
-
|
|
33
|
+
), /* @__PURE__ */ t(
|
|
34
|
+
v,
|
|
33
35
|
{
|
|
34
36
|
ref: a,
|
|
35
37
|
name: f,
|
|
36
|
-
placeholder:
|
|
38
|
+
placeholder: i,
|
|
37
39
|
value: d,
|
|
38
|
-
className:
|
|
40
|
+
className: I("min-w-[340px]", u),
|
|
39
41
|
onChange: w,
|
|
40
42
|
...p,
|
|
41
|
-
...
|
|
43
|
+
...r || {},
|
|
42
44
|
slotProps: {
|
|
43
|
-
...
|
|
45
|
+
...r || {},
|
|
44
46
|
input: {
|
|
45
|
-
startAdornment: /* @__PURE__ */
|
|
46
|
-
...
|
|
47
|
+
startAdornment: /* @__PURE__ */ t(L, { loading: m, children: /* @__PURE__ */ t(K, {}) }),
|
|
48
|
+
...r?.input || {}
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
);
|
|
51
53
|
};
|
|
52
54
|
export {
|
|
53
|
-
|
|
55
|
+
z as Search
|
|
54
56
|
};
|
|
55
57
|
//# sourceMappingURL=Search.js.map
|
package/Search/Search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../src/Search/Search.tsx"],"sourcesContent":["'use client';\n\nimport { ChangeEvent, useEffect, useState, KeyboardEvent, useRef } from 'react';\n\nimport { Input } from '../Input';\nimport { SearchProps } from './Search.types';\n\nimport { useDebounceCallback, useEventListener } from '@oneplatformdev/hooks';\nimport { cn } from '@oneplatformdev/utils';\nimport { SearchIcon } from 'lucide-react';\nimport { LoadedIcon } from '../LoadedIcon';\n\nexport const Search = (props: SearchProps) => {\n const {\n search: initialSearch,\n onChange: handleChange,\n onSearch,\n placeholder = 'Search',\n className,\n loading = false,\n slotProps,\n name = 'search',\n ...rest\n } = props;\n const [ search, setSearch ] = useState(initialSearch);\n const debounced = useDebounceCallback(onSearch, 1000);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n setSearch(v);\n handleChange?.(e);\n debounced(e.target.value);\n };\n\n useEffect(() => {\n setSearch(initialSearch ?? '');\n }, [ initialSearch ]);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {\n event.preventDefault();\n inputRef.current?.focus();\n }\n };\n\n useEventListener(\n 'keydown',\n handleKeyDown,\n typeof window !== 'undefined' ? window : undefined\n );\n\n return (\n <Input\n ref={inputRef}\n name={name}\n placeholder={placeholder}\n value={search}\n className={cn('min-w-[340px]', className)}\n onChange={onChange}\n {...rest}\n {...(slotProps || {})}\n slotProps={{\n ...(slotProps || {}),\n input: {\n startAdornment: (\n <LoadedIcon loading={loading}>\n <SearchIcon/>\n </LoadedIcon>\n ),\n ...(slotProps?.input || {}),\n },\n }}\n />\n );\n};\n"],"names":["Search","props","initialSearch","handleChange","onSearch","placeholder","className","loading","slotProps","name","rest","search","setSearch","useState","debounced","useDebounceCallback","inputRef","useRef","onChange","v","useEffect","
|
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../src/Search/Search.tsx"],"sourcesContent":["'use client';\n\nimport { ChangeEvent, useEffect, useState, KeyboardEvent, useRef, useCallback } from 'react';\n\nimport { Input } from '../Input';\nimport { SearchProps } from './Search.types';\n\nimport { useDebounceCallback, useEventListener } from '@oneplatformdev/hooks';\nimport { cn } from '@oneplatformdev/utils';\nimport { SearchIcon } from 'lucide-react';\nimport { LoadedIcon } from '../LoadedIcon';\n\nexport const Search = (props: SearchProps) => {\n const {\n search: initialSearch,\n onChange: handleChange,\n onSearch,\n placeholder = 'Search',\n className,\n loading = false,\n slotProps,\n name = 'search',\n ...rest\n } = props;\n const [ search, setSearch ] = useState(initialSearch);\n const debounced = useDebounceCallback(onSearch, 1000);\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n setSearch(v);\n handleChange?.(e);\n debounced(e.target.value);\n };\n\n useEffect(() => {\n setSearch(initialSearch ?? '');\n }, [ initialSearch ]);\n\n const handleKeyDown = useCallback((event: KeyboardEvent<HTMLInputElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k') {\n event.preventDefault();\n inputRef.current?.focus();\n }\n }, []);\n\n useEventListener(\n 'keydown',\n handleKeyDown,\n typeof window !== 'undefined' ? window : undefined\n );\n\n return (\n <Input\n ref={inputRef}\n name={name}\n placeholder={placeholder}\n value={search}\n className={cn('min-w-[340px]', className)}\n onChange={onChange}\n {...rest}\n {...(slotProps || {})}\n slotProps={{\n ...(slotProps || {}),\n input: {\n startAdornment: (\n <LoadedIcon loading={loading}>\n <SearchIcon/>\n </LoadedIcon>\n ),\n ...(slotProps?.input || {}),\n },\n }}\n />\n );\n};\n"],"names":["Search","props","initialSearch","handleChange","onSearch","placeholder","className","loading","slotProps","name","rest","search","setSearch","useState","debounced","useDebounceCallback","inputRef","useRef","onChange","v","useEffect","handleKeyDown","useCallback","event","useEventListener","jsx","Input","cn","LoadedIcon","SearchIcon"],"mappings":";;;;;;;AAYO,MAAMA,IAAS,CAACC,MAAuB;AAC5C,QAAM;AAAA,IACJ,QAAQC;AAAA,IACR,UAAUC;AAAA,IACV,UAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,WAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EAAA,IACDT,GACE,CAAEU,GAAQC,CAAU,IAAIC,EAASX,CAAa,GAC9CY,IAAYC,EAAoBX,GAAU,GAAI,GAE9CY,IAAWC,EAAyB,IAAI,GAExCC,IAAW,CAAC,MAAqC;AACrD,UAAMC,IAAI,EAAE,OAAO;AACnB,IAAAP,EAAUO,CAAC,GACXhB,IAAe,CAAC,GAChBW,EAAU,EAAE,OAAO,KAAK;AAAA,EAC1B;AAEA,EAAAM,EAAU,MAAM;AACd,IAAAR,EAAUV,KAAiB,EAAE;AAAA,EAC/B,GAAG,CAAEA,CAAc,CAAC;AAEpB,QAAMmB,IAAgBC,EAAY,CAACC,MAA2C;AAC5E,KAAKA,EAAM,WAAWA,EAAM,YAAYA,EAAM,IAAI,YAAA,MAAkB,QAClEA,EAAM,eAAA,GACNP,EAAS,SAAS,MAAA;AAAA,EAEtB,GAAG,CAAA,CAAE;AAEL,SAAAQ;AAAA,IACE;AAAA,IACAH;AAAA,IACA,OAAO,SAAW,MAAc,SAAS;AAAA,EAAA,GAIzC,gBAAAI;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAKV;AAAA,MACL,MAAAP;AAAA,MACA,aAAAJ;AAAA,MACA,OAAOM;AAAA,MACP,WAAWgB,EAAG,iBAAiBrB,CAAS;AAAA,MACxC,UAAAY;AAAA,MACC,GAAGR;AAAA,MACH,GAAIF,KAAa,CAAA;AAAA,MAClB,WAAW;AAAA,QACT,GAAIA,KAAa,CAAA;AAAA,QACjB,OAAO;AAAA,UACL,gBACE,gBAAAiB,EAACG,GAAA,EAAW,SAAArB,GACV,UAAA,gBAAAkB,EAACI,KAAU,GACb;AAAA,UAEF,GAAIrB,GAAW,SAAS,CAAA;AAAA,QAAC;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { jsxs as i, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { Button as o } from "../Button/Button.js";
|
|
3
3
|
import "../Button/buttonVariants.js";
|
|
4
|
+
import "react";
|
|
4
5
|
import "@radix-ui/react-select";
|
|
5
6
|
import "lucide-react";
|
|
6
7
|
import "@oneplatformdev/utils";
|
|
7
8
|
import { Select as P } from "../Select/Select.js";
|
|
8
|
-
const
|
|
9
|
+
const M = ({
|
|
9
10
|
offset: l,
|
|
10
11
|
limit: a,
|
|
11
|
-
totalRows:
|
|
12
|
+
totalRows: t,
|
|
12
13
|
setLimit: p,
|
|
13
|
-
setOffset:
|
|
14
|
+
setOffset: s,
|
|
14
15
|
tRowsPerPage: m = "Rows per page",
|
|
15
16
|
tPrevious: d = "Previous",
|
|
16
17
|
tPage: u = "Page",
|
|
17
18
|
tNext: x = "Next",
|
|
18
19
|
tOf: v = "Of"
|
|
19
20
|
}) => {
|
|
20
|
-
const r = Math.ceil(l / a) + 1, c = Math.ceil(
|
|
21
|
-
|
|
21
|
+
const r = Math.ceil(l / a) + 1, c = Math.ceil(t / a), h = r === c, b = (e) => {
|
|
22
|
+
s(0), p(parseInt(e));
|
|
22
23
|
}, g = () => {
|
|
23
24
|
let e = l - a;
|
|
24
|
-
e < 0 && (e = 0),
|
|
25
|
+
e < 0 && (e = 0), s(e);
|
|
25
26
|
}, N = () => {
|
|
26
27
|
let e = l + a;
|
|
27
|
-
e >
|
|
28
|
+
e > t && (e = t - a), s(e);
|
|
28
29
|
};
|
|
29
30
|
return /* @__PURE__ */ i("div", { className: "flex items-center justify-end space-x-2 py-4", children: [
|
|
30
31
|
/* @__PURE__ */ i("div", { className: "flex items-center space-x-2", children: [
|
|
@@ -72,6 +73,6 @@ const L = ({
|
|
|
72
73
|
] });
|
|
73
74
|
};
|
|
74
75
|
export {
|
|
75
|
-
|
|
76
|
+
M as TablePagination
|
|
76
77
|
};
|
|
77
78
|
//# sourceMappingURL=TablePagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.js","sources":["../../src/TablePagination/TablePagination.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../Button';\nimport { Select } from '../Select';\nimport { FC } from 'react';\n\ninterface IProps {\n limit: number;\n offset: number;\n totalRows: number;\n setLimit: (limit: number) => void;\n setOffset: (offset: number) => void;\n tRowsPerPage?: string;\n tPrevious?: string;\n tPage?:string;\n tNext?:string;\n tOf?:string\n}\n\nexport const TablePagination: FC<IProps> = ({\n offset,\n limit,\n totalRows,\n setLimit,\n setOffset,\n tRowsPerPage= \"Rows per page\",\n tPrevious= \"Previous\",\n tPage= \"Page\",\n tNext= \"Next\",\n tOf= \"Of\",\n}) => {\n const currentPage = Math.ceil(offset / limit) + 1;\n const totalPages = Math.ceil(totalRows / limit);\n const isLastPage = currentPage === totalPages;\n\n const onChangeLimit = (value: string) => {\n setOffset(0);\n setLimit(parseInt(value));\n };\n\n const onPrevious = () => {\n let nextOffset = offset - limit;\n if (nextOffset < 0) {\n nextOffset = 0;\n }\n setOffset(nextOffset);\n };\n\n const onNext = () => {\n let nextOffset = offset + limit;\n if (nextOffset > totalRows) {\n nextOffset = totalRows - limit;\n }\n setOffset(nextOffset);\n };\n\n return (\n <div className=\"flex items-center justify-end space-x-2 py-4\">\n <div className=\"flex items-center space-x-2\">\n <span className=\"text-sm text-nowrap\">{tRowsPerPage}</span>\n <Select\n value={limit?.toString()}\n options={[\n { value: '5', label: '5' },\n { value: '10', label: '10' },\n { value: '20', label: '20' },\n { value: '30', label: '30' },\n { value: '50', label: '50' },\n ]}\n onChange={onChangeLimit}\n placeholder=\"6\"\n nullable={false}\n />\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={!offset}\n onClick={onPrevious}\n >\n {tPrevious}\n </Button>\n <span className=\"text-sm\">{`${tPage} ${currentPage} ${tOf} ${totalPages}`}</span>\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={isLastPage}\n onClick={onNext}\n >\n {tNext}\n </Button>\n </div>\n </div>\n );\n};\n"],"names":["TablePagination","offset","limit","totalRows","setLimit","setOffset","tRowsPerPage","tPrevious","tPage","tNext","tOf","currentPage","totalPages","isLastPage","onChangeLimit","value","onPrevious","nextOffset","onNext","jsxs","jsx","Select","Button"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TablePagination.js","sources":["../../src/TablePagination/TablePagination.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '../Button';\nimport { Select } from '../Select';\nimport { FC } from 'react';\n\ninterface IProps {\n limit: number;\n offset: number;\n totalRows: number;\n setLimit: (limit: number) => void;\n setOffset: (offset: number) => void;\n tRowsPerPage?: string;\n tPrevious?: string;\n tPage?:string;\n tNext?:string;\n tOf?:string\n}\n\nexport const TablePagination: FC<IProps> = ({\n offset,\n limit,\n totalRows,\n setLimit,\n setOffset,\n tRowsPerPage= \"Rows per page\",\n tPrevious= \"Previous\",\n tPage= \"Page\",\n tNext= \"Next\",\n tOf= \"Of\",\n}) => {\n const currentPage = Math.ceil(offset / limit) + 1;\n const totalPages = Math.ceil(totalRows / limit);\n const isLastPage = currentPage === totalPages;\n\n const onChangeLimit = (value: string) => {\n setOffset(0);\n setLimit(parseInt(value));\n };\n\n const onPrevious = () => {\n let nextOffset = offset - limit;\n if (nextOffset < 0) {\n nextOffset = 0;\n }\n setOffset(nextOffset);\n };\n\n const onNext = () => {\n let nextOffset = offset + limit;\n if (nextOffset > totalRows) {\n nextOffset = totalRows - limit;\n }\n setOffset(nextOffset);\n };\n\n return (\n <div className=\"flex items-center justify-end space-x-2 py-4\">\n <div className=\"flex items-center space-x-2\">\n <span className=\"text-sm text-nowrap\">{tRowsPerPage}</span>\n <Select\n value={limit?.toString()}\n options={[\n { value: '5', label: '5' },\n { value: '10', label: '10' },\n { value: '20', label: '20' },\n { value: '30', label: '30' },\n { value: '50', label: '50' },\n ]}\n onChange={onChangeLimit}\n placeholder=\"6\"\n nullable={false}\n />\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={!offset}\n onClick={onPrevious}\n >\n {tPrevious}\n </Button>\n <span className=\"text-sm\">{`${tPage} ${currentPage} ${tOf} ${totalPages}`}</span>\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled={isLastPage}\n onClick={onNext}\n >\n {tNext}\n </Button>\n </div>\n </div>\n );\n};\n"],"names":["TablePagination","offset","limit","totalRows","setLimit","setOffset","tRowsPerPage","tPrevious","tPage","tNext","tOf","currentPage","totalPages","isLastPage","onChangeLimit","value","onPrevious","nextOffset","onNext","jsxs","jsx","Select","Button"],"mappings":";;;;;;;;AAmBO,MAAMA,IAA8B,CAAC;AAAA,EAC1C,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC,IAAc;AAAA,EACd,WAAAC,IAAW;AAAA,EACX,OAAAC,IAAO;AAAA,EACP,OAAAC,IAAO;AAAA,EACP,KAAAC,IAAK;AACP,MAAM;AACJ,QAAMC,IAAc,KAAK,KAAKV,IAASC,CAAK,IAAI,GAC1CU,IAAa,KAAK,KAAKT,IAAYD,CAAK,GACxCW,IAAaF,MAAgBC,GAE7BE,IAAgB,CAACC,MAAkB;AACvC,IAAAV,EAAU,CAAC,GACXD,EAAS,SAASW,CAAK,CAAC;AAAA,EAC1B,GAEMC,IAAa,MAAM;AACvB,QAAIC,IAAahB,IAASC;AAC1B,IAAIe,IAAa,MACfA,IAAa,IAEfZ,EAAUY,CAAU;AAAA,EACtB,GAEMC,IAAS,MAAM;AACnB,QAAID,IAAahB,IAASC;AAC1B,IAAIe,IAAad,MACfc,IAAad,IAAYD,IAE3BG,EAAUY,CAAU;AAAA,EACtB;AAEA,SACE,gBAAAE,EAAC,OAAA,EAAI,WAAU,gDACb,UAAA;AAAA,IAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,+BACb,UAAA;AAAA,MAAA,gBAAAC,EAAC,QAAA,EAAK,WAAU,uBAAuB,UAAAd,GAAa;AAAA,MACpD,gBAAAc;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,OAAOnB,GAAO,SAAA;AAAA,UACd,SAAS;AAAA,YACP,EAAE,OAAO,KAAK,OAAO,IAAA;AAAA,YACrB,EAAE,OAAO,MAAM,OAAO,KAAA;AAA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