@g4rcez/components 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/core/button.d.ts +77 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.jsx +79 -0
- package/dist/components/core/heading.d.ts +3 -0
- package/dist/components/core/heading.d.ts.map +1 -0
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/polymorph.d.ts +10 -0
- package/dist/components/core/polymorph.d.ts.map +1 -0
- package/dist/components/core/polymorph.jsx +5 -0
- package/dist/components/core/render-on-view.d.ts +7 -0
- package/dist/components/core/render-on-view.d.ts.map +1 -0
- package/dist/components/core/render-on-view.jsx +31 -0
- package/dist/components/core/resizable.d.ts +3 -0
- package/dist/components/core/resizable.d.ts.map +1 -0
- package/dist/components/core/resizable.jsx +51 -0
- package/dist/components/core/slot.d.ts +16 -0
- package/dist/components/core/slot.d.ts.map +1 -0
- package/dist/components/core/slot.jsx +156 -0
- package/dist/components/core/tag.d.ts +35 -0
- package/dist/components/core/tag.d.ts.map +1 -0
- package/dist/components/core/tag.jsx +53 -0
- package/dist/components/core/typography.d.ts +25 -0
- package/dist/components/core/typography.d.ts.map +1 -0
- package/dist/components/core/typography.jsx +20 -0
- package/dist/components/display/alert.d.ts +28 -0
- package/dist/components/display/alert.d.ts.map +1 -0
- package/dist/components/display/alert.jsx +61 -0
- package/dist/components/display/calendar.d.ts +42 -0
- package/dist/components/display/calendar.d.ts.map +1 -0
- package/dist/components/display/calendar.jsx +318 -0
- package/dist/components/display/card.d.ts +29 -0
- package/dist/components/display/card.d.ts.map +1 -0
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +8 -0
- package/dist/components/display/empty.d.ts.map +1 -0
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +16 -0
- package/dist/components/display/list.d.ts.map +1 -0
- package/dist/components/display/list.jsx +85 -0
- package/dist/components/display/notifications.d.ts +27 -0
- package/dist/components/display/notifications.d.ts.map +1 -0
- package/dist/components/display/notifications.jsx +130 -0
- package/dist/components/display/progress.d.ts +16 -0
- package/dist/components/display/progress.d.ts.map +1 -0
- package/dist/components/display/progress.jsx +21 -0
- package/dist/components/display/shortcut.d.ts +4 -0
- package/dist/components/display/shortcut.d.ts.map +1 -0
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +12 -0
- package/dist/components/display/skeleton.d.ts.map +1 -0
- package/dist/components/display/skeleton.jsx +19 -0
- package/dist/components/display/spinner.d.ts +5 -0
- package/dist/components/display/spinner.d.ts.map +1 -0
- package/dist/components/display/spinner.jsx +11 -0
- package/dist/components/display/stats.d.ts +12 -0
- package/dist/components/display/stats.d.ts.map +1 -0
- package/dist/components/display/stats.jsx +16 -0
- package/dist/components/display/step.d.ts +24 -0
- package/dist/components/display/step.d.ts.map +1 -0
- package/dist/components/display/step.jsx +145 -0
- package/dist/components/display/tabs.d.ts +24 -0
- package/dist/components/display/tabs.d.ts.map +1 -0
- package/dist/components/display/tabs.jsx +125 -0
- package/dist/components/display/timeline.d.ts +10 -0
- package/dist/components/display/timeline.d.ts.map +1 -0
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +49 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -0
- package/dist/components/floating/command-palette.jsx +223 -0
- package/dist/components/floating/dropdown.d.ts +15 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -0
- package/dist/components/floating/dropdown.jsx +56 -0
- package/dist/components/floating/expand.d.ts +11 -0
- package/dist/components/floating/expand.d.ts.map +1 -0
- package/dist/components/floating/expand.jsx +44 -0
- package/dist/components/floating/menu.d.ts +52 -0
- package/dist/components/floating/menu.d.ts.map +1 -0
- package/dist/components/floating/menu.jsx +165 -0
- package/dist/components/floating/modal.d.ts +60 -0
- package/dist/components/floating/modal.d.ts.map +1 -0
- package/dist/components/floating/modal.jsx +336 -0
- package/dist/components/floating/toolbar.d.ts +6 -0
- package/dist/components/floating/toolbar.d.ts.map +1 -0
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/tooltip.d.ts +17 -0
- package/dist/components/floating/tooltip.d.ts.map +1 -0
- package/dist/components/floating/tooltip.jsx +67 -0
- package/dist/components/floating/wizard.d.ts +26 -0
- package/dist/components/floating/wizard.d.ts.map +1 -0
- package/dist/components/floating/wizard.jsx +165 -0
- package/dist/components/form/autocomplete.d.ts +16 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -0
- package/dist/components/form/autocomplete.jsx +290 -0
- package/dist/components/form/checkbox.d.ts +12 -0
- package/dist/components/form/checkbox.d.ts.map +1 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/date-picker.d.ts +10 -0
- package/dist/components/form/date-picker.d.ts.map +1 -0
- package/dist/components/form/date-picker.jsx +115 -0
- package/dist/components/form/file-upload.d.ts +15 -0
- package/dist/components/form/file-upload.d.ts.map +1 -0
- package/dist/components/form/file-upload.jsx +138 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.jsx +10 -0
- package/dist/components/form/formReset.d.ts +2 -0
- package/dist/components/form/formReset.d.ts.map +1 -0
- package/dist/components/form/formReset.jsx +17 -0
- package/dist/components/form/free-text.d.ts +11 -0
- package/dist/components/form/free-text.d.ts.map +1 -0
- package/dist/components/form/free-text.jsx +41 -0
- package/dist/components/form/input-field.d.ts +34 -0
- package/dist/components/form/input-field.d.ts.map +1 -0
- package/dist/components/form/input-field.jsx +58 -0
- package/dist/components/form/input.d.ts +52 -0
- package/dist/components/form/input.d.ts.map +1 -0
- package/dist/components/form/input.jsx +36 -0
- package/dist/components/form/multi-select.d.ts +19 -0
- package/dist/components/form/multi-select.d.ts.map +1 -0
- package/dist/components/form/multi-select.jsx +344 -0
- package/dist/components/form/radiobox.d.ts +7 -0
- package/dist/components/form/radiobox.d.ts.map +1 -0
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.d.ts +13 -0
- package/dist/components/form/select.d.ts.map +1 -0
- package/dist/components/form/select.jsx +44 -0
- package/dist/components/form/slider.d.ts +7 -0
- package/dist/components/form/slider.d.ts.map +1 -0
- package/dist/components/form/slider.jsx +45 -0
- package/dist/components/form/switch.d.ts +9 -0
- package/dist/components/form/switch.d.ts.map +1 -0
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +3 -0
- package/dist/components/form/task-list.d.ts.map +1 -0
- package/dist/components/form/task-list.jsx +26 -0
- package/dist/components/form/textarea.d.ts +5 -0
- package/dist/components/form/textarea.d.ts.map +1 -0
- package/dist/components/form/textarea.jsx +26 -0
- package/dist/components/index.d.ts +45 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +44 -0
- package/dist/components/page-calendar/calendar-header.d.ts +16 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
- package/dist/components/page-calendar/calendar-header.jsx +83 -0
- package/dist/components/page-calendar/day-view.d.ts +12 -0
- package/dist/components/page-calendar/day-view.d.ts.map +1 -0
- package/dist/components/page-calendar/day-view.jsx +89 -0
- package/dist/components/page-calendar/event-pill.d.ts +9 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.d.ts +4 -0
- package/dist/components/page-calendar/index.d.ts.map +1 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.d.ts +11 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +46 -0
- package/dist/components/page-calendar/page-calendar.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts +24 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +93 -0
- package/dist/components/page-calendar/week-view.d.ts +11 -0
- package/dist/components/page-calendar/week-view.d.ts.map +1 -0
- package/dist/components/page-calendar/week-view.jsx +66 -0
- package/dist/components/table/filter.d.ts +42 -0
- package/dist/components/table/filter.d.ts.map +1 -0
- package/dist/components/table/filter.jsx +169 -0
- package/dist/components/table/group.d.ts +17 -0
- package/dist/components/table/group.d.ts.map +1 -0
- package/dist/components/table/group.jsx +75 -0
- package/dist/components/table/index.d.ts +19 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.jsx +63 -0
- package/dist/components/table/inner-table.d.ts +29 -0
- package/dist/components/table/inner-table.d.ts.map +1 -0
- package/dist/components/table/inner-table.jsx +102 -0
- package/dist/components/table/metadata.d.ts +4 -0
- package/dist/components/table/metadata.d.ts.map +1 -0
- package/dist/components/table/metadata.jsx +36 -0
- package/dist/components/table/pagination.d.ts +5 -0
- package/dist/components/table/pagination.d.ts.map +1 -0
- package/dist/components/table/pagination.jsx +74 -0
- package/dist/components/table/row.d.ts +11 -0
- package/dist/components/table/row.d.ts.map +1 -0
- package/dist/components/table/row.jsx +49 -0
- package/dist/components/table/sort.d.ts +28 -0
- package/dist/components/table/sort.d.ts.map +1 -0
- package/dist/components/table/sort.jsx +109 -0
- package/dist/components/table/table-lib.d.ts +135 -0
- package/dist/components/table/table-lib.d.ts.map +1 -0
- package/dist/components/table/table-lib.js +83 -0
- package/dist/components/table/table.context.d.ts +10 -0
- package/dist/components/table/table.context.d.ts.map +1 -0
- package/dist/components/table/table.context.jsx +5 -0
- package/dist/components/table/thead.d.ts +9 -0
- package/dist/components/table/thead.d.ts.map +1 -0
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/context.d.ts +21 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +12 -0
- package/dist/config/default-translations.d.ts +94 -0
- package/dist/config/default-translations.d.ts.map +1 -0
- package/dist/config/default-translations.jsx +87 -0
- package/dist/config/default-tweaks.d.ts +13 -0
- package/dist/config/default-tweaks.d.ts.map +1 -0
- package/dist/config/default-tweaks.js +4 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/hooks/use-click-outside.d.ts +3 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-click-outside.js +17 -0
- package/dist/hooks/use-color-parser.d.ts +2 -0
- package/dist/hooks/use-color-parser.d.ts.map +1 -0
- package/dist/hooks/use-color-parser.js +9 -0
- package/dist/hooks/use-components-provider.d.ts +15 -0
- package/dist/hooks/use-components-provider.d.ts.map +1 -0
- package/dist/hooks/use-components-provider.jsx +22 -0
- package/dist/hooks/use-debounce.d.ts +5 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +12 -0
- package/dist/hooks/use-floating-ref.d.ts +2 -0
- package/dist/hooks/use-floating-ref.d.ts.map +1 -0
- package/dist/hooks/use-floating-ref.js +6 -0
- package/dist/hooks/use-form.d.ts +394 -0
- package/dist/hooks/use-form.d.ts.map +1 -0
- package/dist/hooks/use-form.js +563 -0
- package/dist/hooks/use-hover.d.ts +3 -0
- package/dist/hooks/use-hover.d.ts.map +1 -0
- package/dist/hooks/use-hover.js +18 -0
- package/dist/hooks/use-input-id.d.ts +4 -0
- package/dist/hooks/use-input-id.d.ts.map +1 -0
- package/dist/hooks/use-input-id.js +5 -0
- package/dist/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/hooks/use-is-coarse-device.js +12 -0
- package/dist/hooks/use-locale.d.ts +3 -0
- package/dist/hooks/use-locale.d.ts.map +1 -0
- package/dist/hooks/use-locale.js +10 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-on-event.d.ts +4 -0
- package/dist/hooks/use-on-event.d.ts.map +1 -0
- package/dist/hooks/use-on-event.js +10 -0
- package/dist/hooks/use-parent.d.ts +3 -0
- package/dist/hooks/use-parent.d.ts.map +1 -0
- package/dist/hooks/use-parent.js +21 -0
- package/dist/hooks/use-preferences.d.ts +2 -0
- package/dist/hooks/use-preferences.d.ts.map +1 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/hooks/use-previous.d.ts +2 -0
- package/dist/hooks/use-previous.d.ts.map +1 -0
- package/dist/hooks/use-previous.js +9 -0
- package/dist/hooks/use-reactive.d.ts +2 -0
- package/dist/hooks/use-reactive.d.ts.map +1 -0
- package/dist/hooks/use-reactive.js +9 -0
- package/dist/hooks/use-remove-scroll.d.ts +4 -0
- package/dist/hooks/use-remove-scroll.d.ts.map +1 -0
- package/dist/hooks/use-remove-scroll.js +48 -0
- package/dist/hooks/use-resize-observer.d.ts +2 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-stable-ref.d.ts +2 -0
- package/dist/hooks/use-stable-ref.d.ts.map +1 -0
- package/dist/hooks/use-stable-ref.js +9 -0
- package/dist/hooks/use-swipe.d.ts +8 -0
- package/dist/hooks/use-swipe.d.ts.map +1 -0
- package/dist/hooks/use-swipe.js +17 -0
- package/dist/hooks/use-translations.d.ts +92 -0
- package/dist/hooks/use-translations.d.ts.map +1 -0
- package/dist/hooks/use-translations.js +9 -0
- package/dist/hooks/use-tweaks.d.ts +3 -0
- package/dist/hooks/use-tweaks.d.ts.map +1 -0
- package/dist/hooks/use-tweaks.js +9 -0
- package/dist/hooks/use-window-size.d.ts +5 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -7932
- package/dist/lib/combi-keys.d.ts +15 -0
- package/dist/lib/combi-keys.d.ts.map +1 -0
- package/dist/lib/combi-keys.js +60 -0
- package/dist/lib/dict.d.ts +9 -0
- package/dist/lib/dict.d.ts.map +1 -0
- package/dist/lib/dict.js +28 -0
- package/dist/lib/dom.d.ts +20 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +185 -0
- package/dist/lib/fns.d.ts +11 -0
- package/dist/lib/fns.d.ts.map +1 -0
- package/dist/lib/fns.js +46 -0
- package/dist/lib/fzf.d.ts +16 -0
- package/dist/lib/fzf.d.ts.map +1 -0
- package/dist/lib/fzf.js +115 -0
- package/dist/lib/keyboard-area.d.ts +16 -0
- package/dist/lib/keyboard-area.d.ts.map +1 -0
- package/dist/lib/keyboard-area.js +14 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
import { LocalStorage } from "storage-manager-js";
|
|
4
|
+
import { useReducer } from "use-typed-reducer";
|
|
5
|
+
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
6
|
+
import { isSsr } from "../../lib/fns";
|
|
7
|
+
export const getLabel = (col) => col.headerLabel ?? col.thead ?? col.id;
|
|
8
|
+
export const createOptionCols = (cols) => cols.map((opt) => ({
|
|
9
|
+
value: opt.id,
|
|
10
|
+
label: (opt.thead ?? opt.headerLabel ?? opt.id),
|
|
11
|
+
}));
|
|
12
|
+
export var ColType;
|
|
13
|
+
(function (ColType) {
|
|
14
|
+
ColType["Boolean"] = "boolean";
|
|
15
|
+
ColType["Number"] = "number";
|
|
16
|
+
ColType["Select"] = "select";
|
|
17
|
+
ColType["Text"] = "text";
|
|
18
|
+
})(ColType || (ColType = {}));
|
|
19
|
+
export const valueFromType = (input) => (input.type === "number" ? input.valueAsNumber : input.value);
|
|
20
|
+
const cols = () => (id, thead, options) => ({ ...options, id, thead });
|
|
21
|
+
export const createColumns = (callback) => {
|
|
22
|
+
let items = [];
|
|
23
|
+
const add = (id, thead, options) => items.push({ ...options, id, thead });
|
|
24
|
+
const remove = (id) => (items = items.filter((x) => x.id !== id));
|
|
25
|
+
const getAll = () => Array.from(items);
|
|
26
|
+
const filter = (c) => (items = Array.from(items.filter(c)));
|
|
27
|
+
callback({ add, remove, getAll, filter });
|
|
28
|
+
return items;
|
|
29
|
+
};
|
|
30
|
+
const noop = {};
|
|
31
|
+
const mergeCols = (cols, saved) => {
|
|
32
|
+
if (!Array.isArray(saved))
|
|
33
|
+
return cols;
|
|
34
|
+
const savedSet = new Set(saved.map((x) => x.id));
|
|
35
|
+
if (!cols.every((x) => savedSet.has(x.id))) {
|
|
36
|
+
return cols;
|
|
37
|
+
}
|
|
38
|
+
const map = new Map(cols.map((x) => [x.id, x]));
|
|
39
|
+
return saved.map((mock, index) => {
|
|
40
|
+
const original = map.get(mock.id);
|
|
41
|
+
if (original === undefined)
|
|
42
|
+
return cols[index];
|
|
43
|
+
return original;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export const useTablePreferences = (name, cols, options = noop) => {
|
|
47
|
+
const init = isSsr() ? null : LocalStorage.get(`@components/table-${name}`) || null;
|
|
48
|
+
const [state, dispatch] = useReducer({
|
|
49
|
+
name,
|
|
50
|
+
groups: options.groups || init?.groups || [],
|
|
51
|
+
sorters: options.sorters || init?.sorters || [],
|
|
52
|
+
filters: options.filters || init?.filters || [],
|
|
53
|
+
cols: mergeCols(cols, init?.cols),
|
|
54
|
+
}, (get) => {
|
|
55
|
+
const intercept = (partial) => {
|
|
56
|
+
const prev = get.state();
|
|
57
|
+
const result = { ...prev, ...partial };
|
|
58
|
+
if (!isSsr())
|
|
59
|
+
LocalStorage.set(`@components/table-${prev.name}`, result);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
intercept(get.state());
|
|
63
|
+
return {
|
|
64
|
+
set: (getters) => intercept(getters),
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return { ...state, ...dispatch, name };
|
|
68
|
+
};
|
|
69
|
+
export const useWidthControl = (reorder) => {
|
|
70
|
+
const stableRef = useStableRef(reorder);
|
|
71
|
+
const ref = useRef(null);
|
|
72
|
+
const onChange = useCallback((cols) => {
|
|
73
|
+
stableRef.current(cols);
|
|
74
|
+
cols.forEach((x) => {
|
|
75
|
+
const c = ref.current.querySelector(`th[data-tableheader="${x.id}"]`);
|
|
76
|
+
if (!c)
|
|
77
|
+
return;
|
|
78
|
+
c.style.width = "auto";
|
|
79
|
+
});
|
|
80
|
+
}, [stableRef]);
|
|
81
|
+
return [ref, onChange];
|
|
82
|
+
};
|
|
83
|
+
export const getModalScrollerRef = () => (isSsr() ? undefined : document.querySelector(`[data-component="modal-body"]`));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TableContextProps = Partial<{
|
|
2
|
+
sticky: number;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const TableProvider: import("react").Provider<Partial<{
|
|
5
|
+
sticky: number;
|
|
6
|
+
}>>;
|
|
7
|
+
export declare const useTable: () => Partial<{
|
|
8
|
+
sticky: number;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=table.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.context.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.context.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAI5D,eAAO,MAAM,aAAa;YAJwB,MAAM;GAIN,CAAC;AAEnD,eAAO,MAAM,QAAQ;YAN6B,MAAM;EAMF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Col, TableOperationProps } from "./table-lib";
|
|
3
|
+
type TableHeaderProps<T extends object> = {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
headers: Col<T>[];
|
|
6
|
+
} & Pick<TableOperationProps<T>, "filters" | "setFilters" | "setCols" | "setSorters" | "sorters" | "inlineSorter" | "inlineFilter">;
|
|
7
|
+
export declare const TableHeader: <T extends object>(props: TableHeaderProps<T>) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=thead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thead.d.ts","sourceRoot":"","sources":["../../../src/components/table/thead.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAM7D,OAAO,EAAE,GAAG,EAAY,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAIlF,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;CACrB,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,cAAc,GAAG,cAAc,CAAC,CAAC;AAmKpI,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,gBAAgB,CAAC,CAAC,CAAC,sBAuBvE,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AnimatePresence, motion, Reorder } from "motion/react";
|
|
3
|
+
import { Order } from "linq-arrays";
|
|
4
|
+
import { PlusIcon, MagnifyingGlassIcon, MagnifyingGlassMinusIcon } from "@phosphor-icons/react";
|
|
5
|
+
import React, { Fragment, useCallback, useRef } from "react";
|
|
6
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
7
|
+
import { useTweaks } from "../../hooks/use-tweaks";
|
|
8
|
+
import { Dropdown } from "../floating/dropdown";
|
|
9
|
+
import { ColumnHeaderFilter, createFilterFromCol, useOperators } from "./filter";
|
|
10
|
+
import { SorterHead } from "./sort";
|
|
11
|
+
import { getLabel, useWidthControl } from "./table-lib";
|
|
12
|
+
const dragConstraints = { top: 0, left: 0, right: 0, bottom: -1 };
|
|
13
|
+
const HeaderChild = (props) => {
|
|
14
|
+
const tweaks = useTweaks();
|
|
15
|
+
const translation = useTranslations();
|
|
16
|
+
const ownFilters = props.filters.filter((x) => x.name === props.header.id);
|
|
17
|
+
const hasFilters = ownFilters.length > 0;
|
|
18
|
+
const defaultAllowSort = props.header.allowSort ?? tweaks.table.sorters ?? true;
|
|
19
|
+
const defaultAllowFilter = props.header.allowFilter ?? tweaks.table.filters ?? true;
|
|
20
|
+
const operators = useOperators();
|
|
21
|
+
const FilterIcon = hasFilters ? MagnifyingGlassIcon : MagnifyingGlassMinusIcon;
|
|
22
|
+
const th = useRef(null);
|
|
23
|
+
const onDelete = (e) => {
|
|
24
|
+
const id = e.currentTarget.dataset.id || "";
|
|
25
|
+
return props.setFilters((prev) => prev.filter((x) => x.id !== id));
|
|
26
|
+
};
|
|
27
|
+
const dragRef = useCallback((dom) => {
|
|
28
|
+
if (dom === null)
|
|
29
|
+
return;
|
|
30
|
+
th.current = dom;
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
dom.addEventListener("pointerdown", (e) => {
|
|
33
|
+
const target = e.target;
|
|
34
|
+
if (target.dataset.type === "resizer") {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
return e.stopImmediatePropagation();
|
|
37
|
+
}
|
|
38
|
+
}, { signal: controller.signal });
|
|
39
|
+
return () => controller.abort();
|
|
40
|
+
}, []);
|
|
41
|
+
const ownSorter = props.sorters.find((x) => props.header.id === x.value);
|
|
42
|
+
const ariaSort = !ownSorter?.type ? "none" : ownSorter.type === Order.Asc ? "ascending" : "descending";
|
|
43
|
+
const label = getLabel(props.header);
|
|
44
|
+
return (<Reorder.Item {...props.header.thProps} as="th" ref={dragRef} initial={false} dragSnapToOrigin dragDirectionLock role="columnheader" aria-sort={ariaSort} value={props.header} aria-busy={props.loading} data-tableheader={props.header.id} whileDrag={{ cursor: "grabbing" }} className={`typography relative min-w-0 cursor-grab overflow-clip border-r-table-cell-border border-table-border bg-table-header font-medium first:rounded-tl-table-radius last:rounded-tr-table-radius last:border-r-transparent md:h-14 ${props.header.thProps?.className ?? ""}`}>
|
|
45
|
+
<span className={`flex h-full items-center justify-between bg-table-header p-table-cell-padding ${props.isLast ? "rounded-tr-table-radius" : ""} ${props.index === 0 ? "rounded-tl-table-radius" : ""}`}>
|
|
46
|
+
<span className="flex items-center gap-table-inline-gap-tight">
|
|
47
|
+
{props.inlineFilter && defaultAllowFilter ? (<Dropdown arrow trigger={<span>
|
|
48
|
+
<span id={`${props.header.id}-filter-dropdown-button`} className="sr-only">
|
|
49
|
+
{translation.tableFilterDropdownTitleUnique} {label}
|
|
50
|
+
</span>
|
|
51
|
+
<FilterIcon aria-labelledby={`${props.header.id}-filter-dropdown-button`} size={14}/>
|
|
52
|
+
</span>} title={<span className="text-typography-lg">
|
|
53
|
+
{translation.tableFilterDropdownTitleUnique} <span className="font-medium">{label}</span>
|
|
54
|
+
</span>}>
|
|
55
|
+
<ul className="font-medium">
|
|
56
|
+
{ownFilters.length === 0 ? null : (<Fragment>
|
|
57
|
+
{ownFilters.map((filter) => (<li key={`thead-filter-${filter.id}`} className="my-1">
|
|
58
|
+
<ColumnHeaderFilter onDelete={onDelete} filter={filter} set={props.setFilters}/>
|
|
59
|
+
</li>))}
|
|
60
|
+
</Fragment>)}
|
|
61
|
+
<li>
|
|
62
|
+
<button type="button" className="flex items-center gap-table-inline-gap-tight text-primary" onClick={() => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header, operators.options, operators.operations)))}>
|
|
63
|
+
<PlusIcon size={14}/> {translation.tableFilterNewFilter}
|
|
64
|
+
</button>
|
|
65
|
+
</li>
|
|
66
|
+
</ul>
|
|
67
|
+
</Dropdown>) : null}
|
|
68
|
+
<span className="text-typography-base pointer-events-auto text-balance">{props.header.thead}</span>
|
|
69
|
+
{props.inlineSorter && defaultAllowSort ? (<SorterHead col={props.header} setSorters={props.setSorters} sorters={props.sorters}/>) : null}
|
|
70
|
+
</span>
|
|
71
|
+
</span>
|
|
72
|
+
{props.isLast ? null : (<motion.button drag="x" draggable dragListener dragMomentum type="button" animate={false} dragElastic={0} dragPropagation initial={false} dragSnapToOrigin dragDirectionLock data-type="resizer" title={props.header.id} dragConstraints={dragConstraints} className="absolute -right-[0.5px] top-0 z-calendar block h-full w-table-divider-w cursor-col-resize bg-transparent hover:w-1.5 hover:bg-primary active:w-1.5 active:bg-primary" onClick={(e) => void e.currentTarget.focus()} onKeyDown={(e) => {
|
|
73
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
74
|
+
if (th.current === null)
|
|
75
|
+
return;
|
|
76
|
+
th.current.setAttribute("data-resized", "true");
|
|
77
|
+
const v = th.current.getBoundingClientRect().width;
|
|
78
|
+
const move = e.shiftKey ? 50 : 10;
|
|
79
|
+
const delta = move * (e.key === "ArrowLeft" ? -1 : 1);
|
|
80
|
+
th.current.style.width = `${Math.abs(v + delta)}px`;
|
|
81
|
+
}
|
|
82
|
+
}} onDoubleClick={() => {
|
|
83
|
+
if (th.current === null)
|
|
84
|
+
return;
|
|
85
|
+
th.current.style.width = "auto";
|
|
86
|
+
}} onDrag={(_, info) => {
|
|
87
|
+
if (th.current === null)
|
|
88
|
+
return;
|
|
89
|
+
th.current.setAttribute("data-resized", "true");
|
|
90
|
+
const v = th.current.getBoundingClientRect().width;
|
|
91
|
+
const delta = info.delta.x;
|
|
92
|
+
th.current.style.width = `${Math.abs(v + delta)}px`;
|
|
93
|
+
}}/>)}
|
|
94
|
+
</Reorder.Item>);
|
|
95
|
+
};
|
|
96
|
+
export const TableHeader = (props) => {
|
|
97
|
+
const [ref, onChange] = useWidthControl(props.setCols);
|
|
98
|
+
return (<Reorder.Group layout as="tr" axis="x" drag="x" ref={ref} layoutRoot role="row" layoutScroll onReorder={onChange} values={props.headers}>
|
|
99
|
+
<AnimatePresence>
|
|
100
|
+
{props.headers.map((header, index) => (<HeaderChild index={index} header={header} filters={props.filters} loading={props.loading} sorters={props.sorters} setFilters={props.setFilters} setSorters={props.setSorters} inlineFilter={props.inlineFilter} inlineSorter={props.inlineSorter} isLast={index === props.headers.length - 1} key={`header-child-item-${header.id}`}/>))}
|
|
101
|
+
</AnimatePresence>
|
|
102
|
+
</Reorder.Group>);
|
|
103
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IconProps } from "@phosphor-icons/react";
|
|
2
|
+
import type { Locales } from "the-mask-input";
|
|
3
|
+
import { parsers } from "../styles/design-tokens";
|
|
4
|
+
import { type Translations } from "./default-translations";
|
|
5
|
+
import { type Tweaks } from "./default-tweaks";
|
|
6
|
+
export type ContextProps = Partial<{
|
|
7
|
+
tweaks: Partial<Tweaks>;
|
|
8
|
+
map: Partial<Translations>;
|
|
9
|
+
locale: Locales | undefined;
|
|
10
|
+
parser: typeof parsers.hsla;
|
|
11
|
+
rootFloating?: HTMLElement | null;
|
|
12
|
+
iconWeight: IconProps["weight"];
|
|
13
|
+
}>;
|
|
14
|
+
export declare const Context: import("react").Context<Partial<{
|
|
15
|
+
tweaks: Tweaks;
|
|
16
|
+
map: Translations;
|
|
17
|
+
locale: Locales | undefined;
|
|
18
|
+
parser: typeof parsers.hsla;
|
|
19
|
+
floatingRef?: HTMLElement | null;
|
|
20
|
+
}>>;
|
|
21
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/config/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CACnC,CAAC,CAAC;AAEH,eAAO,MAAM,OAAO;;;;;;GAMlB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import { parsers } from "../styles/design-tokens";
|
|
4
|
+
import { defaultTranslations } from "./default-translations";
|
|
5
|
+
import { defaultTweaks } from "./default-tweaks";
|
|
6
|
+
export const Context = createContext({
|
|
7
|
+
parser: parsers.hsla,
|
|
8
|
+
tweaks: defaultTweaks,
|
|
9
|
+
floatingRef: undefined,
|
|
10
|
+
map: defaultTranslations,
|
|
11
|
+
locale: undefined,
|
|
12
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const defaultTranslations: {
|
|
3
|
+
autocompleteEmpty: string;
|
|
4
|
+
calendarBackMonth: string;
|
|
5
|
+
calendarFromDate: string;
|
|
6
|
+
calendarMonthLabel: string;
|
|
7
|
+
calendarNextMonth: string;
|
|
8
|
+
calendarDatetimeTitle: string;
|
|
9
|
+
calendarToDate: string;
|
|
10
|
+
calendarToday: string;
|
|
11
|
+
pageCalendarMonthView: string;
|
|
12
|
+
pageCalendarWeekView: string;
|
|
13
|
+
pageCalendarDayView: string;
|
|
14
|
+
pageCalendarPrevious: string;
|
|
15
|
+
pageCalendarNext: string;
|
|
16
|
+
pageCalendarToday: string;
|
|
17
|
+
pageCalendarAddEvent: string;
|
|
18
|
+
pageCalendarWeekLabel: (n: number) => string;
|
|
19
|
+
pageCalendarFilter: string;
|
|
20
|
+
pageCalendarMoreEvents: (n: number) => string;
|
|
21
|
+
pageCalendarLabel: string;
|
|
22
|
+
pageCalendarNavigation: string;
|
|
23
|
+
pageCalendarMonthGrid: string;
|
|
24
|
+
pageCalendarFilterEnabled: string;
|
|
25
|
+
pageCalendarFilterDisabled: string;
|
|
26
|
+
pageCalendarEventCount: (n: number) => string;
|
|
27
|
+
pageCalendarEventAt: (title: string, time: string) => string;
|
|
28
|
+
commandPaletteEmpty: string;
|
|
29
|
+
commandPaletteLoading: string;
|
|
30
|
+
datePickerCalendarButtonLabel: string;
|
|
31
|
+
emptyDataMessage: string;
|
|
32
|
+
inputCaretDown: string;
|
|
33
|
+
inputCloseValue: string;
|
|
34
|
+
inputOptionalLabel: string;
|
|
35
|
+
wizardNext: string;
|
|
36
|
+
wizardPrev: string;
|
|
37
|
+
wizardFinish: string;
|
|
38
|
+
wizardSkip: string;
|
|
39
|
+
multiSelectInnerPlaceholder: string;
|
|
40
|
+
multiSelectSelectedLabel: string;
|
|
41
|
+
tableColumnResizer: string;
|
|
42
|
+
tableFilterColumnPlaceholder: string;
|
|
43
|
+
tableFilterColumnTitle: string;
|
|
44
|
+
tableFilterDropdownTitle: string;
|
|
45
|
+
tableFilterDropdownTitleUnique: string;
|
|
46
|
+
tableFilterLabel: string;
|
|
47
|
+
tableFilterNewFilter: string;
|
|
48
|
+
tableFilterOperatorPlaceholder: string;
|
|
49
|
+
tableFilterOperatorTitle: string;
|
|
50
|
+
tableFilterTypeContains: string;
|
|
51
|
+
tableFilterTypeEndsWith: string;
|
|
52
|
+
tableFilterTypeGreaterThan: string;
|
|
53
|
+
tableFilterTypeIs: string;
|
|
54
|
+
tableFilterTypeIsNot: string;
|
|
55
|
+
tableFilterTypeLessThan: string;
|
|
56
|
+
tableFilterTypeNotContains: string;
|
|
57
|
+
tableFilterTypeStartsWith: string;
|
|
58
|
+
tableFilterValuePlaceholder: string;
|
|
59
|
+
tableFilterValueTitle: string;
|
|
60
|
+
tableGroupLabel: string;
|
|
61
|
+
tableGroupLabelWithCount: string;
|
|
62
|
+
tablePaginationFooter: (pagination: {
|
|
63
|
+
pages: number;
|
|
64
|
+
totalItems: number;
|
|
65
|
+
sizes?: number[];
|
|
66
|
+
current: number;
|
|
67
|
+
select: React.ReactNode;
|
|
68
|
+
}) => React.JSX.Element;
|
|
69
|
+
tablePaginationNext: string;
|
|
70
|
+
tablePaginationPrevious: string;
|
|
71
|
+
tablePaginationSelectLabel: string;
|
|
72
|
+
tableSortAddButton: string;
|
|
73
|
+
tableSortAsc: string;
|
|
74
|
+
tableSortDesc: string;
|
|
75
|
+
tableSortDropdownTitle: string;
|
|
76
|
+
tableSortOrderByLabel: string;
|
|
77
|
+
tableSortOrderInputPlaceholder: string;
|
|
78
|
+
tableSortOrderInputTitle: string;
|
|
79
|
+
tableSortTypeInputPlaceholder: string;
|
|
80
|
+
tableSortTypeInputTitle: string;
|
|
81
|
+
uploadIdle: string;
|
|
82
|
+
uploadIdleButton: string;
|
|
83
|
+
uploadDragging: (props: {
|
|
84
|
+
n: number;
|
|
85
|
+
}) => string;
|
|
86
|
+
uploadDialogTitle: string;
|
|
87
|
+
datepickerPlaceholder: (_: string) => string;
|
|
88
|
+
spinnerLoading: string;
|
|
89
|
+
skeletonLoading: string;
|
|
90
|
+
closeButton: string;
|
|
91
|
+
fileUploadZoneLabel: string;
|
|
92
|
+
};
|
|
93
|
+
export type Translations = typeof defaultTranslations;
|
|
94
|
+
//# sourceMappingURL=default-translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-translations.d.ts","sourceRoot":"","sources":["../../src/config/default-translations.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;+BAgBD,MAAM;;gCAEL,MAAM;;;;;;gCAMN,MAAM;iCACL,MAAM,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAmCb;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;;;;;;;;;;;;4BAqB7G;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE;;+BAGV,MAAM;;;;;CAKpC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
export const defaultTranslations = {
|
|
3
|
+
autocompleteEmpty: "Nothing here...",
|
|
4
|
+
calendarBackMonth: "Back month",
|
|
5
|
+
calendarFromDate: "From",
|
|
6
|
+
calendarMonthLabel: "Month",
|
|
7
|
+
calendarNextMonth: "Next month",
|
|
8
|
+
calendarDatetimeTitle: "Time",
|
|
9
|
+
calendarToDate: "To",
|
|
10
|
+
calendarToday: "Today",
|
|
11
|
+
pageCalendarMonthView: "Month view",
|
|
12
|
+
pageCalendarWeekView: "Week view",
|
|
13
|
+
pageCalendarDayView: "Day view",
|
|
14
|
+
pageCalendarPrevious: "Previous",
|
|
15
|
+
pageCalendarNext: "Next",
|
|
16
|
+
pageCalendarToday: "Today",
|
|
17
|
+
pageCalendarAddEvent: "Add event",
|
|
18
|
+
pageCalendarWeekLabel: (n) => `Week ${n}`,
|
|
19
|
+
pageCalendarFilter: "Filter:",
|
|
20
|
+
pageCalendarMoreEvents: (n) => `+${n} more...`,
|
|
21
|
+
pageCalendarLabel: "Calendar",
|
|
22
|
+
pageCalendarNavigation: "Calendar navigation",
|
|
23
|
+
pageCalendarMonthGrid: "Calendar month",
|
|
24
|
+
pageCalendarFilterEnabled: "enabled",
|
|
25
|
+
pageCalendarFilterDisabled: "disabled",
|
|
26
|
+
pageCalendarEventCount: (n) => (n === 1 ? "1 event" : `${n} events`),
|
|
27
|
+
pageCalendarEventAt: (title, time) => `${title} at ${time}`,
|
|
28
|
+
commandPaletteEmpty: "Nothing here...",
|
|
29
|
+
commandPaletteLoading: "Loading...",
|
|
30
|
+
datePickerCalendarButtonLabel: "Click to open a date picker",
|
|
31
|
+
emptyDataMessage: "No data",
|
|
32
|
+
inputCaretDown: "Click to see all options",
|
|
33
|
+
inputCloseValue: "Click to clear the value",
|
|
34
|
+
inputOptionalLabel: "Optional",
|
|
35
|
+
wizardNext: "Next",
|
|
36
|
+
wizardPrev: "Previous",
|
|
37
|
+
wizardFinish: "Finish",
|
|
38
|
+
wizardSkip: "Skip",
|
|
39
|
+
multiSelectInnerPlaceholder: "Search...",
|
|
40
|
+
multiSelectSelectedLabel: "Selected",
|
|
41
|
+
tableColumnResizer: "Resize column",
|
|
42
|
+
tableFilterColumnPlaceholder: "Filter by",
|
|
43
|
+
tableFilterColumnTitle: "Filter by",
|
|
44
|
+
tableFilterDropdownTitle: "Filters",
|
|
45
|
+
tableFilterDropdownTitleUnique: "Filter by",
|
|
46
|
+
tableFilterLabel: "Filters",
|
|
47
|
+
tableFilterNewFilter: "New filter",
|
|
48
|
+
tableFilterOperatorPlaceholder: "Equals to...",
|
|
49
|
+
tableFilterOperatorTitle: "Operation",
|
|
50
|
+
tableFilterTypeContains: "Contains",
|
|
51
|
+
tableFilterTypeEndsWith: "Ends with",
|
|
52
|
+
tableFilterTypeGreaterThan: "Greater than",
|
|
53
|
+
tableFilterTypeIs: "Is",
|
|
54
|
+
tableFilterTypeIsNot: "Is not",
|
|
55
|
+
tableFilterTypeLessThan: "Less than",
|
|
56
|
+
tableFilterTypeNotContains: "Not contains",
|
|
57
|
+
tableFilterTypeStartsWith: "Starts with",
|
|
58
|
+
tableFilterValuePlaceholder: "Something...",
|
|
59
|
+
tableFilterValueTitle: "Value",
|
|
60
|
+
tableGroupLabel: "Group",
|
|
61
|
+
tableGroupLabelWithCount: "Group",
|
|
62
|
+
tablePaginationFooter: (pagination) => (<Fragment>
|
|
63
|
+
{pagination.current} to {pagination.pages} of {pagination.totalItems} items.{Array.isArray(pagination.sizes) ? pagination.select : null}{" "}
|
|
64
|
+
per page.
|
|
65
|
+
</Fragment>),
|
|
66
|
+
tablePaginationNext: "Next",
|
|
67
|
+
tablePaginationPrevious: "Previous",
|
|
68
|
+
tablePaginationSelectLabel: "Select the size of page",
|
|
69
|
+
tableSortAddButton: "Add sort",
|
|
70
|
+
tableSortAsc: "Ascending",
|
|
71
|
+
tableSortDesc: "Descending",
|
|
72
|
+
tableSortDropdownTitle: "Order by",
|
|
73
|
+
tableSortOrderByLabel: "Order by",
|
|
74
|
+
tableSortOrderInputPlaceholder: "Order by",
|
|
75
|
+
tableSortOrderInputTitle: "Order by",
|
|
76
|
+
tableSortTypeInputPlaceholder: "Ascending",
|
|
77
|
+
tableSortTypeInputTitle: "Sort type",
|
|
78
|
+
uploadIdle: "You can drag your files here",
|
|
79
|
+
uploadIdleButton: "Choose your files",
|
|
80
|
+
uploadDragging: (props) => `Dragging ${props.n} ${props.n > 0 ? "files" : "file"}`,
|
|
81
|
+
uploadDialogTitle: "Details of your file",
|
|
82
|
+
datepickerPlaceholder: (_) => "day/month/year",
|
|
83
|
+
spinnerLoading: "Loading",
|
|
84
|
+
skeletonLoading: "Loading content",
|
|
85
|
+
closeButton: "Close",
|
|
86
|
+
fileUploadZoneLabel: "File upload area. Drag files here or press Enter to browse.",
|
|
87
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Tweaks = {
|
|
2
|
+
table: {
|
|
3
|
+
sorters: boolean;
|
|
4
|
+
filters: boolean;
|
|
5
|
+
operations: boolean;
|
|
6
|
+
sticky: number | undefined;
|
|
7
|
+
};
|
|
8
|
+
input: {
|
|
9
|
+
iconFeedback: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const defaultTweaks: Tweaks;
|
|
13
|
+
//# sourceMappingURL=default-tweaks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-tweaks.d.ts","sourceRoot":"","sources":["../../src/config/default-tweaks.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACjB,KAAK,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC9B,CAAC;IACF,KAAK,EAAE;QACH,YAAY,EAAE,OAAO,CAAC;KACzB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAG3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../src/hooks/use-click-outside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,KAAK,IAAI,SAclI,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export const useOnClickOutside = (ref, handler) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
const listener = (event) => {
|
|
5
|
+
if (!ref.current || ref.current.contains(event.target))
|
|
6
|
+
return;
|
|
7
|
+
handler(event);
|
|
8
|
+
};
|
|
9
|
+
const params = { passive: true };
|
|
10
|
+
document.addEventListener("mousedown", listener, params);
|
|
11
|
+
document.addEventListener("touchstart", listener, params);
|
|
12
|
+
return () => {
|
|
13
|
+
document.removeEventListener("mousedown", listener);
|
|
14
|
+
document.removeEventListener("touchstart", listener);
|
|
15
|
+
};
|
|
16
|
+
}, [ref, handler]);
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-color-parser.d.ts","sourceRoot":"","sources":["../../src/hooks/use-color-parser.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,wCAI1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { Context } from "../config/context";
|
|
3
|
+
import { parsers } from "../styles/design-tokens";
|
|
4
|
+
export const useColorParser = () => {
|
|
5
|
+
const ctx = useContext(Context);
|
|
6
|
+
if (!ctx)
|
|
7
|
+
return parsers.hsla;
|
|
8
|
+
return ctx.parser;
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { Locales } from "the-mask-input";
|
|
3
|
+
import { parsers } from "../styles/design-tokens";
|
|
4
|
+
import { ContextProps } from "../config/context";
|
|
5
|
+
import { Translations } from "../config/default-translations";
|
|
6
|
+
import { Tweaks } from "../config/default-tweaks";
|
|
7
|
+
export type ContextType = Partial<{
|
|
8
|
+
tweaks: Tweaks;
|
|
9
|
+
map: Translations;
|
|
10
|
+
locale: Locales | undefined;
|
|
11
|
+
parser: typeof parsers.hsla;
|
|
12
|
+
floatingRef?: HTMLElement | null;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const ComponentsProvider: (props: PropsWithChildren<ContextProps>) => React.JSX.Element;
|
|
15
|
+
//# sourceMappingURL=use-components-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-components-provider.d.ts","sourceRoot":"","sources":["../../src/hooks/use-components-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAW,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAuB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAiB,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACpC,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAAI,OAAO,iBAAiB,CAAC,YAAY,CAAC,sBAkBxE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { IconContext } from "@phosphor-icons/react";
|
|
4
|
+
import { parsers } from "../styles/design-tokens";
|
|
5
|
+
import { Context } from "../config/context";
|
|
6
|
+
import { defaultTranslations } from "../config/default-translations";
|
|
7
|
+
import { defaultTweaks } from "../config/default-tweaks";
|
|
8
|
+
import { ModalConfirmProvider } from "../components/floating/modal";
|
|
9
|
+
export const ComponentsProvider = (props) => {
|
|
10
|
+
const memoMap = useMemo(() => ({
|
|
11
|
+
locale: props.locale,
|
|
12
|
+
floatingRef: props.rootFloating,
|
|
13
|
+
tweaks: { ...defaultTweaks, ...props.tweaks },
|
|
14
|
+
parser: props.parser || parsers.hsla,
|
|
15
|
+
map: { ...defaultTranslations, ...props.map },
|
|
16
|
+
}), [props]);
|
|
17
|
+
return (<IconContext.Provider value={{ weight: props.iconWeight ?? "regular" }}>
|
|
18
|
+
<Context.Provider value={memoMap}>
|
|
19
|
+
<ModalConfirmProvider>{props.children}</ModalConfirmProvider>
|
|
20
|
+
</Context.Provider>
|
|
21
|
+
</IconContext.Provider>);
|
|
22
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type Fn = (...a: never[]) => unknown;
|
|
2
|
+
export declare const debounce: <T extends Fn>(fn: T, ms?: number) => ((...args: Parameters<T>) => void);
|
|
3
|
+
export declare function useDebounce<T extends Fn>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=use-debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce.d.ts","sourceRoot":"","sources":["../../src/hooks/use-debounce.ts"],"names":[],"mappings":"AAEA,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAErC,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,EAAE,WAAM,KAAG,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMvF,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,+BARsB,IAAI,CAWvF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
export const debounce = (fn, ms = 0) => {
|
|
3
|
+
let timeoutId = undefined;
|
|
4
|
+
return function debounced(...args) {
|
|
5
|
+
clearTimeout(timeoutId);
|
|
6
|
+
timeoutId = setTimeout(() => fn(...args), ms);
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export function useDebounce(fn, delay) {
|
|
10
|
+
const debouncedValue = useRef(debounce(fn, delay));
|
|
11
|
+
return debouncedValue.current;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-floating-ref.d.ts","sourceRoot":"","sources":["../../src/hooks/use-floating-ref.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,+BAG1B,CAAC"}
|