@jakubmazanec/ui 0.4.2 → 0.5.0-unstable.409a84de
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/build/components/Button.js +8 -5
- package/build/components/Button.js.map +2 -2
- package/build/components/Checkbox.js +2 -2
- package/build/components/Checkbox.js.map +1 -1
- package/build/components/Icon.js +1 -1
- package/build/components/Icon.js.map +1 -1
- package/build/components/Spinner.js +1 -1
- package/build/components/Spinner.js.map +1 -1
- package/build/components/data-table/DataTable.js +90 -115
- package/build/components/data-table/DataTable.js.map +2 -2
- package/build/components/data-table/internals/DataTableFilter.d.ts +12 -0
- package/build/components/data-table/internals/DataTableFilter.js +275 -0
- package/build/components/data-table/internals/DataTableFilter.js.map +7 -0
- package/build/components/data-table/internals/DataTableFilters.d.ts +11 -0
- package/build/components/data-table/internals/DataTableFilters.js +39 -0
- package/build/components/data-table/internals/DataTableFilters.js.map +7 -0
- package/build/components/data-table/internals/DataTableHeader.d.ts +2 -11
- package/build/components/data-table/internals/DataTableHeader.js +18 -112
- package/build/components/data-table/internals/DataTableHeader.js.map +2 -2
- package/build/components/data-table/internals/DataTableMenu.d.ts +11 -0
- package/build/components/data-table/internals/DataTableMenu.js +35 -0
- package/build/components/data-table/internals/DataTableMenu.js.map +7 -0
- package/build/components/data-table/internals/DataTableSetting.d.ts +10 -0
- package/build/components/data-table/internals/DataTableSetting.js +111 -0
- package/build/components/data-table/internals/DataTableSetting.js.map +7 -0
- package/build/components/data-table/internals/DataTableSettings.d.ts +9 -0
- package/build/components/data-table/internals/DataTableSettings.js +71 -0
- package/build/components/data-table/internals/DataTableSettings.js.map +7 -0
- package/build/components/data-table/internals.d.ts +5 -0
- package/build/components/data-table/internals.js +5 -0
- package/build/components/data-table/internals.js.map +2 -2
- package/build/development/createTailwindConfig.d.ts +78 -0
- package/build/development/createTailwindConfig.js +3 -47
- package/build/development/createTailwindConfig.js.map +2 -2
- package/build/development/internals/createTailwindThemeColors.d.ts +2 -0
- package/build/development/internals/createTailwindThemeColors.js +51 -0
- package/build/development/internals/createTailwindThemeColors.js.map +7 -0
- package/build/development/internals.d.ts +1 -0
- package/build/development/internals.js +1 -0
- package/build/development/internals.js.map +2 -2
- package/package.json +1 -1
- package/source/components/Button.tsx +12 -5
- package/source/components/Checkbox.tsx +2 -2
- package/source/components/Icon.tsx +1 -1
- package/source/components/Spinner.tsx +1 -1
- package/source/components/data-table/DataTable.tsx +108 -135
- package/source/components/data-table/internals/DataTableFilter.tsx +354 -0
- package/source/components/data-table/internals/DataTableFilters.tsx +55 -0
- package/source/components/data-table/internals/DataTableHeader.tsx +7 -145
- package/source/components/data-table/internals/DataTableMenu.tsx +62 -0
- package/source/components/data-table/internals/DataTableSetting.tsx +142 -0
- package/source/components/data-table/internals/DataTableSettings.tsx +91 -0
- package/source/components/data-table/internals.ts +5 -0
- package/source/development/createTailwindConfig.ts +4 -48
- package/source/development/internals/createTailwindThemeColors.ts +53 -0
- package/source/development/internals.ts +1 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Table } from '@tanstack/react-table';
|
|
2
|
+
import { type DataTableProps } from '../DataTable.js';
|
|
3
|
+
export type DataTableMenuProps = {
|
|
4
|
+
table: Table<any>;
|
|
5
|
+
hideFilters: DataTableProps<any, any>['hideFilters'];
|
|
6
|
+
hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];
|
|
7
|
+
hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];
|
|
8
|
+
hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];
|
|
9
|
+
toggleFilters: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function DataTableMenu({ table, hideFilters, hideColumnVisibility, hideColumnOrder, hideColumnPinning, toggleFilters, }: DataTableMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "../../Button.js";
|
|
4
|
+
import { Container } from "../../Container.js";
|
|
5
|
+
import { Icon } from "../../Icon.js";
|
|
6
|
+
import { Popover } from "../../Popover.js";
|
|
7
|
+
import { PopoverButton } from "../../PopoverButton.js";
|
|
8
|
+
import { PopoverPanel } from "../../PopoverPanel.js";
|
|
9
|
+
import { DataTableSettings } from "./DataTableSettings.js";
|
|
10
|
+
export function DataTableMenu({
|
|
11
|
+
table,
|
|
12
|
+
hideFilters = false,
|
|
13
|
+
hideColumnVisibility = false,
|
|
14
|
+
hideColumnOrder = false,
|
|
15
|
+
hideColumnPinning = false,
|
|
16
|
+
// TODO: this probablu should be passed via some context
|
|
17
|
+
toggleFilters
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ jsxs(Container, { justify: "spaced", spacing: "small", children: [
|
|
20
|
+
hideFilters ? null : /* @__PURE__ */ jsx(Button, { "aria-label": "Filter", variant: "outline", onClick: toggleFilters, children: /* @__PURE__ */ jsx(Icon, { name: "Funnel", size: "large" }) }),
|
|
21
|
+
/* @__PURE__ */ jsxs(Popover, { className: "ml-auto", children: [
|
|
22
|
+
/* @__PURE__ */ jsx(PopoverButton, { children: /* @__PURE__ */ jsx(Button, { "aria-label": "Settings", variant: "outline", children: /* @__PURE__ */ jsx(Icon, { name: "Cog6Tooth", size: "large" }) }) }),
|
|
23
|
+
/* @__PURE__ */ jsx(PopoverPanel, { anchor: "bottom end", children: /* @__PURE__ */ jsx(
|
|
24
|
+
DataTableSettings,
|
|
25
|
+
{
|
|
26
|
+
hideColumnOrder,
|
|
27
|
+
hideColumnPinning,
|
|
28
|
+
hideColumnVisibility,
|
|
29
|
+
table
|
|
30
|
+
}
|
|
31
|
+
) })
|
|
32
|
+
] })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DataTableMenu.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../source/components/data-table/internals/DataTableMenu.tsx"],
|
|
4
|
+
"sourcesContent": ["import {type Table} from '@tanstack/react-table';\n\nimport {Button} from '../../Button.js';\nimport {Container} from '../../Container.js';\nimport {Icon} from '../../Icon.js';\nimport {Popover} from '../../Popover.js';\nimport {PopoverButton} from '../../PopoverButton.js';\nimport {PopoverPanel} from '../../PopoverPanel.js';\nimport {type DataTableProps} from '../DataTable.js';\nimport {DataTableSettings} from './DataTableSettings.js';\n\nexport type DataTableMenuProps = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n table: Table<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideFilters: DataTableProps<any, any>['hideFilters'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];\n\n // TODO: this probablu should be passed via some context\n toggleFilters: () => void;\n};\n\nexport function DataTableMenu({\n table,\n hideFilters = false,\n hideColumnVisibility = false,\n hideColumnOrder = false,\n hideColumnPinning = false,\n\n // TODO: this probablu should be passed via some context\n toggleFilters,\n}: DataTableMenuProps) {\n return (\n <Container justify=\"spaced\" spacing=\"small\">\n {hideFilters ? null : (\n <Button aria-label=\"Filter\" variant=\"outline\" onClick={toggleFilters}>\n <Icon name=\"Funnel\" size=\"large\" />\n </Button>\n )}\n <Popover className=\"ml-auto\">\n <PopoverButton>\n <Button aria-label=\"Settings\" variant=\"outline\">\n <Icon name=\"Cog6Tooth\" size=\"large\" />\n </Button>\n </PopoverButton>\n <PopoverPanel anchor=\"bottom end\">\n <DataTableSettings\n hideColumnOrder={hideColumnOrder}\n hideColumnPinning={hideColumnPinning}\n hideColumnVisibility={hideColumnVisibility}\n table={table}\n />\n </PopoverPanel>\n </Popover>\n </Container>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAyCU,cAGJ,YAHI;AAvCV,SAAQ,cAAa;AACrB,SAAQ,iBAAgB;AACxB,SAAQ,YAAW;AACnB,SAAQ,eAAc;AACtB,SAAQ,qBAAoB;AAC5B,SAAQ,oBAAmB;AAE3B,SAAQ,yBAAwB;AAkBzB,gBAAS,cAAc;AAAA,EAC5B;AAAA,EACA,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA;AAAA,EAGpB;AACF,GAAuB;AACrB,SACE,qBAAC,aAAU,SAAQ,UAAS,SAAQ,SACjC;AAAA,kBAAc,OACb,oBAAC,UAAO,cAAW,UAAS,SAAQ,WAAU,SAAS,eACrD,8BAAC,QAAK,MAAK,UAAS,MAAK,SAAQ,GACnC;AAAA,IAEF,qBAAC,WAAQ,WAAU,WACjB;AAAA,0BAAC,iBACC,8BAAC,UAAO,cAAW,YAAW,SAAQ,WACpC,8BAAC,QAAK,MAAK,aAAY,MAAK,SAAQ,GACtC,GACF;AAAA,MACA,oBAAC,gBAAa,QAAO,cACnB;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACF,GACF;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Column, type Table } from '@tanstack/react-table';
|
|
2
|
+
import { type DataTableProps } from '../DataTable.js';
|
|
3
|
+
export type DataTableSettingProps = {
|
|
4
|
+
table: Table<any>;
|
|
5
|
+
column: Column<any>;
|
|
6
|
+
hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];
|
|
7
|
+
hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];
|
|
8
|
+
hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];
|
|
9
|
+
};
|
|
10
|
+
export declare function DataTableSetting({ table, column, hideColumnVisibility, hideColumnOrder, hideColumnPinning, }: DataTableSettingProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
4
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
5
|
+
import { flexRender } from "@tanstack/react-table";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import { Button } from "../../Button.js";
|
|
8
|
+
import { Checkbox } from "../../Checkbox.js";
|
|
9
|
+
import { CheckboxField } from "../../CheckboxField.js";
|
|
10
|
+
import { Container } from "../../Container.js";
|
|
11
|
+
import { Icon } from "../../Icon.js";
|
|
12
|
+
import { Label } from "../../Label.js";
|
|
13
|
+
export function DataTableSetting({
|
|
14
|
+
table,
|
|
15
|
+
// header,
|
|
16
|
+
column,
|
|
17
|
+
hideColumnVisibility = false,
|
|
18
|
+
hideColumnOrder = false,
|
|
19
|
+
hideColumnPinning = false
|
|
20
|
+
}) {
|
|
21
|
+
let { attributes, isDragging, listeners, setNodeRef, transform, setActivatorNodeRef } = useSortable(
|
|
22
|
+
{
|
|
23
|
+
id: column.id
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
let handleChange = useCallback(
|
|
27
|
+
(checked) => {
|
|
28
|
+
if (!checked && table.getFlatHeaders().length >= 2) {
|
|
29
|
+
column.toggleVisibility(checked);
|
|
30
|
+
} else if (checked) {
|
|
31
|
+
column.toggleVisibility(checked);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[column, table]
|
|
35
|
+
);
|
|
36
|
+
let handlePinLeftClick = useCallback(() => {
|
|
37
|
+
column.pin("left");
|
|
38
|
+
}, [column]);
|
|
39
|
+
let handlePinRightClick = useCallback(() => {
|
|
40
|
+
column.pin("right");
|
|
41
|
+
}, [column]);
|
|
42
|
+
let handleUnpinClick = useCallback(() => {
|
|
43
|
+
column.pin(false);
|
|
44
|
+
}, [column]);
|
|
45
|
+
let resolvedHideColumnPinning = hideColumnPinning || !column.getCanPin();
|
|
46
|
+
return /* @__PURE__ */ jsxs(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
ref: setNodeRef,
|
|
50
|
+
style: {
|
|
51
|
+
transform: CSS.Translate.toString(transform),
|
|
52
|
+
transition: "width transform 0.2s ease-in-out",
|
|
53
|
+
zIndex: isDragging ? 20 : void 0
|
|
54
|
+
},
|
|
55
|
+
className: "flex items-center gap-4",
|
|
56
|
+
children: [
|
|
57
|
+
hideColumnOrder ? null : /* @__PURE__ */ jsx(
|
|
58
|
+
Button,
|
|
59
|
+
{
|
|
60
|
+
ref: setActivatorNodeRef,
|
|
61
|
+
"aria-label": "Resize",
|
|
62
|
+
className: "cursor-move",
|
|
63
|
+
size: "small",
|
|
64
|
+
variant: "invisible",
|
|
65
|
+
...attributes,
|
|
66
|
+
...listeners,
|
|
67
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "Bars4", size: "small" })
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
hideColumnVisibility ? /* @__PURE__ */ jsx("span", { className: "mr-auto font-sans text-sm font-medium", children: flexRender(column.columnDef.header, {
|
|
71
|
+
table,
|
|
72
|
+
column,
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions -- needed
|
|
74
|
+
header: { column }
|
|
75
|
+
}) }) : /* @__PURE__ */ jsxs(CheckboxField, { className: "mr-auto", children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Checkbox, { checked: column.getIsVisible(), onChange: handleChange }),
|
|
77
|
+
/* @__PURE__ */ jsx(Label, { className: "flex", children: flexRender(column.columnDef.header, {
|
|
78
|
+
table,
|
|
79
|
+
column,
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions -- needed
|
|
81
|
+
header: { column }
|
|
82
|
+
}) })
|
|
83
|
+
] }),
|
|
84
|
+
resolvedHideColumnPinning ? null : /* @__PURE__ */ jsxs(Container, { spacing: "extra-small", children: [
|
|
85
|
+
column.getIsPinned() === "left" ? null : /* @__PURE__ */ jsx(
|
|
86
|
+
Button,
|
|
87
|
+
{
|
|
88
|
+
"aria-label": "Pin to left",
|
|
89
|
+
size: "small",
|
|
90
|
+
variant: "outline",
|
|
91
|
+
onClick: handlePinLeftClick,
|
|
92
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "ArrowLeftEndOnRectangle", size: "small" })
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
column.getIsPinned() ? /* @__PURE__ */ jsx(Button, { "aria-label": "Unpin", size: "small", variant: "outline", onClick: handleUnpinClick, children: /* @__PURE__ */ jsx(Icon, { name: "XMark", size: "small" }) }) : null,
|
|
96
|
+
column.getIsPinned() === "right" ? null : /* @__PURE__ */ jsx(
|
|
97
|
+
Button,
|
|
98
|
+
{
|
|
99
|
+
"aria-label": "Pin to right",
|
|
100
|
+
size: "small",
|
|
101
|
+
variant: "outline",
|
|
102
|
+
onClick: handlePinRightClick,
|
|
103
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "ArrowRightEndOnRectangle", size: "small" })
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=DataTableSetting.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../source/components/data-table/internals/DataTableSetting.tsx"],
|
|
4
|
+
"sourcesContent": ["import {useSortable} from '@dnd-kit/sortable';\nimport {CSS} from '@dnd-kit/utilities';\nimport {type Column, flexRender, type Header, type Table} from '@tanstack/react-table';\nimport {useCallback} from 'react';\n\nimport {Button} from '../../Button.js';\nimport {Checkbox} from '../../Checkbox.js';\nimport {CheckboxField} from '../../CheckboxField.js';\nimport {Container} from '../../Container.js';\nimport {Icon} from '../../Icon.js';\nimport {Label} from '../../Label.js';\nimport {type DataTableProps} from '../DataTable.js';\n\nexport type DataTableSettingProps = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n table: Table<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n column: Column<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];\n};\n\nexport function DataTableSetting({\n table,\n // header,\n column,\n hideColumnVisibility = false,\n hideColumnOrder = false,\n hideColumnPinning = false,\n}: DataTableSettingProps) {\n let {attributes, isDragging, listeners, setNodeRef, transform, setActivatorNodeRef} = useSortable(\n {\n id: column.id,\n },\n );\n\n let handleChange = useCallback(\n (checked: boolean) => {\n if (!checked && table.getFlatHeaders().length >= 2) {\n column.toggleVisibility(checked);\n } else if (checked) {\n column.toggleVisibility(checked);\n }\n },\n [column, table],\n );\n\n let handlePinLeftClick = useCallback(() => {\n column.pin('left');\n }, [column]);\n\n let handlePinRightClick = useCallback(() => {\n column.pin('right');\n }, [column]);\n\n let handleUnpinClick = useCallback(() => {\n column.pin(false);\n }, [column]);\n\n let resolvedHideColumnPinning = hideColumnPinning || !column.getCanPin();\n\n return (\n <div\n ref={setNodeRef}\n style={{\n transform: CSS.Translate.toString(transform),\n transition: 'width transform 0.2s ease-in-out',\n zIndex: isDragging ? 20 : undefined,\n }}\n className=\"flex items-center gap-4\"\n >\n {hideColumnOrder ? null : (\n <Button\n ref={setActivatorNodeRef}\n aria-label=\"Resize\"\n className=\"cursor-move\"\n size=\"small\"\n variant=\"invisible\"\n {...attributes}\n {...listeners}\n >\n <Icon name=\"Bars4\" size=\"small\" />\n </Button>\n )}\n {hideColumnVisibility ?\n <span className=\"mr-auto font-sans text-sm font-medium\">\n {flexRender(column.columnDef.header, {\n table,\n column,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions -- needed\n header: {column} as Header<any, any>,\n })}\n </span>\n : <CheckboxField className=\"mr-auto\">\n <Checkbox checked={column.getIsVisible()} onChange={handleChange} />\n <Label className=\"flex\">\n {flexRender(column.columnDef.header, {\n table,\n column,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions -- needed\n header: {column} as Header<any, any>,\n })}\n </Label>\n </CheckboxField>\n }\n\n {resolvedHideColumnPinning ? null : (\n <Container spacing=\"extra-small\">\n {column.getIsPinned() === 'left' ? null : (\n <Button\n aria-label=\"Pin to left\"\n size=\"small\"\n variant=\"outline\"\n onClick={handlePinLeftClick}\n >\n <Icon name=\"ArrowLeftEndOnRectangle\" size=\"small\" />\n </Button>\n )}\n {column.getIsPinned() ?\n <Button aria-label=\"Unpin\" size=\"small\" variant=\"outline\" onClick={handleUnpinClick}>\n <Icon name=\"XMark\" size=\"small\" />\n </Button>\n : null}\n {column.getIsPinned() === 'right' ? null : (\n <Button\n aria-label=\"Pin to right\"\n size=\"small\"\n variant=\"outline\"\n onClick={handlePinRightClick}\n >\n <Icon name=\"ArrowRightEndOnRectangle\" size=\"small\" />\n </Button>\n )}\n </Container>\n )}\n </div>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAqFU,cAYF,YAZE;AArFV,SAAQ,mBAAkB;AAC1B,SAAQ,WAAU;AAClB,SAAqB,kBAA0C;AAC/D,SAAQ,mBAAkB;AAE1B,SAAQ,cAAa;AACrB,SAAQ,gBAAe;AACvB,SAAQ,qBAAoB;AAC5B,SAAQ,iBAAgB;AACxB,SAAQ,YAAW;AACnB,SAAQ,aAAY;AAgBb,gBAAS,iBAAiB;AAAA,EAC/B;AAAA;AAAA,EAEA;AAAA,EACA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U,QAAQ;AAAA,UACnC;AAAA,UACA;AAAA;AAAA,UAEA,QAAQ,EAAC,OAAM;AAAA,QACjB,CAAC,GACH,IACA,qBAAC,iBAAc,WAAU,WACvB;AAAA,8BAAC,YAAS,SAAS,OAAO,aAAa,GAAG,UAAU,cAAc;AAAA,UAClE,oBAAC,SAAM,WAAU,QACd,qBAAW,OAAO,UAAU,QAAQ;AAAA,YACnC;AAAA,YACA;AAAA;AAAA,YAEA,QAAQ,EAAC,OAAM;AAAA,UACjB,CAAC,GACH;AAAA,WACF;AAAA,QAGD,4BAA4B,OAC3B,qBAAC,aAAU,SAAQ,eAChB;AAAA,iBAAO,YAAY,MAAM,SAAS,OACjC;AAAA,YAAC;AAAA;AAAA,cACC,cAAW;AAAA,cACX,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cAET,8BAAC,QAAK,MAAK,2BAA0B,MAAK,SAAQ;AAAA;AAAA,UACpD;AAAA,UAED,OAAO,YAAY,IAClB,oBAAC,UAAO,cAAW,SAAQ,MAAK,SAAQ,SAAQ,WAAU,SAAS,kBACjE,8BAAC,QAAK,MAAK,SAAQ,MAAK,SAAQ,GAClC,IACA;AAAA,UACD,OAAO,YAAY,MAAM,UAAU,OAClC;AAAA,YAAC;AAAA;AAAA,cACC,cAAW;AAAA,cACX,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,SAAS;AAAA,cAET,8BAAC,QAAK,MAAK,4BAA2B,MAAK,SAAQ;AAAA;AAAA,UACrD;AAAA,WAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Table } from '@tanstack/react-table';
|
|
2
|
+
import { type DataTableProps } from '../DataTable.js';
|
|
3
|
+
export type DataTableSettingsProps = {
|
|
4
|
+
table: Table<any>;
|
|
5
|
+
hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];
|
|
6
|
+
hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];
|
|
7
|
+
hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];
|
|
8
|
+
};
|
|
9
|
+
export declare function DataTableSettings({ table, hideColumnVisibility, hideColumnOrder, hideColumnPinning, }: DataTableSettingsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
closestCenter,
|
|
5
|
+
DndContext,
|
|
6
|
+
KeyboardSensor,
|
|
7
|
+
MouseSensor,
|
|
8
|
+
TouchSensor,
|
|
9
|
+
useSensor,
|
|
10
|
+
useSensors
|
|
11
|
+
} from "@dnd-kit/core";
|
|
12
|
+
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
13
|
+
import { arrayMove, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
14
|
+
import { useCallback, useId } from "react";
|
|
15
|
+
import { Container } from "../../Container.js";
|
|
16
|
+
import { DataTableSetting } from "./DataTableSetting.js";
|
|
17
|
+
export function DataTableSettings({
|
|
18
|
+
table,
|
|
19
|
+
hideColumnVisibility = false,
|
|
20
|
+
hideColumnOrder = false,
|
|
21
|
+
hideColumnPinning = false
|
|
22
|
+
}) {
|
|
23
|
+
let sensors = useSensors(
|
|
24
|
+
useSensor(MouseSensor, {
|
|
25
|
+
activationConstraint: {
|
|
26
|
+
distance: 1
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
useSensor(TouchSensor, {
|
|
30
|
+
activationConstraint: {
|
|
31
|
+
distance: 1
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
useSensor(KeyboardSensor, {})
|
|
35
|
+
);
|
|
36
|
+
let id = useId();
|
|
37
|
+
let handleDragEnd = useCallback(
|
|
38
|
+
({ active, over }) => {
|
|
39
|
+
if (over && active.id !== over.id) {
|
|
40
|
+
table.setColumnOrder((previousColumnOrder) => {
|
|
41
|
+
let oldIndex = previousColumnOrder.indexOf(active.id);
|
|
42
|
+
let newIndex = previousColumnOrder.indexOf(over.id);
|
|
43
|
+
return arrayMove(previousColumnOrder, oldIndex, newIndex);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[table]
|
|
48
|
+
);
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
DndContext,
|
|
51
|
+
{
|
|
52
|
+
collisionDetection: closestCenter,
|
|
53
|
+
id,
|
|
54
|
+
modifiers: [restrictToVerticalAxis],
|
|
55
|
+
sensors,
|
|
56
|
+
onDragEnd: handleDragEnd,
|
|
57
|
+
children: /* @__PURE__ */ jsx(SortableContext, { items: table.getState().columnOrder, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsx(Container, { direction: "column", spacing: "small", children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ jsx(
|
|
58
|
+
DataTableSetting,
|
|
59
|
+
{
|
|
60
|
+
column,
|
|
61
|
+
hideColumnOrder,
|
|
62
|
+
hideColumnPinning,
|
|
63
|
+
hideColumnVisibility,
|
|
64
|
+
table
|
|
65
|
+
},
|
|
66
|
+
column.id
|
|
67
|
+
)) }) })
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=DataTableSettings.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../source/components/data-table/internals/DataTableSettings.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n closestCenter,\n DndContext,\n type DragEndEvent,\n KeyboardSensor,\n MouseSensor,\n TouchSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {arrayMove, SortableContext, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {type Table} from '@tanstack/react-table';\nimport {useCallback, useId} from 'react';\n\nimport {Container} from '../../Container.js';\nimport {type DataTableProps} from '../DataTable.js';\nimport {DataTableSetting} from './DataTableSetting.js';\n\nexport type DataTableSettingsProps = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n table: Table<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnVisibility: DataTableProps<any, any>['hideColumnVisibility'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnOrder: DataTableProps<any, any>['hideColumnOrder'];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- needed\n hideColumnPinning: DataTableProps<any, any>['hideColumnPinning'];\n};\n\nexport function DataTableSettings({\n table,\n hideColumnVisibility = false,\n hideColumnOrder = false,\n hideColumnPinning = false,\n}: DataTableSettingsProps) {\n let sensors = useSensors(\n useSensor(MouseSensor, {\n activationConstraint: {\n distance: 1,\n },\n }),\n useSensor(TouchSensor, {\n activationConstraint: {\n distance: 1,\n },\n }),\n useSensor(KeyboardSensor, {}),\n );\n\n let id = useId();\n\n let handleDragEnd = useCallback(\n ({active, over}: DragEndEvent) => {\n if (over && active.id !== over.id) {\n table.setColumnOrder((previousColumnOrder) => {\n let oldIndex = previousColumnOrder.indexOf(active.id as string);\n let newIndex = previousColumnOrder.indexOf(over.id as string);\n\n return arrayMove(previousColumnOrder, oldIndex, newIndex);\n });\n }\n },\n [table],\n );\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n id={id}\n modifiers={[restrictToVerticalAxis]}\n sensors={sensors}\n onDragEnd={handleDragEnd}\n >\n <SortableContext items={table.getState().columnOrder} strategy={verticalListSortingStrategy}>\n <Container direction=\"column\" spacing=\"small\">\n {table.getAllLeafColumns().map((column) => (\n <DataTableSetting\n key={column.id}\n column={column}\n hideColumnOrder={hideColumnOrder}\n hideColumnPinning={hideColumnPinning}\n hideColumnVisibility={hideColumnVisibility}\n table={table}\n />\n ))}\n </Container>\n </SortableContext>\n </DndContext>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AA6EY;AA7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QAAC;AAAA;AAAA,UAEC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,QALK,OAAO;AAAA,MAMd,CACD,GACH,GACF;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export * from './internals/addFilter.js';
|
|
2
2
|
export * from './internals/constants.js';
|
|
3
|
+
export * from './internals/DataTableFilter.js';
|
|
4
|
+
export * from './internals/DataTableFilters.js';
|
|
3
5
|
export * from './internals/DataTableHeader.js';
|
|
4
6
|
export * from './internals/DataTableHeaderColumnCheckbox.js';
|
|
5
7
|
export * from './internals/DataTableHeaderFilter.js';
|
|
8
|
+
export * from './internals/DataTableMenu.js';
|
|
6
9
|
export * from './internals/DataTablePageButton.js';
|
|
7
10
|
export * from './internals/DataTablePagination.js';
|
|
8
11
|
export * from './internals/DataTableSearch.js';
|
|
12
|
+
export * from './internals/DataTableSetting.js';
|
|
13
|
+
export * from './internals/DataTableSettings.js';
|
|
9
14
|
export * from './internals/fromPinningState.js';
|
|
10
15
|
export * from './internals/fuzzyFilter.js';
|
|
11
16
|
export * from './internals/getCommonPinningClasses.js';
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
export * from "./internals/addFilter.js";
|
|
3
3
|
export * from "./internals/constants.js";
|
|
4
|
+
export * from "./internals/DataTableFilter.js";
|
|
5
|
+
export * from "./internals/DataTableFilters.js";
|
|
4
6
|
export * from "./internals/DataTableHeader.js";
|
|
5
7
|
export * from "./internals/DataTableHeaderColumnCheckbox.js";
|
|
6
8
|
export * from "./internals/DataTableHeaderFilter.js";
|
|
9
|
+
export * from "./internals/DataTableMenu.js";
|
|
7
10
|
export * from "./internals/DataTablePageButton.js";
|
|
8
11
|
export * from "./internals/DataTablePagination.js";
|
|
9
12
|
export * from "./internals/DataTableSearch.js";
|
|
13
|
+
export * from "./internals/DataTableSetting.js";
|
|
14
|
+
export * from "./internals/DataTableSettings.js";
|
|
10
15
|
export * from "./internals/fromPinningState.js";
|
|
11
16
|
export * from "./internals/fuzzyFilter.js";
|
|
12
17
|
export * from "./internals/getCommonPinningClasses.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../source/components/data-table/internals.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './internals/addFilter.js';\nexport * from './internals/constants.js';\nexport * from './internals/DataTableHeader.js';\nexport * from './internals/DataTableHeaderColumnCheckbox.js';\nexport * from './internals/DataTableHeaderFilter.js';\nexport * from './internals/DataTablePageButton.js';\nexport * from './internals/DataTablePagination.js';\nexport * from './internals/DataTableSearch.js';\nexport * from './internals/fromPinningState.js';\nexport * from './internals/fuzzyFilter.js';\nexport * from './internals/getCommonPinningClasses.js';\nexport * from './internals/getCommonPinningStyles.js';\nexport * from './internals/normalizeFilter.js';\nexport * from './internals/normalizeFilters.js';\nexport * from './internals/normalizeSorting.js';\nexport * from './internals/removeFilter.js';\n"],
|
|
5
|
-
"mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from './internals/addFilter.js';\nexport * from './internals/constants.js';\nexport * from './internals/DataTableFilter.js';\nexport * from './internals/DataTableFilters.js';\nexport * from './internals/DataTableHeader.js';\nexport * from './internals/DataTableHeaderColumnCheckbox.js';\nexport * from './internals/DataTableHeaderFilter.js';\nexport * from './internals/DataTableMenu.js';\nexport * from './internals/DataTablePageButton.js';\nexport * from './internals/DataTablePagination.js';\nexport * from './internals/DataTableSearch.js';\nexport * from './internals/DataTableSetting.js';\nexport * from './internals/DataTableSettings.js';\nexport * from './internals/fromPinningState.js';\nexport * from './internals/fuzzyFilter.js';\nexport * from './internals/getCommonPinningClasses.js';\nexport * from './internals/getCommonPinningStyles.js';\nexport * from './internals/normalizeFilter.js';\nexport * from './internals/normalizeFilters.js';\nexport * from './internals/normalizeSorting.js';\nexport * from './internals/removeFilter.js';\n"],
|
|
5
|
+
"mappings": ";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
import { type Config as BaseTailwindConfig } from 'tailwindcss';
|
|
2
2
|
import { type DEFAULT_STOPS } from './internals/constants.js';
|
|
3
|
+
export declare const defaultCreateTailwindConfigOptions: {
|
|
4
|
+
colors: {
|
|
5
|
+
gray: string;
|
|
6
|
+
neutral: string;
|
|
7
|
+
red: string;
|
|
8
|
+
danger: string;
|
|
9
|
+
orange: {
|
|
10
|
+
hex: string;
|
|
11
|
+
hueShift: number;
|
|
12
|
+
};
|
|
13
|
+
warning: {
|
|
14
|
+
hex: string;
|
|
15
|
+
hueShift: number;
|
|
16
|
+
};
|
|
17
|
+
yellow: {
|
|
18
|
+
swatches: ({
|
|
19
|
+
hex: string;
|
|
20
|
+
stop: 10;
|
|
21
|
+
} | {
|
|
22
|
+
hex: string;
|
|
23
|
+
stop: 25;
|
|
24
|
+
} | {
|
|
25
|
+
hex: string;
|
|
26
|
+
stop: 50;
|
|
27
|
+
} | {
|
|
28
|
+
hex: string;
|
|
29
|
+
stop: 100;
|
|
30
|
+
} | {
|
|
31
|
+
hex: string;
|
|
32
|
+
stop: 200;
|
|
33
|
+
} | {
|
|
34
|
+
hex: string;
|
|
35
|
+
stop: 300;
|
|
36
|
+
} | {
|
|
37
|
+
hex: string;
|
|
38
|
+
stop: 400;
|
|
39
|
+
} | {
|
|
40
|
+
hex: string;
|
|
41
|
+
stop: 500;
|
|
42
|
+
} | {
|
|
43
|
+
hex: string;
|
|
44
|
+
stop: 600;
|
|
45
|
+
} | {
|
|
46
|
+
hex: string;
|
|
47
|
+
stop: 700;
|
|
48
|
+
} | {
|
|
49
|
+
hex: string;
|
|
50
|
+
stop: 800;
|
|
51
|
+
} | {
|
|
52
|
+
hex: string;
|
|
53
|
+
stop: 900;
|
|
54
|
+
} | {
|
|
55
|
+
hex: string;
|
|
56
|
+
stop: 950;
|
|
57
|
+
} | {
|
|
58
|
+
hex: string;
|
|
59
|
+
stop: 975;
|
|
60
|
+
} | {
|
|
61
|
+
hex: string;
|
|
62
|
+
stop: 990;
|
|
63
|
+
})[];
|
|
64
|
+
hex: string;
|
|
65
|
+
hueShift: number;
|
|
66
|
+
};
|
|
67
|
+
green: string;
|
|
68
|
+
teal: {
|
|
69
|
+
hex: string;
|
|
70
|
+
hueShift: number;
|
|
71
|
+
};
|
|
72
|
+
blue: string;
|
|
73
|
+
primary: string;
|
|
74
|
+
violet: string;
|
|
75
|
+
pink: {
|
|
76
|
+
hex: string;
|
|
77
|
+
hueShift: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
3
81
|
export type CreateTailwindConfigOptions = {
|
|
4
82
|
content?: string[] | undefined;
|
|
5
83
|
colors?: Record<string, {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import plugin from "tailwindcss/plugin";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
let defaultCreateTailwindConfigOptions = {
|
|
3
|
+
import { createTailwindThemeColors } from "./internals.js";
|
|
4
|
+
export const defaultCreateTailwindConfigOptions = {
|
|
6
5
|
colors: {
|
|
7
6
|
gray: "#6c6e79",
|
|
8
7
|
neutral: "#6c6e79",
|
|
@@ -59,50 +58,7 @@ export function createTailwindConfig({
|
|
|
59
58
|
content,
|
|
60
59
|
colors
|
|
61
60
|
} = defaultCreateTailwindConfigOptions) {
|
|
62
|
-
let themeColors =
|
|
63
|
-
transparent: "transparent",
|
|
64
|
-
current: "currentColor",
|
|
65
|
-
white: "#fff",
|
|
66
|
-
black: "#000"
|
|
67
|
-
};
|
|
68
|
-
for (let [name, color] of Object.entries(colors ?? {})) {
|
|
69
|
-
if (typeof color === "string") {
|
|
70
|
-
themeColors = {
|
|
71
|
-
...themeColors,
|
|
72
|
-
...createPalette({
|
|
73
|
-
name,
|
|
74
|
-
swatches: [
|
|
75
|
-
{
|
|
76
|
-
hex: color,
|
|
77
|
-
stop: DEFAULT_STOP
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
hueShift: 0,
|
|
81
|
-
saturationShift: 0
|
|
82
|
-
})
|
|
83
|
-
};
|
|
84
|
-
} else if ("swatches" in color) {
|
|
85
|
-
themeColors = {
|
|
86
|
-
...themeColors,
|
|
87
|
-
...createPalette({
|
|
88
|
-
name,
|
|
89
|
-
swatches: color.swatches,
|
|
90
|
-
hueShift: color.hueShift ?? 0,
|
|
91
|
-
saturationShift: color.saturationShift ?? 0
|
|
92
|
-
})
|
|
93
|
-
};
|
|
94
|
-
} else if ("hex" in color) {
|
|
95
|
-
themeColors = {
|
|
96
|
-
...themeColors,
|
|
97
|
-
...createPalette({
|
|
98
|
-
name,
|
|
99
|
-
swatches: [{ hex: color.hex, stop: DEFAULT_STOP }],
|
|
100
|
-
hueShift: color.hueShift ?? 0,
|
|
101
|
-
saturationShift: color.saturationShift ?? 0
|
|
102
|
-
})
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
61
|
+
let themeColors = createTailwindThemeColors(colors);
|
|
106
62
|
let root = {
|
|
107
63
|
"--radius-none": "0",
|
|
108
64
|
"--radius-0_5": "0.125rem",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../source/development/createTailwindConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import {type Config as BaseTailwindConfig} from 'tailwindcss';\nimport plugin from 'tailwindcss/plugin';\n\nimport {
|
|
5
|
-
"mappings": ";AACA,OAAO,YAAY;AAEnB,SAAQ,
|
|
4
|
+
"sourcesContent": ["import {type Config as BaseTailwindConfig} from 'tailwindcss';\nimport plugin from 'tailwindcss/plugin';\n\nimport {createTailwindThemeColors} from './internals.js';\nimport {type DEFAULT_STOPS} from './internals/constants.js';\n\nexport const defaultCreateTailwindConfigOptions = {\n colors: {\n gray: '#6c6e79',\n neutral: '#6c6e79', // copy of \"gray\"\n red: '#d1002f',\n danger: '#d1002f', // copy of \"red\"\n orange: {\n hex: '#c33909',\n hueShift: 1,\n },\n warning: {\n hex: '#c33909',\n hueShift: 1,\n }, // copy of \"orange\"\n yellow: {\n swatches: [\n {hex: '#fffffa', stop: 10},\n {hex: '#fffef0', stop: 25},\n {hex: '#fffbdb', stop: 50},\n {hex: '#fff3b8', stop: 100},\n {hex: '#ffe06f', stop: 200},\n {hex: '#ffc72d', stop: 300},\n {hex: '#e69d00', stop: 400},\n {hex: '#9e6300', stop: 500},\n {hex: '#805701', stop: 600},\n {hex: '#614700', stop: 700},\n {hex: '#3d3000', stop: 800},\n {hex: '#1f1a00', stop: 900},\n {hex: '#0f0e00', stop: 950},\n {hex: '#0a0a00', stop: 975},\n {hex: '#050500', stop: 990},\n ],\n hex: '#9e6300',\n hueShift: 3,\n },\n green: '#0a7e22',\n teal: {\n hex: '#007c65',\n hueShift: 5,\n },\n blue: '#006dca',\n primary: '#006dca', // copy of \"blue\"\n violet: '#8649e1',\n pink: {\n hex: '#b229b9',\n hueShift: 10,\n },\n },\n} satisfies CreateTailwindConfigOptions;\n\nexport type CreateTailwindConfigOptions = {\n content?: string[] | undefined;\n colors?: Record<\n string,\n | {hex: string; hueShift?: number; saturationShift?: number}\n | {\n swatches: Array<{hex: string; stop: (typeof DEFAULT_STOPS)[number]}>;\n hueShift?: number;\n saturationShift?: number;\n }\n | string\n >;\n};\n\nexport type TailwindConfig = {\n theme: BaseTailwindConfig['theme'];\n // TODO: find another solution; following is needed because of this: https://github.com/tailwindlabs/tailwindcss/issues/18237\n plugins: BaseTailwindConfig['plugins'];\n};\n\nexport function createTailwindConfig({\n content,\n colors,\n}: CreateTailwindConfigOptions = defaultCreateTailwindConfigOptions): TailwindConfig {\n let themeColors = createTailwindThemeColors(colors);\n\n // TODO: find another solution; following is needed because of this: https://github.com/tailwindlabs/tailwindcss/issues/18237\n let root: Record<string, Record<string, string> | string> = {\n '--radius-none': '0',\n '--radius-0_5': '0.125rem',\n '--radius-1': '0.25rem',\n '--radius-1_5': '0.375rem',\n '--radius-2': '0.5rem',\n '--radius-2_5': '0.625rem',\n '--radius-3': '0.75rem',\n '--radius-4': '1rem',\n '--radius-full': '9999px',\n '--font-sans':\n 'InterVariable, ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"',\n };\n\n for (let [colorName, colorValue] of Object.entries(themeColors)) {\n if (typeof colorValue === 'string') {\n let variableName = `--color-${colorName}`;\n let variableValue = colorValue;\n\n root[variableName] = variableValue;\n themeColors[colorName] = `var(${variableName})`;\n } else if (typeof colorValue === 'object') {\n for (let [shadeName, shadeValue] of Object.entries(colorValue)) {\n let variableName = `--color-${colorName}-${shadeName}`;\n let variableValue = shadeValue;\n\n root[variableName] = variableValue;\n (themeColors[colorName] as Record<string, string>)[shadeName] = `var(${variableName})`; // type assertion is ok, we know the shape of `themeColors`\n }\n }\n }\n\n return {\n theme: {\n colors: themeColors,\n radius: {\n none: 'var(--radius-none)',\n '0.5': 'var(--radius-0_5)',\n '1': 'var(--radius-1)',\n '1.5': 'var(--radius-1_5)',\n '2': 'var(--radius-2)',\n '2.5': 'var(--radius-2_5)',\n '3': 'var(--radius-3)',\n '4': 'var(--radius-4)',\n full: 'var(--radius-full)',\n },\n font: {\n sans: 'var(--font-sans)',\n },\n },\n // TODO: find another solution; following is needed because of this: https://github.com/tailwindlabs/tailwindcss/issues/18237\n plugins: [\n plugin(({addBase}) => {\n addBase({\n ':root': root,\n });\n }),\n ],\n };\n}\n"],
|
|
5
|
+
"mappings": ";AACA,OAAO,YAAY;AAEnB,SAAQ,iCAAgC;AAGjC,aAAM,qCAAqC;AAAA,EAChD,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA;AAAA,IACT,KAAK;AAAA,IACL,QAAQ;AAAA;AAAA,IACR,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA;AAAA,IACA,QAAQ;AAAA,MACN,UAAU;AAAA,QACR,EAAC,KAAK,WAAW,MAAM,GAAE;AAAA,QACzB,EAAC,KAAK,WAAW,MAAM,GAAE;AAAA,QACzB,EAAC,KAAK,WAAW,MAAM,GAAE;AAAA,QACzB,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,QAC1B,EAAC,KAAK,WAAW,MAAM,IAAG;AAAA,MAC5B;AAAA,MACA,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,IACP,MAAM;AAAA,MACJ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AAM;AAAA,MACR;AAAA,IACF;AAAA;AAAA,IAEA,SAAS;AAAA,MACP,OAAO,CAAC,EAAC,QAAO,MAAM;AACpB,gBAAQ;AAAA,UACN,SAAS;AAAA,QACX,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { DEFAULT_STOP } from "./constants.js";
|
|
3
|
+
import { createPalette } from "./createPalette.js";
|
|
4
|
+
export function createTailwindThemeColors(colors) {
|
|
5
|
+
let themeColors = {
|
|
6
|
+
transparent: "transparent",
|
|
7
|
+
current: "currentColor",
|
|
8
|
+
white: "#fff",
|
|
9
|
+
black: "#000"
|
|
10
|
+
};
|
|
11
|
+
for (let [name, color] of Object.entries(colors ?? {})) {
|
|
12
|
+
if (typeof color === "string") {
|
|
13
|
+
themeColors = {
|
|
14
|
+
...themeColors,
|
|
15
|
+
...createPalette({
|
|
16
|
+
name,
|
|
17
|
+
swatches: [
|
|
18
|
+
{
|
|
19
|
+
hex: color,
|
|
20
|
+
stop: DEFAULT_STOP
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
hueShift: 0,
|
|
24
|
+
saturationShift: 0
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
} else if ("swatches" in color) {
|
|
28
|
+
themeColors = {
|
|
29
|
+
...themeColors,
|
|
30
|
+
...createPalette({
|
|
31
|
+
name,
|
|
32
|
+
swatches: color.swatches,
|
|
33
|
+
hueShift: color.hueShift ?? 0,
|
|
34
|
+
saturationShift: color.saturationShift ?? 0
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
} else if ("hex" in color) {
|
|
38
|
+
themeColors = {
|
|
39
|
+
...themeColors,
|
|
40
|
+
...createPalette({
|
|
41
|
+
name,
|
|
42
|
+
swatches: [{ hex: color.hex, stop: DEFAULT_STOP }],
|
|
43
|
+
hueShift: color.hueShift ?? 0,
|
|
44
|
+
saturationShift: color.saturationShift ?? 0
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return themeColors;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=createTailwindThemeColors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../source/development/internals/createTailwindThemeColors.ts"],
|
|
4
|
+
"sourcesContent": ["import {type CreateTailwindConfigOptions} from '../createTailwindConfig.js';\nimport {DEFAULT_STOP} from './constants.js';\nimport {createPalette} from './createPalette.js';\n\nexport function createTailwindThemeColors(colors: CreateTailwindConfigOptions['colors']) {\n let themeColors: Record<string, Record<string, string> | string> = {\n transparent: 'transparent',\n current: 'currentColor',\n white: '#fff',\n black: '#000',\n };\n\n for (let [name, color] of Object.entries(colors ?? {})) {\n if (typeof color === 'string') {\n themeColors = {\n ...themeColors,\n ...createPalette({\n name,\n swatches: [\n {\n hex: color,\n stop: DEFAULT_STOP,\n },\n ],\n hueShift: 0,\n saturationShift: 0,\n }),\n };\n } else if ('swatches' in color) {\n themeColors = {\n ...themeColors,\n ...createPalette({\n name,\n swatches: color.swatches,\n hueShift: color.hueShift ?? 0,\n saturationShift: color.saturationShift ?? 0,\n }),\n };\n } else if ('hex' in color) {\n themeColors = {\n ...themeColors,\n ...createPalette({\n name,\n swatches: [{hex: color.hex, stop: DEFAULT_STOP}],\n hueShift: color.hueShift ?? 0,\n saturationShift: color.saturationShift ?? 0,\n }),\n };\n }\n }\n\n return themeColors;\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAQ,oBAAmB;AAC3B,SAAQ,qBAAoB;AAErB,gBAAS,0BAA0B,QAA+C;AACvF,MAAI,cAA+D;AAAA,IACjE,aAAa;AAAA,IACb,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAEA,WAAS,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,UAAU,CAAC,CAAC,GAAG;AACtD,QAAI,OAAO,UAAU,UAAU;AAC7B,oBAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,cAAc;AAAA,UACf;AAAA,UACA,UAAU;AAAA,YACR;AAAA,cACE,KAAK;AAAA,cACL,MAAM;AAAA,YACR;AAAA,UACF;AAAA,UACA,UAAU;AAAA,UACV,iBAAiB;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,WAAW,cAAc,OAAO;AAC9B,oBAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,cAAc;AAAA,UACf;AAAA,UACA,UAAU,MAAM;AAAA,UAChB,UAAU,MAAM,YAAY;AAAA,UAC5B,iBAAiB,MAAM,mBAAmB;AAAA,QAC5C,CAAC;AAAA,MACH;AAAA,IACF,WAAW,SAAS,OAAO;AACzB,oBAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,cAAc;AAAA,UACf;AAAA,UACA,UAAU,CAAC,EAAC,KAAK,MAAM,KAAK,MAAM,aAAY,CAAC;AAAA,UAC/C,UAAU,MAAM,YAAY;AAAA,UAC5B,iBAAiB,MAAM,mBAAmB;AAAA,QAC5C,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -6,6 +6,7 @@ export * from './internals/createHueScale.js';
|
|
|
6
6
|
export * from './internals/createPalette.js';
|
|
7
7
|
export * from './internals/createSaturationScale.js';
|
|
8
8
|
export * from './internals/createSwatches.js';
|
|
9
|
+
export * from './internals/createTailwindThemeColors.js';
|
|
9
10
|
export * from './internals/hexToHsl.js';
|
|
10
11
|
export * from './internals/hexToRgb.js';
|
|
11
12
|
export * from './internals/hslToHex.js';
|
|
@@ -7,6 +7,7 @@ export * from "./internals/createHueScale.js";
|
|
|
7
7
|
export * from "./internals/createPalette.js";
|
|
8
8
|
export * from "./internals/createSaturationScale.js";
|
|
9
9
|
export * from "./internals/createSwatches.js";
|
|
10
|
+
export * from "./internals/createTailwindThemeColors.js";
|
|
10
11
|
export * from "./internals/hexToHsl.js";
|
|
11
12
|
export * from "./internals/hexToRgb.js";
|
|
12
13
|
export * from "./internals/hslToHex.js";
|