@solidpb/ui-kit 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/components/ActivityFeed/ActivityFeed.d.ts +16 -0
- package/dist/components/ActivityFeed/ActivityFeed.jsx +54 -0
- package/dist/components/ActivityFeed/index.d.ts +1 -0
- package/dist/components/ActivityFeed/index.js +1 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +27 -0
- package/dist/components/AlertDialog/AlertDialog.jsx +62 -0
- package/dist/components/AlertDialog/alertDialogContext.d.ts +9 -0
- package/dist/components/AlertDialog/alertDialogContext.js +2 -0
- package/dist/components/AlertDialog/index.d.ts +1 -0
- package/dist/components/AlertDialog/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +10 -0
- package/dist/components/Avatar/Avatar.jsx +30 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/BreadCrumbs/BreadCrumbs.d.ts +12 -0
- package/dist/components/BreadCrumbs/BreadCrumbs.jsx +26 -0
- package/dist/components/BreadCrumbs/index.d.ts +1 -0
- package/dist/components/BreadCrumbs/index.js +1 -0
- package/dist/components/Button/Button.d.ts +3 -3
- package/dist/components/Button/Button.jsx +1 -6
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Card/Card.jsx +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +6 -7
- package/dist/components/Checkbox/Checkbox.jsx +39 -22
- package/dist/components/ColorPicker/ColorPicker.d.ts +10 -0
- package/dist/components/ColorPicker/ColorPicker.jsx +61 -0
- package/dist/components/ColorPicker/index.d.ts +1 -0
- package/dist/components/ColorPicker/index.js +1 -0
- package/dist/components/Container/Container.jsx +1 -1
- package/dist/components/DateInput/DateInput.d.ts +5 -0
- package/dist/components/DateInput/DateInput.jsx +29 -8
- package/dist/components/Drawer/Drawer.d.ts +33 -0
- package/dist/components/Drawer/Drawer.jsx +49 -0
- package/dist/components/Drawer/drawerContext.d.ts +6 -0
- package/dist/components/Drawer/drawerContext.js +9 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Drawer/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +23 -7
- package/dist/components/DropdownMenu/DropdownMenu.jsx +41 -15
- package/dist/components/FileInput/FileInput.d.ts +7 -3
- package/dist/components/FileInput/FileInput.jsx +35 -9
- package/dist/components/FilterBar/AddFilter.d.ts +9 -0
- package/dist/components/FilterBar/AddFilter.jsx +14 -0
- package/dist/components/FilterBar/AddSortingDropdown.d.ts +9 -0
- package/dist/components/FilterBar/AddSortingDropdown.jsx +67 -0
- package/dist/components/FilterBar/EditFilters.d.ts +10 -0
- package/dist/components/FilterBar/EditFilters.jsx +12 -0
- package/dist/components/FilterBar/FilterBar.d.ts +56 -0
- package/dist/components/FilterBar/FilterBar.jsx +234 -0
- package/dist/components/FilterBar/FilterChip.d.ts +23 -0
- package/dist/components/FilterBar/FilterChip.jsx +220 -0
- package/dist/components/FilterBar/FilterEdit.d.ts +13 -0
- package/dist/components/FilterBar/FilterEdit.jsx +159 -0
- package/dist/components/FilterBar/FiltersEdit.d.ts +13 -0
- package/dist/components/FilterBar/FiltersEdit.jsx +45 -0
- package/dist/components/FilterBar/index.d.ts +1 -0
- package/dist/components/FilterBar/index.js +1 -0
- package/dist/components/Form/Form.d.ts +36 -2
- package/dist/components/Form/Form.jsx +98 -3
- package/dist/components/Form/formContext.d.ts +2 -0
- package/dist/components/Form/formContext.js +9 -0
- package/dist/components/Image/Image.d.ts +6 -7
- package/dist/components/Image/Image.jsx +56 -7
- package/dist/components/Input/Input.d.ts +4 -4
- package/dist/components/Input/Input.jsx +9 -35
- package/dist/components/Kanban/Kanban.d.ts +19 -0
- package/dist/components/Kanban/Kanban.jsx +66 -0
- package/dist/components/Kanban/KanbanCard.d.ts +11 -0
- package/dist/components/Kanban/KanbanCard.jsx +94 -0
- package/dist/components/Kanban/KanbanColumn.d.ts +18 -0
- package/dist/components/Kanban/KanbanColumn.jsx +256 -0
- package/dist/components/Kanban/index.d.ts +1 -0
- package/dist/components/Kanban/index.js +1 -0
- package/dist/components/Link/Link.d.ts +8 -6
- package/dist/components/Link/Link.jsx +17 -5
- package/dist/components/Modal/Modal.d.ts +17 -8
- package/dist/components/Modal/Modal.jsx +32 -39
- package/dist/components/Modal/modalContext.d.ts +2 -3
- package/dist/components/Navbar/Navbar.d.ts +22 -0
- package/dist/components/Navbar/Navbar.jsx +38 -0
- package/dist/components/Navbar/index.d.ts +1 -0
- package/dist/components/Navbar/index.js +1 -0
- package/dist/components/NumberInput/NumberInput.d.ts +8 -6
- package/dist/components/NumberInput/NumberInput.jsx +52 -7
- package/dist/components/Pagination/Pagination.d.ts +15 -0
- package/dist/components/Pagination/Pagination.jsx +67 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/SearchInput/SearchInput.d.ts +3 -0
- package/dist/components/SearchInput/SearchInput.jsx +38 -3
- package/dist/components/Select/Select.d.ts +13 -11
- package/dist/components/Select/Select.jsx +78 -32
- package/dist/components/Slider/Slider.d.ts +16 -0
- package/dist/components/Slider/Slider.jsx +60 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Switch/Switch.d.ts +6 -8
- package/dist/components/Switch/Switch.jsx +38 -19
- package/dist/components/{List/List.d.ts → Table/Table.d.ts} +13 -12
- package/dist/components/Table/Table.jsx +193 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Tabs/Tabs.d.ts +25 -1
- package/dist/components/Tabs/Tabs.jsx +42 -1
- package/dist/components/Tabs/tabContext.d.ts +9 -0
- package/dist/components/Tabs/tabContext.js +2 -0
- package/dist/components/Tag/Tag.d.ts +7 -5
- package/dist/components/Tag/Tag.jsx +40 -14
- package/dist/components/TagArea/TagArea.d.ts +6 -2
- package/dist/components/TagArea/TagArea.jsx +89 -35
- package/dist/components/TextArea/TextArea.d.ts +9 -8
- package/dist/components/TextArea/TextArea.jsx +54 -18
- package/dist/components/ThemeSwitch/ThemeSwitch.d.ts +2 -0
- package/dist/components/ThemeSwitch/ThemeSwitch.jsx +72 -0
- package/dist/components/ThemeSwitch/index.d.ts +1 -0
- package/dist/components/ThemeSwitch/index.js +1 -0
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.jsx +13 -10
- package/dist/components/Toast/Toaster.jsx +1 -2
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/Tooltip/Tooltip.jsx +19 -8
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +7 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +14 -2
- package/dist/methods/triggerFlash.d.ts +1 -0
- package/dist/methods/triggerFlash.js +7 -0
- package/package.json +3 -2
- package/dist/components/List/List.jsx +0 -120
- package/dist/components/List/index.d.ts +0 -1
- package/dist/components/List/index.js +0 -1
- package/dist/components/RelationPicker/RelationPicker.d.ts +0 -11
- package/dist/components/RelationPicker/RelationPicker.jsx +0 -13
- package/dist/components/RelationPicker/index.d.ts +0 -1
- package/dist/components/RelationPicker/index.js +0 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { createSignal, createMemo, createEffect, onCleanup, Show, For } from "solid-js";
|
|
2
|
+
import { attachClosestEdge, extractClosestEdge, } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
3
|
+
import { dropTargetForElements, draggable, monitorForElements, } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
4
|
+
import Fold from "lucide-solid/icons/fold-horizontal";
|
|
5
|
+
import UnFold from "lucide-solid/icons/unfold-horizontal";
|
|
6
|
+
import Plus from "lucide-solid/icons/plus";
|
|
7
|
+
import invariant from "tiny-invariant";
|
|
8
|
+
import { tv } from "tailwind-variants";
|
|
9
|
+
import { triggerFlash } from "../../methods/triggerFlash";
|
|
10
|
+
import { iconSize } from "../../constants";
|
|
11
|
+
import { Button } from "../Button";
|
|
12
|
+
import { KanbanCard } from "./KanbanCard";
|
|
13
|
+
import { Input } from "../Input";
|
|
14
|
+
const column = tv({
|
|
15
|
+
base: "kanban-column flex flex-col gap-1 flex-shrink-0 bg-base-300 p-1.5 rounded-md transition-[width] text-nowrap",
|
|
16
|
+
variants: {
|
|
17
|
+
folded: {
|
|
18
|
+
true: "w-9",
|
|
19
|
+
false: "w-70",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
folded: false,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const columnHeader = tv({
|
|
27
|
+
base: "font-semibold text-sm sticky top-0 pb-1",
|
|
28
|
+
variants: {
|
|
29
|
+
folded: {
|
|
30
|
+
true: "flex flex-col",
|
|
31
|
+
false: "flex justify-between",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
folded: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
const columnContent = tv({
|
|
39
|
+
base: "flex flex-col gap-1.5",
|
|
40
|
+
});
|
|
41
|
+
export const KanbanColumn = (props) => {
|
|
42
|
+
let ref;
|
|
43
|
+
const [dragging, setDragging] = createSignal("idle");
|
|
44
|
+
const [closestEdge, setClosestEdge] = createSignal();
|
|
45
|
+
const [cardDraggedOver, setCardDraggedOver] = createSignal(false);
|
|
46
|
+
const [folded, setFolded] = createSignal(false);
|
|
47
|
+
const [creatingItem, setCreatingItem] = createSignal(false);
|
|
48
|
+
const [newItemTitle, setNewItemTitle] = createSignal("");
|
|
49
|
+
const filteredItems = createMemo(() => {
|
|
50
|
+
let items = [...props.items];
|
|
51
|
+
const stateKey = props.itemStateKey;
|
|
52
|
+
const posKey = props.itemPositionKey;
|
|
53
|
+
if (stateKey) {
|
|
54
|
+
items = items.filter((item) => item[stateKey] === props.col.id);
|
|
55
|
+
}
|
|
56
|
+
if (!posKey)
|
|
57
|
+
return items;
|
|
58
|
+
return items.sort((a, b) => (Number(a[posKey]) || 0) - (Number(b[posKey]) || 0));
|
|
59
|
+
});
|
|
60
|
+
const itemDragEnabled = () => !!props.itemPositionKey;
|
|
61
|
+
const [flashedCardId, setFlashedCardId] = createSignal(null);
|
|
62
|
+
createEffect(() => {
|
|
63
|
+
if (props.flashSignal?.() === props.col.id && ref) {
|
|
64
|
+
triggerFlash(ref);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
createEffect(() => {
|
|
68
|
+
if (!props.dragEnabled())
|
|
69
|
+
return;
|
|
70
|
+
const element = ref;
|
|
71
|
+
invariant(element);
|
|
72
|
+
const dispose = dropTargetForElements({
|
|
73
|
+
element,
|
|
74
|
+
canDrop({ source }) {
|
|
75
|
+
// not allowing dropping on yourself
|
|
76
|
+
if (source.element === element) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
// only allowing same collection for now to be dropped on me
|
|
80
|
+
return source.data.item.collectionId == props.col.collectionId;
|
|
81
|
+
},
|
|
82
|
+
getData({ input }) {
|
|
83
|
+
return attachClosestEdge({
|
|
84
|
+
item: props.col,
|
|
85
|
+
isKanbanColumn: true,
|
|
86
|
+
}, { element, input, allowedEdges: ["left", "right"] });
|
|
87
|
+
},
|
|
88
|
+
onDragEnter({ self, source }) {
|
|
89
|
+
setDragging("dragging-over");
|
|
90
|
+
if (source.data.isKanbanColumn) {
|
|
91
|
+
const _closestEdge = extractClosestEdge(self.data);
|
|
92
|
+
setClosestEdge(_closestEdge);
|
|
93
|
+
}
|
|
94
|
+
else if (source.data.isKanbanCard) {
|
|
95
|
+
setCardDraggedOver(true);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
onDrag({ self, source }) {
|
|
99
|
+
if (source.data.isKanbanColumn) {
|
|
100
|
+
const _closestEdge = extractClosestEdge(self.data);
|
|
101
|
+
// Only need to update state if nothing has changed.
|
|
102
|
+
if (dragging() !== "dragging-over" || _closestEdge !== closestEdge()) {
|
|
103
|
+
setDragging("dragging-over");
|
|
104
|
+
setClosestEdge(_closestEdge);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (source.data.isKanbanCard) {
|
|
108
|
+
setCardDraggedOver(true);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onDragLeave() {
|
|
112
|
+
setDragging("idle");
|
|
113
|
+
setCardDraggedOver(false);
|
|
114
|
+
},
|
|
115
|
+
onDrop() {
|
|
116
|
+
setDragging("idle");
|
|
117
|
+
setCardDraggedOver(false);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
onCleanup(dispose);
|
|
121
|
+
});
|
|
122
|
+
createEffect(() => {
|
|
123
|
+
if (!props.dragEnabled())
|
|
124
|
+
return;
|
|
125
|
+
const element = ref;
|
|
126
|
+
invariant(element);
|
|
127
|
+
const dispose = draggable({
|
|
128
|
+
element,
|
|
129
|
+
getInitialData() {
|
|
130
|
+
return {
|
|
131
|
+
item: props.col,
|
|
132
|
+
isKanbanColumn: true,
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
onDragStart() {
|
|
136
|
+
setDragging("dragging");
|
|
137
|
+
},
|
|
138
|
+
onDrop() {
|
|
139
|
+
setDragging("idle");
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
onCleanup(dispose);
|
|
143
|
+
});
|
|
144
|
+
createEffect(() => {
|
|
145
|
+
if (!filteredItems().length || !itemDragEnabled())
|
|
146
|
+
return;
|
|
147
|
+
const dispose = monitorForElements({
|
|
148
|
+
canMonitor({ source }) {
|
|
149
|
+
if (!source.data.item) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return (source.data.item.collectionId == filteredItems()[0].collectionId &&
|
|
153
|
+
!!source.data.isKanbanCard);
|
|
154
|
+
},
|
|
155
|
+
onDrop({ location, source }) {
|
|
156
|
+
const target = location.current.dropTargets[0];
|
|
157
|
+
if (!target) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const sourceData = source.data;
|
|
161
|
+
const targetData = target.data;
|
|
162
|
+
const sourceItem = sourceData.item;
|
|
163
|
+
const targetItem = targetData.item;
|
|
164
|
+
const stateKey = props.itemStateKey;
|
|
165
|
+
const posKey = props.itemPositionKey;
|
|
166
|
+
if (!stateKey || !posKey)
|
|
167
|
+
return;
|
|
168
|
+
if (sourceItem.collectionId !== targetItem.collectionId)
|
|
169
|
+
return;
|
|
170
|
+
if (target.data.isKanbanColumn) {
|
|
171
|
+
let newInd = 0;
|
|
172
|
+
for (const item of props.items.filter((item) => item[stateKey] === target.data.item.id)) {
|
|
173
|
+
if ((Number(item[posKey]) || 0) >= newInd) {
|
|
174
|
+
newInd = (Number(item[posKey]) || 0) + 1;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if ((sourceItem[posKey] || 0) !== newInd) {
|
|
178
|
+
setFlashedCardId(sourceItem.id);
|
|
179
|
+
setTimeout(() => setFlashedCardId(null), 10);
|
|
180
|
+
}
|
|
181
|
+
// if we drop on the column
|
|
182
|
+
props.onReorderCard?.(sourceItem, Number(sourceItem[posKey]), newInd, String(sourceItem[stateKey]), targetData.item.id);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const closestEdgeOfTarget = extractClosestEdge(targetData);
|
|
186
|
+
const newInd = closestEdgeOfTarget === "top" ? Number(targetItem[posKey]) : Number(targetItem[posKey]) + 1;
|
|
187
|
+
if ((sourceItem[posKey] || 0) !== newInd) {
|
|
188
|
+
setFlashedCardId(sourceItem.id);
|
|
189
|
+
setTimeout(() => setFlashedCardId(null), 10);
|
|
190
|
+
}
|
|
191
|
+
props.onReorderCard?.(sourceItem, Number(sourceItem[posKey]), newInd, String(sourceItem[stateKey]), String(targetItem[stateKey]));
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
onCleanup(dispose);
|
|
196
|
+
});
|
|
197
|
+
const bgStyle = createMemo(() => {
|
|
198
|
+
if (cardDraggedOver()) {
|
|
199
|
+
return { "background-color": "color-mix(in srgb, var(--color-primary) 10%, transparent)" };
|
|
200
|
+
}
|
|
201
|
+
return {};
|
|
202
|
+
});
|
|
203
|
+
return (<div data-drop-edge={dragging() === "dragging-over" && !cardDraggedOver() ? (closestEdge() ?? undefined) : undefined} ref={ref} class={column({ class: props.class, folded: folded() })} style={{ opacity: dragging() == "dragging" ? 0.2 : 1, ...bgStyle() }}>
|
|
204
|
+
<div>
|
|
205
|
+
<div class={columnHeader({ folded: folded() })}>
|
|
206
|
+
<div class="flex items-center gap-2">
|
|
207
|
+
<Button size="xs" variant="ghost" modifier="square" onClick={() => setFolded(!folded())}>
|
|
208
|
+
<Show when={folded()} fallback={<Fold size={iconSize["sm"]}/>}>
|
|
209
|
+
<UnFold size={iconSize["sm"]}/>
|
|
210
|
+
</Show>
|
|
211
|
+
</Button>
|
|
212
|
+
{!folded() && (<div>
|
|
213
|
+
{props.col.title}
|
|
214
|
+
<span class="text-xs font-normal text-base-content/50 ml-2">{filteredItems().length}</span>
|
|
215
|
+
</div>)}
|
|
216
|
+
</div>
|
|
217
|
+
<div>
|
|
218
|
+
{!folded() && (<Button size="xs" variant="ghost" modifier="square" aria-label="create new item" onClick={() => setCreatingItem(!creatingItem())}>
|
|
219
|
+
<Plus size={iconSize["sm"]}/>
|
|
220
|
+
</Button>)}
|
|
221
|
+
</div>
|
|
222
|
+
{folded() && (<div class="font-semibold text-sm [writing-mode:vertical-rl] mt-2">
|
|
223
|
+
{props.col.title}
|
|
224
|
+
<span class="text-xs font-normal text-base-content/50 mt-2">{filteredItems().length}</span>
|
|
225
|
+
</div>)}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
<div class={columnContent()}>
|
|
229
|
+
{!folded() && (<>
|
|
230
|
+
{creatingItem() && (<div class="card bg-base-100 p-2 rounded-md space-y-1.5">
|
|
231
|
+
<p class="font-medium text-sm">New Item</p>
|
|
232
|
+
<Input value={newItemTitle()} onChange={setNewItemTitle} label="Title"/>
|
|
233
|
+
<div class="flex justify-end space-x-1.5">
|
|
234
|
+
<Button appearance="neutral" size="sm" onClick={() => {
|
|
235
|
+
setCreatingItem(false);
|
|
236
|
+
setNewItemTitle("");
|
|
237
|
+
}}>
|
|
238
|
+
Cancel
|
|
239
|
+
</Button>
|
|
240
|
+
<Button appearance="success" size="sm" onClick={() => {
|
|
241
|
+
setCreatingItem(false);
|
|
242
|
+
props.onCreateItem?.(newItemTitle(), props.col.id);
|
|
243
|
+
setNewItemTitle("");
|
|
244
|
+
}}>
|
|
245
|
+
Add
|
|
246
|
+
</Button>
|
|
247
|
+
</div>
|
|
248
|
+
</div>)}
|
|
249
|
+
<For each={filteredItems()}>
|
|
250
|
+
{(item) => (<KanbanCard item={item} dragEnabled={itemDragEnabled} onCardClick={() => props.onCardClick?.(item)} class={props.cardClass} renderItem={props.renderItem} flashSignal={() => flashedCardId()}/>)}
|
|
251
|
+
</For>
|
|
252
|
+
</>)}
|
|
253
|
+
</div>
|
|
254
|
+
</div>);
|
|
255
|
+
};
|
|
256
|
+
export default KanbanColumn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Kanban";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Kanban";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PolymorphicProps } from "@kobalte/core";
|
|
2
|
+
import { JSXElement, ValidComponent } from "solid-js";
|
|
3
|
+
type LinkProps<T extends ValidComponent = "a"> = PolymorphicProps<T, {
|
|
4
4
|
href?: string;
|
|
5
|
-
|
|
5
|
+
disabled?: boolean;
|
|
6
6
|
class?: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
appearance?: "neutral" | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "error";
|
|
8
|
+
children: JSXElement;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function Link<T extends ValidComponent = "a">(props: LinkProps<T>): import("solid-js").JSX.Element;
|
|
9
11
|
export default Link;
|
|
@@ -2,12 +2,24 @@ import { splitProps } from "solid-js";
|
|
|
2
2
|
import { Dynamic } from "solid-js/web";
|
|
3
3
|
import { tv } from "tailwind-variants";
|
|
4
4
|
const link = tv({
|
|
5
|
-
base: "
|
|
5
|
+
base: "link",
|
|
6
|
+
variants: {
|
|
7
|
+
appearance: {
|
|
8
|
+
neutral: "link-neutral",
|
|
9
|
+
primary: "link-primary",
|
|
10
|
+
secondary: "link-secondary",
|
|
11
|
+
accent: "link-accent",
|
|
12
|
+
info: "link-info",
|
|
13
|
+
success: "link-success",
|
|
14
|
+
warning: "link-warning",
|
|
15
|
+
error: "link-error",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
6
18
|
});
|
|
7
|
-
export
|
|
8
|
-
const [local, others] = splitProps(props, ["as", "
|
|
9
|
-
return (<Dynamic component={local.as ?? "a"} {...others} class={link({ class: local.class })}>
|
|
19
|
+
export function Link(props) {
|
|
20
|
+
const [local, others] = splitProps(props, ["as", "class", "children"]);
|
|
21
|
+
return (<Dynamic component={local.as ?? "a"} {...others} class={link({ class: local.class, appearance: props.appearance })}>
|
|
10
22
|
{local.children}
|
|
11
23
|
</Dynamic>);
|
|
12
|
-
}
|
|
24
|
+
}
|
|
13
25
|
export default Link;
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { ParentComponent } from "solid-js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
saveFunc?: () => Promise<void>;
|
|
5
|
-
zIndexClass?: string;
|
|
2
|
+
import { Dialog } from "@kobalte/core/dialog";
|
|
3
|
+
interface ModalProps {
|
|
6
4
|
title?: string;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
interface ModalComponents {
|
|
9
|
+
Trigger: typeof Dialog.Trigger;
|
|
10
|
+
Modal: ParentComponent<{
|
|
11
|
+
class?: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export declare const Modal: ParentComponent<ModalProps> & ModalComponents;
|
|
15
|
+
export declare const ModalContent: ParentComponent<{
|
|
16
|
+
class?: string;
|
|
17
|
+
}>;
|
|
9
18
|
export default Modal;
|
|
10
|
-
export declare function
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
export declare function useModal(): {
|
|
20
|
+
title?: string;
|
|
21
|
+
setOpen?: (v: boolean) => void;
|
|
13
22
|
};
|
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { useContext } from "solid-js";
|
|
2
|
+
import { Dialog } from "@kobalte/core/dialog";
|
|
3
|
+
import Close from "lucide-solid/icons/x";
|
|
4
|
+
import { tv } from "tailwind-variants";
|
|
4
5
|
import { Button } from "../Button";
|
|
5
6
|
import { ModalContext } from "./modalContext";
|
|
6
7
|
export const Modal = (props) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<div class="
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</
|
|
28
|
-
|
|
29
|
-
<Show when={props.saveFunc}>
|
|
30
|
-
<Button appearance="success" onClick={() => {
|
|
31
|
-
setLoading(true);
|
|
32
|
-
props.saveFunc()
|
|
33
|
-
.then(() => props.setModalVisible?.(false))
|
|
34
|
-
.finally(() => setLoading(false));
|
|
35
|
-
}} class="mt-3">
|
|
36
|
-
Save
|
|
37
|
-
</Button>
|
|
38
|
-
</Show>
|
|
8
|
+
return (<ModalContext.Provider value={{ title: props.title, setOpen: props.onOpenChange }}>
|
|
9
|
+
<Dialog open={props.open} onOpenChange={props.onOpenChange}>
|
|
10
|
+
{props.children}
|
|
11
|
+
</Dialog>
|
|
12
|
+
</ModalContext.Provider>);
|
|
13
|
+
};
|
|
14
|
+
const modalContent = tv({
|
|
15
|
+
base: "modal-box w-fit max-w-[90vw]",
|
|
16
|
+
});
|
|
17
|
+
export const ModalContent = (props) => {
|
|
18
|
+
const { title } = useModal();
|
|
19
|
+
return (<Dialog.Portal>
|
|
20
|
+
<div class="modal modal-open z-10">
|
|
21
|
+
<Dialog.Content class={modalContent({ class: props.class })}>
|
|
22
|
+
<div class="flex justify-between items-start">
|
|
23
|
+
{title && (<Dialog.Title>
|
|
24
|
+
<h3 class="font-bold text-lg mb-2">{title}</h3>
|
|
25
|
+
</Dialog.Title>)}
|
|
26
|
+
<Dialog.CloseButton as={Button} variant="ghost" modifier="square" size="xs">
|
|
27
|
+
<Close size={20}/>
|
|
28
|
+
</Dialog.CloseButton>
|
|
39
29
|
</div>
|
|
40
|
-
|
|
30
|
+
{props.children}
|
|
31
|
+
</Dialog.Content>
|
|
41
32
|
</div>
|
|
42
|
-
</Portal>);
|
|
33
|
+
</Dialog.Portal>);
|
|
43
34
|
};
|
|
35
|
+
Modal.Trigger = Dialog.Trigger;
|
|
36
|
+
Modal.Modal = ModalContent;
|
|
44
37
|
export default Modal;
|
|
45
|
-
export function
|
|
38
|
+
export function useModal() {
|
|
46
39
|
const context = useContext(ModalContext);
|
|
47
40
|
if (!context) {
|
|
48
|
-
throw new Error("
|
|
41
|
+
throw new Error("useModal must be used within a Modal");
|
|
49
42
|
}
|
|
50
43
|
return context;
|
|
51
44
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Accessor, Setter } from "solid-js";
|
|
2
1
|
type ModalContextType = {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
title?: string;
|
|
3
|
+
setOpen?: (v: boolean) => void;
|
|
5
4
|
};
|
|
6
5
|
export declare const ModalContext: import("solid-js").Context<ModalContextType | undefined>;
|
|
7
6
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ParentComponent } from "solid-js";
|
|
2
|
+
export interface NavbarProps {
|
|
3
|
+
class?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface NavbarComponents {
|
|
6
|
+
Brand: ParentComponent;
|
|
7
|
+
Profile: ParentComponent;
|
|
8
|
+
Menu: ParentComponent;
|
|
9
|
+
MenuItem: ParentComponent;
|
|
10
|
+
Submenu: ParentComponent<{
|
|
11
|
+
title: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export declare const Navbar: ParentComponent<NavbarProps> & NavbarComponents;
|
|
15
|
+
export declare const NavbarBrand: ParentComponent;
|
|
16
|
+
export declare const NavbarProfile: ParentComponent;
|
|
17
|
+
export declare const NavbarMenu: ParentComponent;
|
|
18
|
+
export declare const NavbarSubmenu: ParentComponent<{
|
|
19
|
+
title: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const NavbarMenuItem: ParentComponent;
|
|
22
|
+
export default Navbar;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DropdownMenu } from "@kobalte/core/dropdown-menu";
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
const navbar = tv({
|
|
4
|
+
base: "navbar bg-base-100 shadow-sm flex justify-between sticky top-0 z-10",
|
|
5
|
+
});
|
|
6
|
+
export const Navbar = (props) => {
|
|
7
|
+
return <nav class={navbar({ class: props.class })}>{props.children}</nav>;
|
|
8
|
+
};
|
|
9
|
+
export const NavbarBrand = (props) => {
|
|
10
|
+
return <div class="btn btn-lg btn-ghost">{props.children}</div>;
|
|
11
|
+
};
|
|
12
|
+
export const NavbarProfile = (props) => {
|
|
13
|
+
return <div class="avatar">{props.children}</div>;
|
|
14
|
+
};
|
|
15
|
+
export const NavbarMenu = (props) => {
|
|
16
|
+
return <ul class="menu menu-horizontal">{props.children}</ul>;
|
|
17
|
+
};
|
|
18
|
+
export const NavbarSubmenu = (props) => {
|
|
19
|
+
return (<DropdownMenu>
|
|
20
|
+
<DropdownMenu.Trigger as="details">
|
|
21
|
+
<summary>{props.title}</summary>
|
|
22
|
+
</DropdownMenu.Trigger>
|
|
23
|
+
<DropdownMenu.Portal>
|
|
24
|
+
<DropdownMenu.Content class="z-50">
|
|
25
|
+
<ul class="menu bg-base-100 shadow-sm rounded-box mt-2 border border-base-200">{props.children}</ul>
|
|
26
|
+
</DropdownMenu.Content>
|
|
27
|
+
</DropdownMenu.Portal>
|
|
28
|
+
</DropdownMenu>);
|
|
29
|
+
};
|
|
30
|
+
export const NavbarMenuItem = (props) => {
|
|
31
|
+
return <li>{props.children}</li>;
|
|
32
|
+
};
|
|
33
|
+
Navbar.Brand = NavbarBrand;
|
|
34
|
+
Navbar.Profile = NavbarProfile;
|
|
35
|
+
Navbar.Menu = NavbarMenu;
|
|
36
|
+
Navbar.MenuItem = NavbarMenuItem;
|
|
37
|
+
Navbar.Submenu = NavbarSubmenu;
|
|
38
|
+
export default Navbar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Navbar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Navbar";
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Component, ValidComponent } from "solid-js";
|
|
2
2
|
import { type NumberFieldInputProps, type NumberFieldRootProps } from "@kobalte/core/number-field";
|
|
3
3
|
import type { PolymorphicProps } from "@kobalte/core";
|
|
4
|
-
type
|
|
5
|
-
interface
|
|
4
|
+
export type NumberInputProps<T extends ValidComponent = "input"> = PolymorphicProps<T, NumberFieldInputProps<T>>;
|
|
5
|
+
export interface NumberInputExtraProps {
|
|
6
6
|
label?: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
variant?: "ghost";
|
|
8
|
+
appearance?: "neutral" | "primary" | "secondary" | "accent" | "info" | "success" | "warning" | "error";
|
|
9
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
10
|
+
inputProps?: NumberInputProps;
|
|
9
11
|
saveFunc?: (v: number) => Promise<any>;
|
|
10
12
|
}
|
|
11
|
-
type
|
|
12
|
-
export declare const NumberInput: Component<
|
|
13
|
+
export type NumberInputRootProps<T extends ValidComponent = "div"> = NumberInputExtraProps & PolymorphicProps<T, NumberFieldRootProps<T>>;
|
|
14
|
+
export declare const NumberInput: Component<NumberInputRootProps>;
|
|
13
15
|
export default NumberInput;
|
|
@@ -2,19 +2,64 @@ import { createMemo, Show, splitProps } from "solid-js";
|
|
|
2
2
|
import { NumberField, } from "@kobalte/core/number-field";
|
|
3
3
|
import { debounce } from "../../methods/debounce";
|
|
4
4
|
import { tv } from "tailwind-variants";
|
|
5
|
-
const inputRoot = tv({
|
|
6
|
-
|
|
5
|
+
const inputRoot = tv({
|
|
6
|
+
base: "relative flex flex-col gap-1",
|
|
7
|
+
});
|
|
8
|
+
const inputField = tv({
|
|
9
|
+
base: "input outline-offset-0 text-end font-semibold",
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
ghost: "input-ghost",
|
|
13
|
+
none: "",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
xs: "input-xs w-18",
|
|
17
|
+
sm: "input-sm w-20",
|
|
18
|
+
md: "input-md w-22",
|
|
19
|
+
lg: "input-lg w-24",
|
|
20
|
+
xl: "input-xl w-26",
|
|
21
|
+
},
|
|
22
|
+
appearance: {
|
|
23
|
+
neutral: "input-neutral",
|
|
24
|
+
primary: "input-primary",
|
|
25
|
+
secondary: "input-secondary",
|
|
26
|
+
accent: "input-accent",
|
|
27
|
+
info: "input-info",
|
|
28
|
+
success: "input-success",
|
|
29
|
+
warning: "input-warning",
|
|
30
|
+
error: "input-error",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
size: "sm",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
7
37
|
export const NumberInput = (props) => {
|
|
8
|
-
const [local, others] = splitProps(props, [
|
|
38
|
+
const [local, others] = splitProps(props, [
|
|
39
|
+
"label",
|
|
40
|
+
"class",
|
|
41
|
+
"inputProps",
|
|
42
|
+
"saveFunc",
|
|
43
|
+
"variant",
|
|
44
|
+
"appearance",
|
|
45
|
+
"size",
|
|
46
|
+
]);
|
|
9
47
|
const debouncedSave = createMemo(() => (local.saveFunc ? debounce(local.saveFunc) : undefined));
|
|
10
48
|
const handleChange = (v) => {
|
|
11
49
|
debouncedSave()?.(Number(v));
|
|
12
50
|
};
|
|
13
51
|
return (<NumberField {...others} onChange={handleChange} class={inputRoot({ class: local.class })}>
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
52
|
+
<NumberField.Label class="floating-label">
|
|
53
|
+
<Show when={local.label}>
|
|
54
|
+
<span>{local.label}</span>
|
|
55
|
+
</Show>
|
|
56
|
+
<NumberField.Input {...local.inputProps} class={inputField({
|
|
57
|
+
appearance: local.appearance,
|
|
58
|
+
variant: local.variant,
|
|
59
|
+
size: local.size,
|
|
60
|
+
class: local.inputProps?.class,
|
|
61
|
+
})}/>
|
|
62
|
+
</NumberField.Label>
|
|
18
63
|
</NumberField>);
|
|
19
64
|
};
|
|
20
65
|
export default NumberInput;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Accessor, Component } from "solid-js";
|
|
2
|
+
interface PaginationProps {
|
|
3
|
+
perPage: Accessor<number>;
|
|
4
|
+
perPageOptions: number[];
|
|
5
|
+
page: Accessor<number>;
|
|
6
|
+
totalItems: number;
|
|
7
|
+
onNextPage: () => void;
|
|
8
|
+
onPrevPage: () => void;
|
|
9
|
+
onPageChange: (page: number) => void;
|
|
10
|
+
onPerPageChange: (perPage: number) => void;
|
|
11
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const Pagination: Component<PaginationProps>;
|
|
15
|
+
export {};
|