@povio/ui 2.2.6 → 2.2.7
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/assets/icons/AlignCenter.js +3 -1
- package/dist/assets/icons/AlignLeft.js +3 -1
- package/dist/assets/icons/AlignLeftRight.js +3 -1
- package/dist/assets/icons/AlignRight.js +3 -1
- package/dist/assets/icons/ArrowDropDown.js +3 -1
- package/dist/assets/icons/ArrowDropUp.js +3 -1
- package/dist/assets/icons/ArrowLeft.js +3 -1
- package/dist/assets/icons/ArrowRight.js +3 -1
- package/dist/assets/icons/Bold.js +3 -1
- package/dist/assets/icons/BulletedList.js +3 -1
- package/dist/assets/icons/Calendar.js +3 -1
- package/dist/assets/icons/Check.js +3 -1
- package/dist/assets/icons/CheckCircle.js +3 -1
- package/dist/assets/icons/CheckboxCheckmark.js +3 -1
- package/dist/assets/icons/CheckboxIndeterminate.js +3 -1
- package/dist/assets/icons/ChevronDown.js +3 -1
- package/dist/assets/icons/ChevronLeft.js +3 -1
- package/dist/assets/icons/ChevronRight.js +3 -1
- package/dist/assets/icons/ChevronUp.js +3 -1
- package/dist/assets/icons/ChevronsLeft.js +3 -1
- package/dist/assets/icons/ChevronsRight.js +3 -1
- package/dist/assets/icons/Clock.js +3 -1
- package/dist/assets/icons/Close.js +3 -1
- package/dist/assets/icons/DateTime.js +3 -1
- package/dist/assets/icons/DragIndicator.js +3 -1
- package/dist/assets/icons/File.js +3 -1
- package/dist/assets/icons/Highlight.js +3 -1
- package/dist/assets/icons/HighlightOn.js +3 -1
- package/dist/assets/icons/Home.js +3 -1
- package/dist/assets/icons/Info.js +3 -1
- package/dist/assets/icons/Italic.js +3 -1
- package/dist/assets/icons/Link.js +3 -1
- package/dist/assets/icons/Menu.js +3 -1
- package/dist/assets/icons/NumberedList.js +3 -1
- package/dist/assets/icons/PointerHorizontal.js +3 -1
- package/dist/assets/icons/PointerVertical.js +3 -1
- package/dist/assets/icons/Search.js +3 -1
- package/dist/assets/icons/Send.js +3 -1
- package/dist/assets/icons/Strikethrough.js +3 -1
- package/dist/assets/icons/TextColor.js +3 -1
- package/dist/assets/icons/Today.js +3 -1
- package/dist/assets/icons/Underlined.js +3 -1
- package/dist/assets/icons/Upload.js +3 -1
- package/dist/assets/icons/Visibility.js +3 -1
- package/dist/assets/icons/VisibilityOff.js +3 -1
- package/dist/assets/icons/WarningFilled.js +3 -1
- package/dist/assets/locales/en/translation.json.js +1 -0
- package/dist/assets/locales/sl/translation.json.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +5 -3
- package/dist/components/Breadcrumbs/breadcrumbs.cva.js +7 -5
- package/dist/components/Menu/Menu.js +3 -1
- package/dist/components/Menu/MenuDesktop.js +3 -1
- package/dist/components/Menu/MenuItem.js +3 -1
- package/dist/components/Menu/MenuMobile.js +3 -1
- package/dist/components/Menu/MenuPopover.js +3 -1
- package/dist/components/Menu/menu.cva.js +6 -4
- package/dist/components/buttons/Button/Button.js +3 -1
- package/dist/components/buttons/Button/button.cva.js +7 -5
- package/dist/components/buttons/IconButton/IconButton.js +3 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +3 -1
- package/dist/components/buttons/PillButton/PillButton.js +3 -1
- package/dist/components/buttons/PillButton/pillButton.cva.js +6 -4
- package/dist/components/buttons/SplitButton/SplitButton.js +3 -1
- package/dist/components/buttons/TextButton/TextButton.js +3 -1
- package/dist/components/buttons/ToggleButton/ToggleButton.js +3 -1
- package/dist/components/buttons/shared/ButtonContent.js +3 -1
- package/dist/components/buttons/shared/buttonContent.cva.js +2 -1
- package/dist/components/inputs/Checkbox/Checkbox.js +3 -1
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +3 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.js +6 -4
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +3 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +9 -7
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +3 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +3 -1
- package/dist/components/inputs/DateTime/shared/Calendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +4 -2
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +3 -1
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimeField.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +3 -1
- package/dist/components/inputs/DateTime/shared/YearPicker.js +3 -1
- package/dist/components/inputs/File/FileUpload.js +6 -4
- package/dist/components/inputs/File/FileUploadContainer.js +3 -1
- package/dist/components/inputs/File/InputUpload.js +3 -1
- package/dist/components/inputs/File/shared/FileCard.js +3 -1
- package/dist/components/inputs/File/shared/FileCardList.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContent.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentError.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadContent.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadFilled.js +3 -1
- package/dist/components/inputs/File/shared/ProgressBar.js +3 -1
- package/dist/components/inputs/File/shared/fileUpload.cva.js +4 -2
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +6 -3
- package/dist/components/inputs/FormField/FormField.js +3 -1
- package/dist/components/inputs/FormField/FormFieldError.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +4 -2
- package/dist/components/inputs/FormField/FormFieldHelper.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.js +3 -1
- package/dist/components/inputs/FormField/formFieldError.cva.js +3 -1
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +3 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +3 -1
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +4 -2
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +3 -1
- package/dist/components/inputs/Input/shared/InputContent.js +3 -1
- package/dist/components/inputs/Inputs/Form.js +2 -0
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/Inputs/Inputs.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +3 -1
- package/dist/components/inputs/RadioGroup/radio.cva.js +5 -3
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +3 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectListBox.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +5 -3
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -1
- package/dist/components/inputs/Selection/shared/select.context.js +20 -18
- package/dist/components/inputs/Selection/shared/useSelectItems.js +6 -4
- package/dist/components/inputs/Slider/Slider.js +3 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +4 -2
- package/dist/components/inputs/TextEditor/textEditor.types.js +3 -1
- package/dist/components/inputs/Toggle/Toggle.js +3 -1
- package/dist/components/inputs/Toggle/toggle.cva.js +4 -2
- package/dist/components/inputs/shared/CheckContent.js +3 -1
- package/dist/components/inputs/shared/InputClear.js +5 -3
- package/dist/components/inputs/shared/TooltipWrapper.js +3 -1
- package/dist/components/inputs/shared/input.cva.js +6 -4
- package/dist/components/inputs/shared/label.cva.js +4 -2
- package/dist/components/navigation/Accordion/Accordion.js +3 -1
- package/dist/components/navigation/Accordion/AccordionItem.js +3 -1
- package/dist/components/navigation/Accordion/accordion.cva.js +12 -10
- package/dist/components/navigation/Stepper/Stepper.js +3 -1
- package/dist/components/navigation/Stepper/StepperItem.js +3 -1
- package/dist/components/navigation/Stepper/StepperSeparator.js +3 -1
- package/dist/components/navigation/Stepper/stepper.cva.js +9 -7
- package/dist/components/outline.clsx.js +4 -2
- package/dist/components/overlays/ActionModal/ActionModal.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheet.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +4 -2
- package/dist/components/overlays/Drawer/Drawer.js +3 -1
- package/dist/components/overlays/Modal/Modal.js +4 -2
- package/dist/components/overlays/Modal/modal.cva.js +5 -3
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +3 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +7 -2
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +3 -1
- package/dist/components/overlays/Tooltip/tooltip.cva.js +6 -4
- package/dist/components/segment/Segment.js +3 -1
- package/dist/components/segment/SegmentItem.js +3 -1
- package/dist/components/segment/segment.cva.js +4 -2
- package/dist/components/shared/pagination/Pagination.js +4 -2
- package/dist/components/shared/pagination/PaginationList.js +4 -2
- package/dist/components/shared/pagination/minWidth.cva.js +3 -1
- package/dist/components/shared/popover.cva.js +3 -1
- package/dist/components/status/Alert/Alert.js +3 -1
- package/dist/components/status/Alert/alert.cva.js +3 -1
- package/dist/components/status/Loader/Loader.js +3 -1
- package/dist/components/status/Loader/loader.cva.js +4 -2
- package/dist/components/status/Toast/Toast.js +15 -6
- package/dist/components/status/Toast/toast.cva.js +6 -20
- package/dist/components/status/Toast/useToast.js +3 -1
- package/dist/components/status/shared/status.cva.js +4 -2
- package/dist/components/table/CellText.js +3 -1
- package/dist/components/table/ColumnConfig.js +3 -1
- package/dist/components/table/HeaderText.js +3 -1
- package/dist/components/table/InfiniteTable.js +3 -1
- package/dist/components/table/PaginatedTable.js +3 -1
- package/dist/components/table/Table.js +4 -2
- package/dist/components/table/table.cva.js +8 -6
- package/dist/components/text/Link/Link.js +3 -1
- package/dist/components/text/Link/link.cva.js +3 -1
- package/dist/components/text/Tag/Tag.d.ts +3 -0
- package/dist/components/text/Tag/Tag.js +9 -4
- package/dist/components/text/Tag/tag.cva.js +3 -1
- package/dist/components/text/Typography/Typography.js +3 -1
- package/dist/components/text/Typography/typography.cva.js +3 -1
- package/dist/config/confirmation.context.js +4 -2
- package/dist/config/i18n.js +4 -2
- package/dist/config/link.context.js +3 -1
- package/dist/config/router.context.js +3 -1
- package/dist/config/theme.context.js +8 -6
- package/dist/config/uiConfig.context.d.ts +4 -0
- package/dist/config/uiConfig.context.js +9 -2
- package/dist/config/uiStyle.context.js +3 -1
- package/dist/helpers/dynamicColumns.js +4 -2
- package/dist/helpers/dynamicInputs.js +5 -3
- package/dist/hooks/useAutosave.js +2 -0
- package/dist/hooks/useBreakpoint.js +5 -3
- package/dist/hooks/useDebounceCallback.js +2 -0
- package/dist/hooks/useDeepCompare.js +5 -3
- package/dist/hooks/useFilters.js +3 -1
- package/dist/hooks/useForm.js +2 -0
- package/dist/hooks/useFormAutosave.js +2 -0
- package/dist/hooks/useIntersectionObserver.js +3 -1
- package/dist/hooks/useLocalStorage.js +3 -1
- package/dist/hooks/useLongPressRepeat.js +3 -1
- package/dist/hooks/usePagination.js +2 -0
- package/dist/hooks/useScrollableListBox.js +2 -0
- package/dist/hooks/useSorting.js +2 -0
- package/dist/hooks/useStateAndRef.js +3 -1
- package/dist/hooks/useTableColumnConfig.js +2 -0
- package/dist/hooks/useTableNav.js +124 -20
- package/dist/hooks/useTranslationMemo.js +2 -0
- package/dist/tw-ui-plugin.js +4 -2
- package/dist/utils/array.utils.js +3 -1
- package/dist/utils/compoundMapper.js +3 -1
- package/dist/utils/date-time.utils.js +3 -1
- package/dist/utils/date.utils.js +3 -1
- package/dist/utils/dom.utils.js +3 -1
- package/dist/utils/file.utils.js +3 -1
- package/dist/utils/isEqual.js +3 -1
- package/dist/utils/logger.js +3 -1
- package/dist/utils/object.utils.js +3 -1
- package/dist/utils/queries.utils.js +3 -1
- package/dist/utils/rest.utils.js +3 -1
- package/dist/utils/routing.utils.js +3 -1
- package/dist/utils/string.utils.js +3 -1
- package/dist/utils/zod.utils.js +3 -1
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { ZodUtils } from "../utils/zod.utils.js";
|
|
|
3
3
|
import { DateUtils } from "../utils/date.utils.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import i18next from "i18next";
|
|
6
|
+
//#region src/helpers/dynamicColumns.ts
|
|
6
7
|
var DEFAULT_NAMESPACE = "dynamicColumns";
|
|
7
8
|
var FORMAT_MAP = {
|
|
8
9
|
datetime: (value) => DateUtils.formatDate(new Date(value)),
|
|
@@ -47,7 +48,7 @@ var convertCustomEntriesToColumnDefs = (entries) => {
|
|
|
47
48
|
var excludeEntries = (entries) => {
|
|
48
49
|
return entries.filter(([, value]) => value !== false && value !== void 0);
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
+
var sortColumns = (columns, orderKeys) => {
|
|
51
52
|
if (!orderKeys) return columns;
|
|
52
53
|
const wildcardIndex = orderKeys.indexOf("*");
|
|
53
54
|
if (wildcardIndex === -1) return columns.sort((columnA, columnB) => {
|
|
@@ -246,7 +247,7 @@ var validateParams = (schema, presetColumns, options) => {
|
|
|
246
247
|
validateOptionKeyArray(allKeys, order, "order");
|
|
247
248
|
validateOptionKeyArray(usedKeys, disableFormatting, "disableFormatting");
|
|
248
249
|
};
|
|
249
|
-
|
|
250
|
+
var dynamicColumns = ({ schema, preset = [], options }) => {
|
|
250
251
|
validateParams(schema, preset, options);
|
|
251
252
|
const sortableKeys = normalizeSortable(options.sortable);
|
|
252
253
|
let entries = Object.entries(options.columns ?? {});
|
|
@@ -269,4 +270,5 @@ const dynamicColumns = ({ schema, preset = [], options }) => {
|
|
|
269
270
|
];
|
|
270
271
|
return sortColumns(options.includeAll ? addMissingSchemaFields(schema, mergedColumns, options, sortableKeys) : mergedColumns, options.order);
|
|
271
272
|
};
|
|
273
|
+
//#endregion
|
|
272
274
|
export { dynamicColumns };
|
|
@@ -2,6 +2,7 @@ import { StringUtils } from "../utils/string.utils.js";
|
|
|
2
2
|
import { ZodUtils } from "../utils/zod.utils.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import i18next from "i18next";
|
|
5
|
+
//#region src/helpers/dynamicInputs.ts
|
|
5
6
|
var defaultComponentTypes = {
|
|
6
7
|
datetime: "datePicker",
|
|
7
8
|
dateRange: "dateRangePicker",
|
|
@@ -52,7 +53,7 @@ var convertInputsConfigToObjectDefinitions = (entries) => {
|
|
|
52
53
|
return [key, inputConfigToObjectDefinition(value)];
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
var getDefaultInputComponentType = (schemaType) => {
|
|
56
57
|
if (ZodUtils.isDateRange(schemaType)) return defaultComponentTypes.dateRange;
|
|
57
58
|
const unwrappedType = ZodUtils.unwrapZodType(schemaType);
|
|
58
59
|
const componentType = ZOD_TYPE_COMPONENT_TYPE.find(([zodType]) => unwrappedType instanceof zodType)?.[1];
|
|
@@ -67,7 +68,7 @@ var getDefaultSelectionItems = (keyType) => {
|
|
|
67
68
|
}));
|
|
68
69
|
return [];
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
var getDefaultSelectionMode = (keyType) => {
|
|
71
72
|
return keyType instanceof z.ZodArray ? "multiple" : "single";
|
|
72
73
|
};
|
|
73
74
|
var getDefaultProps = (componentType, keyType) => {
|
|
@@ -171,7 +172,7 @@ var addMissingSchemaFields = (schema, existingInputDefs, options) => {
|
|
|
171
172
|
});
|
|
172
173
|
return [...existingInputDefs, ...additionalInputDefs];
|
|
173
174
|
};
|
|
174
|
-
|
|
175
|
+
var dynamicInputs = ({ schema, preset = [], options }) => {
|
|
175
176
|
validateParams(schema, preset, options);
|
|
176
177
|
let entries = Object.entries(options.inputs ?? {});
|
|
177
178
|
entries = excludeEntries(entries);
|
|
@@ -183,4 +184,5 @@ const dynamicInputs = ({ schema, preset = [], options }) => {
|
|
|
183
184
|
const mergedInputDefs = [...presetInputDefs, ...inputDefs];
|
|
184
185
|
return sortInputDefs(options.includeAll ? addMissingSchemaFields(schema, mergedInputDefs, options) : mergedInputDefs, options.order);
|
|
185
186
|
};
|
|
187
|
+
//#endregion
|
|
186
188
|
export { dynamicInputs, getDefaultInputComponentType };
|
|
@@ -2,6 +2,7 @@ import { ObjectUtils } from "../utils/object.utils.js";
|
|
|
2
2
|
import { isEqual } from "../utils/isEqual.js";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { useFormState, useWatch } from "react-hook-form";
|
|
5
|
+
//#region src/hooks/useAutosave.ts
|
|
5
6
|
function isNilOrEqual(left, right) {
|
|
6
7
|
if (ObjectUtils.isNil(left) && ObjectUtils.isNil(right)) return true;
|
|
7
8
|
return isEqual(left, right);
|
|
@@ -59,4 +60,5 @@ function useAutosave({ form, delay = 500, enabled = true, onSave, onSaveSuccess
|
|
|
59
60
|
reset
|
|
60
61
|
]);
|
|
61
62
|
}
|
|
63
|
+
//#endregion
|
|
62
64
|
export { useAutosave };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useMediaQuery } from "react-responsive";
|
|
3
|
+
//#region src/hooks/useBreakpoint.ts
|
|
3
4
|
var breakpoints = null;
|
|
4
5
|
function getBreakpoints() {
|
|
5
6
|
if (breakpoints) return breakpoints;
|
|
@@ -21,8 +22,9 @@ function getBreakpoints() {
|
|
|
21
22
|
return breakpoints;
|
|
22
23
|
}
|
|
23
24
|
function useBreakpoint(breakpointKey) {
|
|
24
|
-
const breakpoints
|
|
25
|
-
if (!breakpoints
|
|
26
|
-
return useMediaQuery({ query: `(min-width: ${breakpoints
|
|
25
|
+
const breakpoints = useMemo(() => getBreakpoints(), []);
|
|
26
|
+
if (!breakpoints) throw new Error("Tailwind config is missing theme.screens");
|
|
27
|
+
return useMediaQuery({ query: `(min-width: ${breakpoints[breakpointKey]})` });
|
|
27
28
|
}
|
|
29
|
+
//#endregion
|
|
28
30
|
export { useBreakpoint };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/hooks/useDebounceCallback.ts
|
|
2
3
|
function useDebounceCallback(callback, { delay = 500 } = {}) {
|
|
3
4
|
const timeoutRef = useRef(null);
|
|
4
5
|
const [isDebouncing, setIsDebouncing] = useState(false);
|
|
@@ -20,4 +21,5 @@ function useDebounceCallback(callback, { delay = 500 } = {}) {
|
|
|
20
21
|
isDebouncing
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
//#endregion
|
|
23
25
|
export { useDebounceCallback };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { isEqual } from "../utils/isEqual.js";
|
|
2
2
|
import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
3
|
-
|
|
3
|
+
//#region src/hooks/useDeepCompare.ts
|
|
4
|
+
var useDeepCompareEffect = (callback, dependencies) => {
|
|
4
5
|
return useEffect(callback, useDeepCompareDeps(dependencies));
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
var useDeepCompareLayoutEffect = (callback, dependencies) => {
|
|
7
8
|
return useLayoutEffect(callback, useDeepCompareDeps(dependencies));
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
var useDeepCompareMemo = (factory, dependencies) => {
|
|
10
11
|
return useMemo(factory, useDeepCompareDeps(dependencies));
|
|
11
12
|
};
|
|
12
13
|
var useDeepCompareDeps = (value) => {
|
|
@@ -18,4 +19,5 @@ var useDeepCompareDeps = (value) => {
|
|
|
18
19
|
}
|
|
19
20
|
return [signalRef.current];
|
|
20
21
|
};
|
|
22
|
+
//#endregion
|
|
21
23
|
export { useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo };
|
package/dist/hooks/useFilters.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
//#region src/hooks/useFilters.ts
|
|
4
5
|
function getFieldType(schema, fieldKey) {
|
|
5
6
|
if (!schema || !schema.shape) return "unknown";
|
|
6
7
|
let fieldSchema = schema.shape[fieldKey];
|
|
@@ -44,7 +45,7 @@ var parseFilterFromQuery = (searchParams, schema) => {
|
|
|
44
45
|
}
|
|
45
46
|
return filter;
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
var useFilters = (defaultFilterValues, prefix = "", schema) => {
|
|
48
49
|
const { searchParams, pathname, replace } = UIRouter.useUIRouter();
|
|
49
50
|
const [filterData, setFilterData] = useState(() => parseFilterFromQuery(searchParams, schema));
|
|
50
51
|
useEffect(() => {
|
|
@@ -118,4 +119,5 @@ const useFilters = (defaultFilterValues, prefix = "", schema) => {
|
|
|
118
119
|
clearAllFilters
|
|
119
120
|
]);
|
|
120
121
|
};
|
|
122
|
+
//#endregion
|
|
121
123
|
export { useFilters };
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useForm } from "react-hook-form";
|
|
3
3
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
//#region src/hooks/useForm.ts
|
|
4
5
|
function useForm$1({ resolver, zodSchema, defaultValues, ...props }) {
|
|
5
6
|
const formResolver = useMemo(() => resolver ?? (zodSchema ? zodResolver(zodSchema) : void 0), [resolver, zodSchema]);
|
|
6
7
|
return useForm({
|
|
@@ -9,4 +10,5 @@ function useForm$1({ resolver, zodSchema, defaultValues, ...props }) {
|
|
|
9
10
|
defaultValues
|
|
10
11
|
});
|
|
11
12
|
}
|
|
13
|
+
//#endregion
|
|
12
14
|
export { useForm$1 as useForm };
|
|
@@ -2,6 +2,7 @@ import { ObjectUtils } from "../utils/object.utils.js";
|
|
|
2
2
|
import { useAutosave } from "./useAutosave.js";
|
|
3
3
|
import { useForm } from "./useForm.js";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
|
+
//#region src/hooks/useFormAutosave.ts
|
|
5
6
|
var getResetTimeoutErrorMessage = (resetTimeout) => `Form Reset Timeout (${resetTimeout}ms) - Action Required
|
|
6
7
|
Problem: Form values weren't reset after submission.
|
|
7
8
|
|
|
@@ -49,4 +50,5 @@ function useFormAutosave({ autosaveDelay, enableAutosave, onAutosave, getResetVa
|
|
|
49
50
|
});
|
|
50
51
|
return form;
|
|
51
52
|
}
|
|
53
|
+
//#endregion
|
|
52
54
|
export { useFormAutosave };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
2
|
+
//#region src/hooks/useIntersectionObserver.ts
|
|
3
|
+
var useIntersectionObserver = ({ onIntersection, onIntersectionChange, root, rootMargin, threshold }) => {
|
|
3
4
|
const ref = useRef(null);
|
|
4
5
|
useEffect(() => {
|
|
5
6
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -20,4 +21,5 @@ const useIntersectionObserver = ({ onIntersection, onIntersectionChange, root, r
|
|
|
20
21
|
]);
|
|
21
22
|
return { ref };
|
|
22
23
|
};
|
|
24
|
+
//#endregion
|
|
23
25
|
export { useIntersectionObserver };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
|
+
//#region src/hooks/useLocalStorage.ts
|
|
2
3
|
var getValue = (key, schema) => {
|
|
3
4
|
if (!localStorage) return null;
|
|
4
5
|
const lsValue = localStorage.getItem(key);
|
|
@@ -13,7 +14,7 @@ var getValue = (key, schema) => {
|
|
|
13
14
|
if (parsedValue.success) return parsedValue.data;
|
|
14
15
|
else return null;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
var useLocalStorage = ({ key, schema }) => {
|
|
17
18
|
const [value, setValue] = useState(() => getValue(key, schema));
|
|
18
19
|
return {
|
|
19
20
|
value,
|
|
@@ -32,4 +33,5 @@ const useLocalStorage = ({ key, schema }) => {
|
|
|
32
33
|
}, [key])
|
|
33
34
|
};
|
|
34
35
|
};
|
|
36
|
+
//#endregion
|
|
35
37
|
export { useLocalStorage };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
2
|
+
//#region src/hooks/useLongPressRepeat.ts
|
|
3
|
+
var useLongPressRepeat = ({ onPress, enabled = true, interval = 85, timeout = 500 }) => {
|
|
3
4
|
const intervalRef = useRef(void 0);
|
|
4
5
|
useEffect(() => {
|
|
5
6
|
return () => {
|
|
@@ -24,4 +25,5 @@ const useLongPressRepeat = ({ onPress, enabled = true, interval = 85, timeout =
|
|
|
24
25
|
onPressEnd
|
|
25
26
|
};
|
|
26
27
|
};
|
|
28
|
+
//#endregion
|
|
27
29
|
export { useLongPressRepeat };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
//#region src/hooks/usePagination.ts
|
|
3
4
|
var DEFAULT_STATE = {
|
|
4
5
|
pageIndex: 1,
|
|
5
6
|
pageSize: 20
|
|
@@ -23,4 +24,5 @@ function usePagination(defaultPagination) {
|
|
|
23
24
|
pageSize: pagination.pageSize
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
//#endregion
|
|
26
28
|
export { usePagination };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useBreakpoint } from "./useBreakpoint.js";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/hooks/useScrollableListBox.ts
|
|
3
4
|
function useScrollableListBox() {
|
|
4
5
|
const ref = useRef(null);
|
|
5
6
|
const isDesktop = useBreakpoint("md");
|
|
@@ -21,4 +22,5 @@ function useScrollableListBox() {
|
|
|
21
22
|
}, [ref, isDesktop]);
|
|
22
23
|
return { ref };
|
|
23
24
|
}
|
|
25
|
+
//#endregion
|
|
24
26
|
export { useScrollableListBox };
|
package/dist/hooks/useSorting.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UIRouter } from "../config/router.context.js";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
//#region src/hooks/useSorting.ts
|
|
3
4
|
function useSorting(defaultSorting, prefix = "") {
|
|
4
5
|
const { pathname, replace, searchParams } = UIRouter.useUIRouter();
|
|
5
6
|
const [sorting, setSorting] = useState(defaultSorting ?? searchParams.get(`order${prefix && `-${prefix}`}`)?.split(",").map((item) => {
|
|
@@ -31,4 +32,5 @@ function useSorting(defaultSorting, prefix = "") {
|
|
|
31
32
|
order
|
|
32
33
|
};
|
|
33
34
|
}
|
|
35
|
+
//#endregion
|
|
34
36
|
export { useSorting };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
2
|
import { useCallback, useRef, useState } from "react";
|
|
3
|
-
|
|
3
|
+
//#region src/hooks/useStateAndRef.ts
|
|
4
|
+
var useStateAndRef = (initialState) => {
|
|
4
5
|
const [state, setState] = useState(initialState);
|
|
5
6
|
const ref = useRef(state);
|
|
6
7
|
return [
|
|
@@ -12,4 +13,5 @@ const useStateAndRef = (initialState) => {
|
|
|
12
13
|
}, [setState])
|
|
13
14
|
];
|
|
14
15
|
};
|
|
16
|
+
//#endregion
|
|
15
17
|
export { useStateAndRef };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
//#region src/hooks/useTableColumnConfig.ts
|
|
2
3
|
function sortByKeyOrder(data, orderedKeys = []) {
|
|
3
4
|
return [...data].sort((a, b) => {
|
|
4
5
|
return orderedKeys.findIndex((key) => key === (a.id ?? a.accessorKey)) - orderedKeys.findIndex((key) => key === (b.id ?? b.accessorKey));
|
|
@@ -35,4 +36,5 @@ function useTableColumnConfig(defaultColumns, options = {}) {
|
|
|
35
36
|
onOrderChange: handleOrderChange
|
|
36
37
|
};
|
|
37
38
|
}
|
|
39
|
+
//#endregion
|
|
38
40
|
export { useTableColumnConfig };
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { logger } from "../utils/logger.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Keys
|
|
5
|
-
Keys
|
|
6
|
-
Keys
|
|
7
|
-
Keys
|
|
8
|
-
Keys
|
|
9
|
-
Keys
|
|
10
|
-
Keys
|
|
11
|
-
Keys
|
|
12
|
-
Keys
|
|
13
|
-
Keys
|
|
14
|
-
Keys
|
|
15
|
-
Keys
|
|
16
|
-
Keys
|
|
17
|
-
|
|
2
|
+
//#region src/hooks/useTableNav.ts
|
|
3
|
+
var Keys = /* @__PURE__ */ function(Keys) {
|
|
4
|
+
Keys["Enter"] = "Enter";
|
|
5
|
+
Keys["Escape"] = "Escape";
|
|
6
|
+
Keys["Shift"] = "Shift";
|
|
7
|
+
Keys["Control"] = "Control";
|
|
8
|
+
Keys["Home"] = "Home";
|
|
9
|
+
Keys["End"] = "End";
|
|
10
|
+
Keys["Backspace"] = "Backspace";
|
|
11
|
+
/** Page Keys */
|
|
12
|
+
Keys["PageUp"] = "PageUp";
|
|
13
|
+
Keys["PageDown"] = "PageDown";
|
|
14
|
+
/** Arrow Keys */
|
|
15
|
+
Keys["ArrowLeft"] = "ArrowLeft";
|
|
16
|
+
Keys["ArrowUp"] = "ArrowUp";
|
|
17
|
+
Keys["ArrowRight"] = "ArrowRight";
|
|
18
|
+
Keys["ArrowDown"] = "ArrowDown";
|
|
19
|
+
Keys["F2"] = "F2";
|
|
20
|
+
return Keys;
|
|
18
21
|
}(Keys || {});
|
|
19
22
|
var Selectors = {
|
|
20
23
|
Cell: "[role=\"cell\"],[role=\"gridcell\"],[role=\"columnheader\"],[role=\"rowheader\"],td,th",
|
|
@@ -39,9 +42,17 @@ var DataGridNav = class {
|
|
|
39
42
|
this.debug = debug;
|
|
40
43
|
this.disabled = false;
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Disables the keyboard listener in cases
|
|
47
|
+
* that elements inside the grid need to use
|
|
48
|
+
* arrows keys etc., like select dropdowns
|
|
49
|
+
*/
|
|
42
50
|
disable() {
|
|
43
51
|
this.disabled = true;
|
|
44
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Enables the keyboard listeners
|
|
55
|
+
*/
|
|
45
56
|
enable() {
|
|
46
57
|
this.disabled = false;
|
|
47
58
|
}
|
|
@@ -51,21 +62,48 @@ var DataGridNav = class {
|
|
|
51
62
|
getActiveCell() {
|
|
52
63
|
return this.activeCell;
|
|
53
64
|
}
|
|
65
|
+
/** Used as a keyboard listener for key up */
|
|
54
66
|
tableKeyUp() {
|
|
55
67
|
this.keys = [];
|
|
56
68
|
}
|
|
69
|
+
/** Used as a keyboard listener for key down */
|
|
57
70
|
tableKeyDown(e) {
|
|
58
71
|
if (this.disabled) return;
|
|
72
|
+
/**
|
|
73
|
+
* Avoid page scrolling etc.
|
|
74
|
+
* Enable default behavior for:
|
|
75
|
+
* Tab, Shift + Tab
|
|
76
|
+
* TODO: Actually it will be better to just prevent
|
|
77
|
+
* in ArrowKeys and PageKeys maybe?
|
|
78
|
+
* Or should the consumer stop propagation?!
|
|
79
|
+
* Cannot work with preventDefault as it will
|
|
80
|
+
* first capture the event from an input in cell for example
|
|
81
|
+
*/
|
|
59
82
|
if (Keys.ArrowDown === e.key || Keys.ArrowUp === e.key || Keys.ArrowLeft === e.key || Keys.ArrowRight === e.key) e.preventDefault();
|
|
83
|
+
/**
|
|
84
|
+
* Add key to the stack if it's
|
|
85
|
+
* not the same with the last (long press)
|
|
86
|
+
*/
|
|
60
87
|
if (this.keys.length === 0 || this.keys[this.keys.length - 1] !== e.key) this.keys.push(e.key);
|
|
88
|
+
/**
|
|
89
|
+
* Need to check if we are inside a grid cell
|
|
90
|
+
* or not to enable/disable Grid Navigation
|
|
91
|
+
*/
|
|
61
92
|
if (!(e.target instanceof Element)) return;
|
|
62
93
|
const cell = e.target.parentElement?.closest(`${this.selectors.Cell},${this.selectors.Row}`);
|
|
63
94
|
if (!cell) return;
|
|
64
95
|
if (cell.matches(this.selectors.Cell)) this.cellNavigation(e);
|
|
65
96
|
else this.gridNavigation(e);
|
|
66
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Handles the navigation inside a cell
|
|
100
|
+
*/
|
|
67
101
|
cellNavigation(e) {
|
|
68
102
|
if (!(e.target instanceof Element)) return;
|
|
103
|
+
/**
|
|
104
|
+
* Keys: Escape
|
|
105
|
+
* Restore grid navigation
|
|
106
|
+
*/
|
|
69
107
|
if (e.key === Keys.Escape) {
|
|
70
108
|
const cell = e.target.closest(this.selectors.Cell);
|
|
71
109
|
if (cell && this.isFocusable(cell)) {
|
|
@@ -73,6 +111,13 @@ var DataGridNav = class {
|
|
|
73
111
|
return;
|
|
74
112
|
}
|
|
75
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Keys: ArrowRight, ArrowDown
|
|
116
|
+
* Move to the next focusable cell, or the first one
|
|
117
|
+
*
|
|
118
|
+
* Arrow Down disabled:
|
|
119
|
+
* https://github.com/w3c/aria-practices/issues/2739#issuecomment-1613538972
|
|
120
|
+
*/
|
|
76
121
|
if (e.key === Keys.ArrowRight || e.key === Keys.ArrowDown) {
|
|
77
122
|
const cell = e.target.closest(this.selectors.Cell);
|
|
78
123
|
if (!cell) return;
|
|
@@ -82,6 +127,13 @@ var DataGridNav = class {
|
|
|
82
127
|
if (this.isFocusable(widgetToFocus)) widgetToFocus.focus();
|
|
83
128
|
return;
|
|
84
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Keys: ArrowLeft, ArrowUp
|
|
132
|
+
* Move to the previous focusable cell, or the last one
|
|
133
|
+
*
|
|
134
|
+
* Arrow Up disabled:
|
|
135
|
+
* https://github.com/w3c/aria-practices/issues/2739#issuecomment-1613538972
|
|
136
|
+
*/
|
|
85
137
|
if (e.key === Keys.ArrowLeft || e.key === Keys.ArrowUp) {
|
|
86
138
|
const cell = e.target.closest(this.selectors.Cell);
|
|
87
139
|
if (!cell) return;
|
|
@@ -91,11 +143,20 @@ var DataGridNav = class {
|
|
|
91
143
|
if (this.isFocusable(widgetToFocus)) widgetToFocus.focus();
|
|
92
144
|
}
|
|
93
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Handles the navigation outside a cell
|
|
148
|
+
* on the grid level
|
|
149
|
+
*/
|
|
94
150
|
gridNavigation(e) {
|
|
95
151
|
const { target } = e;
|
|
96
152
|
if (!(e.target instanceof Element)) return;
|
|
97
153
|
if (!(target instanceof Element)) return;
|
|
98
154
|
if (this.keys.length === 1) {
|
|
155
|
+
/**
|
|
156
|
+
* Keys: Enter
|
|
157
|
+
* Should move focus inside the cell to the first focusable element:
|
|
158
|
+
* https://www.w3.org/WAI/ARIA/apg/patterns/grid/#gridNav_inside
|
|
159
|
+
*/
|
|
99
160
|
if (/^[a-zA-Z0-9]$/.test(e.key)) {
|
|
100
161
|
const cell = e.target.querySelector(this.selectors.Focusable);
|
|
101
162
|
if (cell && this.isFocusable(cell) && cell instanceof HTMLInputElement) {
|
|
@@ -129,6 +190,10 @@ var DataGridNav = class {
|
|
|
129
190
|
}
|
|
130
191
|
return;
|
|
131
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Keys: ArrowLeft, ArrowRight
|
|
195
|
+
* Should move focus to the next/previous cell
|
|
196
|
+
*/
|
|
132
197
|
if (e.key === Keys.ArrowLeft || e.key === Keys.ArrowRight) {
|
|
133
198
|
const direction = e.key === Keys.ArrowLeft ? "prev" : "next";
|
|
134
199
|
const cell = e.target.closest(this.selectors.Cell);
|
|
@@ -140,20 +205,37 @@ var DataGridNav = class {
|
|
|
140
205
|
e.preventDefault();
|
|
141
206
|
}
|
|
142
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Keys: Up,Down
|
|
210
|
+
* Should move focus to the same column of the next/previous row
|
|
211
|
+
*/
|
|
143
212
|
if (e.key === Keys.ArrowDown || e.key === Keys.ArrowUp) {
|
|
144
213
|
this.verticalCellNavigation(e);
|
|
145
214
|
return;
|
|
146
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Keys: PageUp, PageDown
|
|
218
|
+
* Should move focus to the first/last row
|
|
219
|
+
* or a predefined number of rows if user provides a value
|
|
220
|
+
*/
|
|
147
221
|
if (e.key === Keys.PageUp || e.key === Keys.PageDown) {
|
|
148
222
|
this.pageCellNavigation(e);
|
|
149
223
|
return;
|
|
150
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Keys: Home, End
|
|
227
|
+
* Should move focus to the first/last cell of the current row
|
|
228
|
+
*/
|
|
151
229
|
if (e.key === Keys.Home || e.key === Keys.End) {
|
|
152
230
|
const rowChildren = [...e.target.closest(this.selectors.Row)?.children || []];
|
|
153
231
|
if (e.key === Keys.End) rowChildren.reverse();
|
|
154
232
|
this.focusOnFirstCell(rowChildren);
|
|
155
233
|
}
|
|
156
234
|
} else {
|
|
235
|
+
/**
|
|
236
|
+
* Keys: Control + Home, Control + End
|
|
237
|
+
* Should move focus to the first/last cell of the first/last row
|
|
238
|
+
*/
|
|
157
239
|
const [firstKey, secondKey] = this.keys;
|
|
158
240
|
if (firstKey === "Control" && (secondKey === Keys.Home || secondKey === Keys.End)) {
|
|
159
241
|
const siblings = e.target.closest(this.selectors.Row).parentElement?.children;
|
|
@@ -200,34 +282,43 @@ var DataGridNav = class {
|
|
|
200
282
|
const rowPosition = this.getRowIndex(row);
|
|
201
283
|
if (cellPosition === void 0 || rowPosition === void 0) return;
|
|
202
284
|
const direction = e.key === Keys.ArrowUp ? "prev" : "next";
|
|
285
|
+
/** Find previous rowgroup and focus on the proper cell */
|
|
203
286
|
if (rowPosition === 0 && direction === "prev") {
|
|
204
287
|
const currentRowGroup = row.parentElement?.closest(this.selectors.RowGroup);
|
|
205
288
|
const siblingRowGroups = [...currentRowGroup?.parentElement?.children || []];
|
|
206
289
|
const currentRowGroupIdx = siblingRowGroups.findIndex((el) => el === currentRowGroup);
|
|
207
290
|
if (currentRowGroupIdx !== 0) {
|
|
208
291
|
const rows = [...siblingRowGroups[currentRowGroupIdx - 1].querySelectorAll(this.selectors.Row)];
|
|
209
|
-
const child
|
|
210
|
-
if (child
|
|
292
|
+
const child = rows[rows.length - 1].children[cellPosition];
|
|
293
|
+
if (child && this.isFocusable(child)) child.focus();
|
|
211
294
|
return;
|
|
212
295
|
}
|
|
213
296
|
}
|
|
297
|
+
/** Find next rowgroup and focus on the proper cell */
|
|
214
298
|
if (rowPosition === [...row.parentElement?.querySelectorAll(this.selectors.Row) || []].length - 1 && direction === "next") {
|
|
215
299
|
const currentRowGroup = row.parentElement?.closest(this.selectors.RowGroup);
|
|
216
300
|
const siblingRowGroups = [...currentRowGroup?.parentElement?.children || []];
|
|
217
301
|
const currentRowGroupIdx = siblingRowGroups.findIndex((el) => el === currentRowGroup);
|
|
218
302
|
if (currentRowGroupIdx !== siblingRowGroups.length - 1) {
|
|
219
|
-
const child
|
|
220
|
-
if (child
|
|
303
|
+
const child = [...siblingRowGroups[currentRowGroupIdx + 1].querySelectorAll(this.selectors.Row)][0].children[cellPosition];
|
|
304
|
+
if (child && this.isFocusable(child)) child.focus();
|
|
221
305
|
return;
|
|
222
306
|
}
|
|
223
307
|
return;
|
|
224
308
|
}
|
|
309
|
+
/** Navigation in the same rowgroup */
|
|
225
310
|
const destinationRow = this.findUntil(direction, row, this.selectors.Row);
|
|
226
311
|
if (!destinationRow) return;
|
|
227
312
|
const child = destinationRow.children[cellPosition];
|
|
228
313
|
if (child && this.isFocusable(child)) child.focus();
|
|
229
314
|
}
|
|
230
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Sending a row `Element` and then the first cell will be focused.
|
|
318
|
+
*
|
|
319
|
+
* If you want to focus the last cell then the row children can be passed in
|
|
320
|
+
* reversed order
|
|
321
|
+
*/
|
|
231
322
|
focusOnFirstCell(el) {
|
|
232
323
|
for (let i = 0; i < el.length; i++) {
|
|
233
324
|
const child = el[i];
|
|
@@ -237,6 +328,10 @@ var DataGridNav = class {
|
|
|
237
328
|
}
|
|
238
329
|
}
|
|
239
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Get the column index of a `cell` based on the first `row` parent.
|
|
333
|
+
* `cellIndex` could be used, but it's not supported in HTML tables.
|
|
334
|
+
*/
|
|
240
335
|
getColumnIndex(cell) {
|
|
241
336
|
let position = 0;
|
|
242
337
|
const siblings = cell?.parentNode?.children;
|
|
@@ -245,6 +340,10 @@ var DataGridNav = class {
|
|
|
245
340
|
if (siblings[position] === void 0) return;
|
|
246
341
|
return position;
|
|
247
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Get the row index of a `row` based
|
|
345
|
+
* on its sibling rows
|
|
346
|
+
*/
|
|
248
347
|
getRowIndex(row) {
|
|
249
348
|
let position = 0;
|
|
250
349
|
const siblings = row?.parentNode?.children;
|
|
@@ -253,6 +352,10 @@ var DataGridNav = class {
|
|
|
253
352
|
if (siblings[position] === void 0) return;
|
|
254
353
|
return position;
|
|
255
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Equivalent to prevUntil/nextUntil in jQuery
|
|
357
|
+
* https://api.jquery.com/prevUntil/
|
|
358
|
+
*/
|
|
256
359
|
findUntil(direction, el, matchSelector, exitSelector) {
|
|
257
360
|
let element = el;
|
|
258
361
|
const method = direction === "next" ? "nextSibling" : "previousSibling";
|
|
@@ -276,4 +379,5 @@ function useTableNav(options) {
|
|
|
276
379
|
tableNav: nav
|
|
277
380
|
};
|
|
278
381
|
}
|
|
382
|
+
//#endregion
|
|
279
383
|
export { useTableNav };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
|
+
//#region src/hooks/useTranslationMemo.ts
|
|
3
4
|
function useTranslationMemo(func) {
|
|
4
5
|
const { t } = useTranslation();
|
|
5
6
|
return useMemo(() => {
|
|
@@ -7,4 +8,5 @@ function useTranslationMemo(func) {
|
|
|
7
8
|
return func();
|
|
8
9
|
}, [func, t]);
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
10
12
|
export { useTranslationMemo };
|
package/dist/tw-ui-plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import plugin from "tailwindcss/plugin";
|
|
2
|
-
|
|
2
|
+
//#region src/tw-ui-plugin.ts
|
|
3
|
+
var uiPlugin = plugin(({ addVariant }) => {
|
|
3
4
|
addVariant("input-filled", [
|
|
4
5
|
"&:has(input:not(:placeholder-shown))",
|
|
5
6
|
"&:is(:where(.group\\/input-content):has(:is(input:not(:placeholder-shown))) *)",
|
|
@@ -18,4 +19,5 @@ var tw_ui_plugin_default = plugin(({ addVariant }) => {
|
|
|
18
19
|
"&:is(:where(.group\\/date-picker-content):where([data-rac])[data-disabled] *)"
|
|
19
20
|
].join(", "));
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
export { uiPlugin as default };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/utils/array.utils.ts
|
|
2
|
+
var ArrayUtils;
|
|
2
3
|
(function(_ArrayUtils) {
|
|
3
4
|
_ArrayUtils.fromCommaSeparatedStr = (str) => {
|
|
4
5
|
if (!str) return [];
|
|
5
6
|
return str.split(",").map((item) => item.trim());
|
|
6
7
|
};
|
|
7
8
|
})(ArrayUtils || (ArrayUtils = {}));
|
|
9
|
+
//#endregion
|
|
8
10
|
export { ArrayUtils };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/utils/compoundMapper.ts
|
|
2
|
+
var compoundMapper = (config) => {
|
|
2
3
|
return (props) => {
|
|
3
4
|
return (config.compoundVariants?.find((v) => {
|
|
4
5
|
return Object.entries(v).filter(([key]) => key !== "value").every(([key, value]) => {
|
|
@@ -8,4 +9,5 @@ const compoundMapper = (config) => {
|
|
|
8
9
|
}))?.value ?? config.default;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
12
|
+
//#endregion
|
|
11
13
|
export { compoundMapper };
|