@k3-tech/react-kit 0.0.71 → 0.0.73
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/index.js +6 -6
- package/dist/kit/themes/clean-slate.css +10 -10
- package/dist/kit/themes/default.css +10 -10
- package/dist/kit/themes/minimal-modern.css +10 -10
- package/dist/kit/themes/spotify.css +10 -10
- package/package.json +5 -1
- package/.babelrc +0 -12
- package/.storybook/main.ts +0 -22
- package/.storybook/preview.ts +0 -198
- package/Dockerfile.storybook +0 -43
- package/biome.json +0 -10
- package/components.json +0 -20
- package/dist/chunks/index.js +0 -5168
- package/dist/chunks/ort.bundle.min.js +0 -4
- package/dist/chunks/ort.webgpu.bundle.min.js +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/Can.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/RequireAuth.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenAuthenticated.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenError.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenLoading.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/ShowWhenUnauthenticated.d.ts.map +0 -1
- package/dist/kit/builder/auth/components/withPermission.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/action-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/core-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/permission-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/hooks/token-hooks.d.ts.map +0 -1
- package/dist/kit/builder/auth/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/providers/AuthProvider.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/adapter-config.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/adapter.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/core.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/middleware.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/permissions.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/state.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/storage.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/token-manager.d.ts.map +0 -1
- package/dist/kit/builder/auth/types/utils.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/auth-adapter.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/apollo-link.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/axios.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/fetch.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/graphql.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/rest.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/client-adapters/urql-exchange.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/permission-checker.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/browser.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/cookie.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/encryption.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/env.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/factory.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/index.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/storage/memory.d.ts.map +0 -1
- package/dist/kit/builder/auth/utils/token-manager.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTable.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableColumnHeader.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableFilterPanel.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTablePagination.d.ts.map +0 -1
- package/dist/kit/builder/data-table/components/DataTableViewOptions.d.ts.map +0 -1
- package/dist/kit/builder/data-table/index.d.ts.map +0 -1
- package/dist/kit/builder/data-table/types.d.ts.map +0 -1
- package/dist/kit/builder/data-table/utils/dotAccessor.d.ts.map +0 -1
- package/dist/kit/builder/dialog/index.d.ts.map +0 -1
- package/dist/kit/builder/dialog/provider.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilder.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderActions.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderContext.d.ts.map +0 -1
- package/dist/kit/builder/form/components/FormBuilderField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/ArrayField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/AutocompleteField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/CheckboxField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DatePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateTimePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/DateTimeRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/FileField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/MonthPickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/MonthRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/NumberField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/ObjectField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/RadioField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/SelectField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/SwitchField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TextField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TextareaField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TimePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/TimeRangePickerField.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/index.d.ts.map +0 -1
- package/dist/kit/builder/form/components/fields/types.d.ts.map +0 -1
- package/dist/kit/builder/form/components/index.d.ts.map +0 -1
- package/dist/kit/builder/form/components/sectionNodes.d.ts.map +0 -1
- package/dist/kit/builder/form/hooks/useFormBuilder.d.ts.map +0 -1
- package/dist/kit/builder/form/index.d.ts.map +0 -1
- package/dist/kit/builder/form/types.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/common-forms.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/dependencies.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/field-factories.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/index.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/section-factories.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/transformers.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/validations.d.ts.map +0 -1
- package/dist/kit/builder/form/utils/validators.d.ts.map +0 -1
- package/dist/kit/builder/page/Page.d.ts.map +0 -1
- package/dist/kit/builder/page/PageBackButton.d.ts.map +0 -1
- package/dist/kit/builder/page/index.d.ts.map +0 -1
- package/dist/kit/builder/section/SectionBuilder.d.ts.map +0 -1
- package/dist/kit/builder/section/SectionContainer.d.ts.map +0 -1
- package/dist/kit/builder/section/index.d.ts.map +0 -1
- package/dist/kit/builder/section/types.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/context.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/hooks.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/index.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/provider.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/renderer.d.ts.map +0 -1
- package/dist/kit/builder/stack-dialog/types.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/index.d.ts.map +0 -1
- package/dist/kit/components/autocomplete/types.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/DataTableHeader.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/DebouncedFilterField.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/FilterFieldRenderer.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/index.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/types.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/urlSerialization.d.ts.map +0 -1
- package/dist/kit/components/data-table-headers/useDataTableHeaderUrl.d.ts.map +0 -1
- package/dist/kit/components/datepicker/DatePicker.d.ts.map +0 -1
- package/dist/kit/components/datepicker/DateRangePicker.d.ts.map +0 -1
- package/dist/kit/components/datepicker/index.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/DateTimePicker.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/DateTimeRangePicker.d.ts.map +0 -1
- package/dist/kit/components/datetimepicker/index.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/FileUploader.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/image-preprocess.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/index.d.ts.map +0 -1
- package/dist/kit/components/fileuploader/types.d.ts.map +0 -1
- package/dist/kit/components/forminfo/FormInfoError.d.ts.map +0 -1
- package/dist/kit/components/forminfo/index.d.ts.map +0 -1
- package/dist/kit/components/info-tooltip/InfoTooltip.d.ts.map +0 -1
- package/dist/kit/components/keyboard/Keyboard.d.ts.map +0 -1
- package/dist/kit/components/keyboard/index.d.ts.map +0 -1
- package/dist/kit/components/login/Login.d.ts.map +0 -1
- package/dist/kit/components/login/index.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthInput.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthPicker.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthRangeInput.d.ts.map +0 -1
- package/dist/kit/components/monthpicker/MonthRangePicker.d.ts.map +0 -1
- package/dist/kit/components/numpad/Numpad.d.ts.map +0 -1
- package/dist/kit/components/numpad/index.d.ts.map +0 -1
- package/dist/kit/components/timepicker/TimePicker.d.ts.map +0 -1
- package/dist/kit/components/timepicker/TimeRangePicker.d.ts.map +0 -1
- package/dist/kit/components/timepicker/index.d.ts.map +0 -1
- package/dist/kit/layouts/admin/components/AdminLayout.d.ts.map +0 -1
- package/dist/kit/layouts/admin/components/ThemeToggle.d.ts.map +0 -1
- package/dist/kit/layouts/admin/hooks/menu.d.ts.map +0 -1
- package/dist/kit/layouts/admin/providers/AdminMenuProvider.d.ts.map +0 -1
- package/dist/kit/layouts/admin/types/index.d.ts.map +0 -1
- package/dist/kit/providers/ThemeProvider.d.ts.map +0 -1
- package/dist/shadcn/hooks/use-mobile.d.ts.map +0 -1
- package/dist/shadcn/lib/utils.d.ts.map +0 -1
- package/dist/shadcn/ui/accordion.d.ts.map +0 -1
- package/dist/shadcn/ui/alert-dialog.d.ts.map +0 -1
- package/dist/shadcn/ui/alert.d.ts.map +0 -1
- package/dist/shadcn/ui/aspect-ratio.d.ts.map +0 -1
- package/dist/shadcn/ui/avatar.d.ts.map +0 -1
- package/dist/shadcn/ui/badge.d.ts.map +0 -1
- package/dist/shadcn/ui/breadcrumb.d.ts.map +0 -1
- package/dist/shadcn/ui/button.d.ts.map +0 -1
- package/dist/shadcn/ui/calendar.d.ts.map +0 -1
- package/dist/shadcn/ui/card.d.ts.map +0 -1
- package/dist/shadcn/ui/carousel.d.ts.map +0 -1
- package/dist/shadcn/ui/chart.d.ts.map +0 -1
- package/dist/shadcn/ui/checkbox.d.ts.map +0 -1
- package/dist/shadcn/ui/collapsible.d.ts.map +0 -1
- package/dist/shadcn/ui/command.d.ts.map +0 -1
- package/dist/shadcn/ui/context-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/dialog.d.ts.map +0 -1
- package/dist/shadcn/ui/drawer.d.ts.map +0 -1
- package/dist/shadcn/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/form.d.ts.map +0 -1
- package/dist/shadcn/ui/hover-card.d.ts.map +0 -1
- package/dist/shadcn/ui/input-otp.d.ts.map +0 -1
- package/dist/shadcn/ui/input.d.ts.map +0 -1
- package/dist/shadcn/ui/label.d.ts.map +0 -1
- package/dist/shadcn/ui/menubar.d.ts.map +0 -1
- package/dist/shadcn/ui/navigation-menu.d.ts.map +0 -1
- package/dist/shadcn/ui/pagination.d.ts.map +0 -1
- package/dist/shadcn/ui/popover.d.ts.map +0 -1
- package/dist/shadcn/ui/progress.d.ts.map +0 -1
- package/dist/shadcn/ui/radio-group.d.ts.map +0 -1
- package/dist/shadcn/ui/resizable.d.ts.map +0 -1
- package/dist/shadcn/ui/scroll-area.d.ts.map +0 -1
- package/dist/shadcn/ui/select.d.ts.map +0 -1
- package/dist/shadcn/ui/separator.d.ts.map +0 -1
- package/dist/shadcn/ui/sheet.d.ts.map +0 -1
- package/dist/shadcn/ui/sidebar.d.ts.map +0 -1
- package/dist/shadcn/ui/skeleton.d.ts.map +0 -1
- package/dist/shadcn/ui/slider.d.ts.map +0 -1
- package/dist/shadcn/ui/sonner.d.ts.map +0 -1
- package/dist/shadcn/ui/switch.d.ts.map +0 -1
- package/dist/shadcn/ui/table.d.ts.map +0 -1
- package/dist/shadcn/ui/tabs.d.ts.map +0 -1
- package/dist/shadcn/ui/textarea.d.ts.map +0 -1
- package/dist/shadcn/ui/toggle-group.d.ts.map +0 -1
- package/dist/shadcn/ui/toggle.d.ts.map +0 -1
- package/dist/shadcn/ui/tooltip.d.ts.map +0 -1
- package/src/index.ts +0 -100
- package/src/kit/builder/auth/components/Can.tsx +0 -27
- package/src/kit/builder/auth/components/RequireAuth.tsx +0 -78
- package/src/kit/builder/auth/components/ShowWhenAuthenticated.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenError.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenLoading.tsx +0 -10
- package/src/kit/builder/auth/components/ShowWhenUnauthenticated.tsx +0 -10
- package/src/kit/builder/auth/components/withPermission.tsx +0 -23
- package/src/kit/builder/auth/hooks/action-hooks.ts +0 -34
- package/src/kit/builder/auth/hooks/core-hooks.ts +0 -65
- package/src/kit/builder/auth/hooks/index.ts +0 -4
- package/src/kit/builder/auth/hooks/permission-hooks.ts +0 -43
- package/src/kit/builder/auth/hooks/token-hooks.ts +0 -25
- package/src/kit/builder/auth/index.ts +0 -132
- package/src/kit/builder/auth/providers/AuthProvider.tsx +0 -131
- package/src/kit/builder/auth/types/adapter-config.ts +0 -44
- package/src/kit/builder/auth/types/adapter.ts +0 -132
- package/src/kit/builder/auth/types/core.ts +0 -27
- package/src/kit/builder/auth/types/index.ts +0 -9
- package/src/kit/builder/auth/types/middleware.ts +0 -20
- package/src/kit/builder/auth/types/permissions.ts +0 -23
- package/src/kit/builder/auth/types/state.ts +0 -16
- package/src/kit/builder/auth/types/storage.ts +0 -21
- package/src/kit/builder/auth/types/token-manager.ts +0 -9
- package/src/kit/builder/auth/types/utils.ts +0 -55
- package/src/kit/builder/auth/utils/auth-adapter.ts +0 -437
- package/src/kit/builder/auth/utils/client-adapters/apollo-link.ts +0 -30
- package/src/kit/builder/auth/utils/client-adapters/axios.ts +0 -61
- package/src/kit/builder/auth/utils/client-adapters/fetch.ts +0 -48
- package/src/kit/builder/auth/utils/client-adapters/graphql.ts +0 -60
- package/src/kit/builder/auth/utils/client-adapters/index.ts +0 -6
- package/src/kit/builder/auth/utils/client-adapters/rest.ts +0 -60
- package/src/kit/builder/auth/utils/client-adapters/urql-exchange.ts +0 -76
- package/src/kit/builder/auth/utils/permission-checker.ts +0 -150
- package/src/kit/builder/auth/utils/storage/browser.ts +0 -99
- package/src/kit/builder/auth/utils/storage/cookie.ts +0 -116
- package/src/kit/builder/auth/utils/storage/encryption.ts +0 -80
- package/src/kit/builder/auth/utils/storage/env.ts +0 -2
- package/src/kit/builder/auth/utils/storage/factory.ts +0 -37
- package/src/kit/builder/auth/utils/storage/index.ts +0 -6
- package/src/kit/builder/auth/utils/storage/memory.ts +0 -15
- package/src/kit/builder/auth/utils/token-manager.ts +0 -55
- package/src/kit/builder/data-table/components/DataTable.tsx +0 -662
- package/src/kit/builder/data-table/components/DataTableColumnHeader.tsx +0 -67
- package/src/kit/builder/data-table/components/DataTableFilterPanel.tsx +0 -160
- package/src/kit/builder/data-table/components/DataTablePagination.tsx +0 -135
- package/src/kit/builder/data-table/components/DataTableViewOptions.tsx +0 -51
- package/src/kit/builder/data-table/index.ts +0 -6
- package/src/kit/builder/data-table/types.ts +0 -44
- package/src/kit/builder/data-table/utils/dotAccessor.ts +0 -6
- package/src/kit/builder/dialog/index.ts +0 -6
- package/src/kit/builder/dialog/provider.tsx +0 -170
- package/src/kit/builder/form/components/FormBuilder.tsx +0 -333
- package/src/kit/builder/form/components/FormBuilderActions.tsx +0 -78
- package/src/kit/builder/form/components/FormBuilderContext.tsx +0 -52
- package/src/kit/builder/form/components/FormBuilderField.tsx +0 -476
- package/src/kit/builder/form/components/fields/ArrayField.tsx +0 -312
- package/src/kit/builder/form/components/fields/AutocompleteField.tsx +0 -99
- package/src/kit/builder/form/components/fields/CheckboxField.tsx +0 -78
- package/src/kit/builder/form/components/fields/DateField.tsx +0 -55
- package/src/kit/builder/form/components/fields/DatePickerField.tsx +0 -48
- package/src/kit/builder/form/components/fields/DateRangePickerField.tsx +0 -72
- package/src/kit/builder/form/components/fields/DateTimePickerField.tsx +0 -55
- package/src/kit/builder/form/components/fields/DateTimeRangePickerField.tsx +0 -65
- package/src/kit/builder/form/components/fields/FileField.tsx +0 -38
- package/src/kit/builder/form/components/fields/MonthPickerField.tsx +0 -34
- package/src/kit/builder/form/components/fields/MonthRangePickerField.tsx +0 -42
- package/src/kit/builder/form/components/fields/NumberField.tsx +0 -88
- package/src/kit/builder/form/components/fields/ObjectField.tsx +0 -35
- package/src/kit/builder/form/components/fields/RadioField.tsx +0 -48
- package/src/kit/builder/form/components/fields/SelectField.tsx +0 -47
- package/src/kit/builder/form/components/fields/SwitchField.tsx +0 -76
- package/src/kit/builder/form/components/fields/TextField.tsx +0 -26
- package/src/kit/builder/form/components/fields/TextareaField.tsx +0 -21
- package/src/kit/builder/form/components/fields/TimePickerField.tsx +0 -36
- package/src/kit/builder/form/components/fields/TimeRangePickerField.tsx +0 -44
- package/src/kit/builder/form/components/fields/index.ts +0 -21
- package/src/kit/builder/form/components/fields/types.ts +0 -18
- package/src/kit/builder/form/components/index.ts +0 -3
- package/src/kit/builder/form/components/sectionNodes.tsx +0 -148
- package/src/kit/builder/form/hooks/useFormBuilder.ts +0 -457
- package/src/kit/builder/form/index.ts +0 -4
- package/src/kit/builder/form/types.ts +0 -294
- package/src/kit/builder/form/utils/common-forms.ts +0 -68
- package/src/kit/builder/form/utils/dependencies.ts +0 -56
- package/src/kit/builder/form/utils/field-factories.ts +0 -177
- package/src/kit/builder/form/utils/index.ts +0 -17
- package/src/kit/builder/form/utils/section-factories.ts +0 -38
- package/src/kit/builder/form/utils/transformers.ts +0 -100
- package/src/kit/builder/form/utils/validations.ts +0 -22
- package/src/kit/builder/form/utils/validators.ts +0 -20
- package/src/kit/builder/page/Page.tsx +0 -205
- package/src/kit/builder/page/PageBackButton.tsx +0 -52
- package/src/kit/builder/page/index.ts +0 -1
- package/src/kit/builder/section/SectionBuilder.tsx +0 -443
- package/src/kit/builder/section/SectionContainer.tsx +0 -85
- package/src/kit/builder/section/index.ts +0 -2
- package/src/kit/builder/section/types.ts +0 -83
- package/src/kit/builder/stack-dialog/context.ts +0 -15
- package/src/kit/builder/stack-dialog/hooks.ts +0 -13
- package/src/kit/builder/stack-dialog/index.ts +0 -12
- package/src/kit/builder/stack-dialog/provider.tsx +0 -51
- package/src/kit/builder/stack-dialog/renderer.tsx +0 -36
- package/src/kit/builder/stack-dialog/types.ts +0 -34
- package/src/kit/components/autocomplete/Autocomplete.tsx +0 -732
- package/src/kit/components/autocomplete/index.ts +0 -3
- package/src/kit/components/autocomplete/types.ts +0 -27
- package/src/kit/components/data-table-headers/DataTableHeader.tsx +0 -158
- package/src/kit/components/data-table-headers/DebouncedFilterField.tsx +0 -83
- package/src/kit/components/data-table-headers/FilterFieldRenderer.tsx +0 -194
- package/src/kit/components/data-table-headers/index.ts +0 -6
- package/src/kit/components/data-table-headers/types.ts +0 -89
- package/src/kit/components/data-table-headers/urlSerialization.ts +0 -173
- package/src/kit/components/data-table-headers/useDataTableHeaderUrl.ts +0 -107
- package/src/kit/components/datepicker/DatePicker.tsx +0 -173
- package/src/kit/components/datepicker/DateRangePicker.tsx +0 -526
- package/src/kit/components/datepicker/index.ts +0 -2
- package/src/kit/components/datetimepicker/DateTimePicker.tsx +0 -420
- package/src/kit/components/datetimepicker/DateTimeRangePicker.tsx +0 -676
- package/src/kit/components/datetimepicker/index.ts +0 -2
- package/src/kit/components/fileuploader/FileUploader.tsx +0 -880
- package/src/kit/components/fileuploader/image-preprocess.ts +0 -253
- package/src/kit/components/fileuploader/index.ts +0 -4
- package/src/kit/components/fileuploader/types.ts +0 -94
- package/src/kit/components/forminfo/FormInfoError.tsx +0 -135
- package/src/kit/components/forminfo/index.ts +0 -1
- package/src/kit/components/info-tooltip/InfoTooltip.tsx +0 -18
- package/src/kit/components/keyboard/Keyboard.tsx +0 -916
- package/src/kit/components/keyboard/index.ts +0 -4
- package/src/kit/components/login/Login.tsx +0 -141
- package/src/kit/components/login/index.ts +0 -1
- package/src/kit/components/monthpicker/MonthInput.tsx +0 -131
- package/src/kit/components/monthpicker/MonthPicker.tsx +0 -224
- package/src/kit/components/monthpicker/MonthRangeInput.tsx +0 -153
- package/src/kit/components/monthpicker/MonthRangePicker.tsx +0 -409
- package/src/kit/components/numpad/Numpad.tsx +0 -377
- package/src/kit/components/numpad/index.ts +0 -4
- package/src/kit/components/timepicker/TimePicker.tsx +0 -319
- package/src/kit/components/timepicker/TimeRangePicker.tsx +0 -368
- package/src/kit/components/timepicker/index.ts +0 -2
- package/src/kit/layouts/admin/components/AdminLayout.tsx +0 -419
- package/src/kit/layouts/admin/components/ThemeToggle.tsx +0 -54
- package/src/kit/layouts/admin/hooks/menu.ts +0 -32
- package/src/kit/layouts/admin/providers/AdminMenuProvider.tsx +0 -78
- package/src/kit/layouts/admin/types/index.ts +0 -26
- package/src/kit/providers/ThemeProvider.tsx +0 -90
- package/src/kit/themes/base.css +0 -11
- package/src/kit/themes/clean-slate.css +0 -155
- package/src/kit/themes/default.css +0 -197
- package/src/kit/themes/minimal-modern.css +0 -155
- package/src/kit/themes/spotify.css +0 -164
- package/src/shadcn/hooks/use-mobile.ts +0 -21
- package/src/shadcn/lib/utils.ts +0 -6
- package/src/shadcn/ui/accordion.tsx +0 -66
- package/src/shadcn/ui/alert-dialog.tsx +0 -157
- package/src/shadcn/ui/alert.tsx +0 -66
- package/src/shadcn/ui/aspect-ratio.tsx +0 -11
- package/src/shadcn/ui/avatar.tsx +0 -53
- package/src/shadcn/ui/badge.tsx +0 -46
- package/src/shadcn/ui/breadcrumb.tsx +0 -111
- package/src/shadcn/ui/button.tsx +0 -59
- package/src/shadcn/ui/calendar.tsx +0 -217
- package/src/shadcn/ui/card.tsx +0 -92
- package/src/shadcn/ui/carousel.tsx +0 -240
- package/src/shadcn/ui/chart.tsx +0 -353
- package/src/shadcn/ui/checkbox.tsx +0 -32
- package/src/shadcn/ui/collapsible.tsx +0 -33
- package/src/shadcn/ui/command.tsx +0 -184
- package/src/shadcn/ui/context-menu.tsx +0 -252
- package/src/shadcn/ui/dialog.tsx +0 -146
- package/src/shadcn/ui/drawer.tsx +0 -135
- package/src/shadcn/ui/dropdown-menu.tsx +0 -257
- package/src/shadcn/ui/form.tsx +0 -168
- package/src/shadcn/ui/hover-card.tsx +0 -44
- package/src/shadcn/ui/input-otp.tsx +0 -77
- package/src/shadcn/ui/input.tsx +0 -21
- package/src/shadcn/ui/label.tsx +0 -24
- package/src/shadcn/ui/menubar.tsx +0 -276
- package/src/shadcn/ui/navigation-menu.tsx +0 -168
- package/src/shadcn/ui/pagination.tsx +0 -128
- package/src/shadcn/ui/popover.tsx +0 -48
- package/src/shadcn/ui/progress.tsx +0 -31
- package/src/shadcn/ui/radio-group.tsx +0 -45
- package/src/shadcn/ui/resizable.tsx +0 -56
- package/src/shadcn/ui/scroll-area.tsx +0 -58
- package/src/shadcn/ui/select.tsx +0 -185
- package/src/shadcn/ui/separator.tsx +0 -28
- package/src/shadcn/ui/sheet.tsx +0 -139
- package/src/shadcn/ui/sidebar.tsx +0 -726
- package/src/shadcn/ui/skeleton.tsx +0 -13
- package/src/shadcn/ui/slider.tsx +0 -63
- package/src/shadcn/ui/sonner.tsx +0 -37
- package/src/shadcn/ui/switch.tsx +0 -31
- package/src/shadcn/ui/table.tsx +0 -134
- package/src/shadcn/ui/tabs.tsx +0 -66
- package/src/shadcn/ui/textarea.tsx +0 -18
- package/src/shadcn/ui/toggle-group.tsx +0 -73
- package/src/shadcn/ui/toggle.tsx +0 -47
- package/src/shadcn/ui/tooltip.tsx +0 -61
- package/src/stories/FileUploader.stories.tsx +0 -185
- package/src/stories/kit/builder/DataTable.Basic.stories.tsx +0 -71
- package/src/stories/kit/builder/DataTable.Filters.stories.tsx +0 -98
- package/src/stories/kit/builder/DataTable.Pagination.stories.tsx +0 -73
- package/src/stories/kit/builder/DataTable.SelectionAndActions.stories.tsx +0 -77
- package/src/stories/kit/builder/DataTable.Sorting.stories.tsx +0 -67
- package/src/stories/kit/builder/Dialog.stories.tsx +0 -90
- package/src/stories/kit/builder/Form.ArrayLayouts.stories.tsx +0 -177
- package/src/stories/kit/builder/Form.Autocomplete.stories.tsx +0 -220
- package/src/stories/kit/builder/Form.Basic.stories.tsx +0 -79
- package/src/stories/kit/builder/Form.Complex.stories.tsx +0 -569
- package/src/stories/kit/builder/Form.DateTime.stories.tsx +0 -70
- package/src/stories/kit/builder/Form.Dynamic.stories.tsx +0 -926
- package/src/stories/kit/builder/Form.Files.stories.tsx +0 -136
- package/src/stories/kit/builder/Form.MultipleFormBuilder.stories.tsx +0 -377
- package/src/stories/kit/builder/Form.Pickers.stories.tsx +0 -75
- package/src/stories/kit/builder/Form.Simple.stories.tsx +0 -91
- package/src/stories/kit/builder/Form.Time.stories.tsx +0 -68
- package/src/stories/kit/builder/Page.stories.tsx +0 -115
- package/src/stories/kit/builder/Section.stories.tsx +0 -282
- package/src/stories/kit/components/Autocomplete.stories.tsx +0 -313
- package/src/stories/kit/components/DatePicker.stories.tsx +0 -195
- package/src/stories/kit/components/DateRangePicker.stories.tsx +0 -195
- package/src/stories/kit/components/Keyboard.stories.tsx +0 -263
- package/src/stories/kit/components/Login.stories.tsx +0 -167
- package/src/stories/kit/components/MonthPicker.stories.tsx +0 -100
- package/src/stories/kit/components/MonthRangePicker.stories.tsx +0 -117
- package/src/stories/kit/components/Numpad.stories.tsx +0 -195
- package/src/stories/kit/components/TimePicker.stories.tsx +0 -71
- package/src/stories/kit/components/TimeRangePicker.stories.tsx +0 -43
- package/src/stories/kit/layouts/admin/AdminLayout.Basic.stories.tsx +0 -118
- package/src/stories/kit/layouts/admin/AdminLayout.Collapsible.stories.tsx +0 -81
- package/src/stories/kit/layouts/admin/AdminLayout.Complex.stories.tsx +0 -251
- package/src/stories/kit/layouts/admin/AdminLayout.CustomSidebarHeaderComponent.stories.tsx +0 -80
- package/src/stories/kit/layouts/admin/AdminLayout.CustomSidebarTitleAndIcon.stories.tsx +0 -70
- package/src/stories/kit/layouts/admin/AdminLayout.HeaderSlots.stories.tsx +0 -87
- package/src/stories/shadcn/ui/Accordion.stories.tsx +0 -117
- package/src/stories/shadcn/ui/Alert.stories.tsx +0 -36
- package/src/stories/shadcn/ui/AlertDialog.stories.tsx +0 -73
- package/src/stories/shadcn/ui/AspectRatio.stories.tsx +0 -58
- package/src/stories/shadcn/ui/Avatar.stories.tsx +0 -26
- package/src/stories/shadcn/ui/Badge.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Breadcrumb.stories.tsx +0 -47
- package/src/stories/shadcn/ui/Button.stories.tsx +0 -51
- package/src/stories/shadcn/ui/Calendar.stories.tsx +0 -33
- package/src/stories/shadcn/ui/Card.stories.tsx +0 -39
- package/src/stories/shadcn/ui/Carousel.stories.tsx +0 -37
- package/src/stories/shadcn/ui/Chart.stories.tsx +0 -72
- package/src/stories/shadcn/ui/Checkbox.stories.tsx +0 -64
- package/src/stories/shadcn/ui/Collapsible.stories.tsx +0 -40
- package/src/stories/shadcn/ui/Command.stories.tsx +0 -53
- package/src/stories/shadcn/ui/ContextMenu.stories.tsx +0 -67
- package/src/stories/shadcn/ui/Dialog.stories.tsx +0 -45
- package/src/stories/shadcn/ui/Drawer.stories.tsx +0 -49
- package/src/stories/shadcn/ui/DropdownMenu.stories.tsx +0 -75
- package/src/stories/shadcn/ui/Form.stories.tsx +0 -93
- package/src/stories/shadcn/ui/HoverCard.stories.tsx +0 -43
- package/src/stories/shadcn/ui/Input.stories.tsx +0 -41
- package/src/stories/shadcn/ui/InputOtp.stories.tsx +0 -39
- package/src/stories/shadcn/ui/Label.stories.tsx +0 -29
- package/src/stories/shadcn/ui/Menubar.stories.tsx +0 -87
- package/src/stories/shadcn/ui/NavigationMenu.stories.tsx +0 -78
- package/src/stories/shadcn/ui/Pagination.stories.tsx +0 -51
- package/src/stories/shadcn/ui/Popover.stories.tsx +0 -53
- package/src/stories/shadcn/ui/Progress.stories.tsx +0 -30
- package/src/stories/shadcn/ui/RadioGroup.stories.tsx +0 -31
- package/src/stories/shadcn/ui/Resizable.stories.tsx +0 -55
- package/src/stories/shadcn/ui/ScrollArea.stories.tsx +0 -84
- package/src/stories/shadcn/ui/Select.stories.tsx +0 -61
- package/src/stories/shadcn/ui/Separator.stories.tsx +0 -35
- package/src/stories/shadcn/ui/Sheet.stories.tsx +0 -48
- package/src/stories/shadcn/ui/Sidebar.stories.tsx +0 -131
- package/src/stories/shadcn/ui/Skeleton.stories.tsx +0 -23
- package/src/stories/shadcn/ui/Slider.stories.tsx +0 -21
- package/src/stories/shadcn/ui/Sonner.stories.tsx +0 -49
- package/src/stories/shadcn/ui/Switch.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Table.stories.tsx +0 -374
- package/src/stories/shadcn/ui/Tabs.stories.tsx +0 -31
- package/src/stories/shadcn/ui/Textarea.stories.tsx +0 -42
- package/src/stories/shadcn/ui/Toggle.stories.tsx +0 -44
- package/src/stories/shadcn/ui/ToggleGroup.stories.tsx +0 -28
- package/src/stories/shadcn/ui/Tooltip.stories.tsx +0 -30
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -52
- package/tsconfig.spec.json +0 -38
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.ts +0 -93
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { CanProps } from '../types';
|
|
2
|
-
import { useCan } from '../hooks';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component for conditional rendering based on permissions.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <Can permissions="post:edit" fallback={<ReadOnlyView />}>
|
|
10
|
-
* <EditButton />
|
|
11
|
-
* </Can>
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export function Can<
|
|
15
|
-
TRole extends string = string,
|
|
16
|
-
TPermission extends string = string,
|
|
17
|
-
>({
|
|
18
|
-
children,
|
|
19
|
-
fallback = null,
|
|
20
|
-
roles,
|
|
21
|
-
permissions,
|
|
22
|
-
requireAll = true,
|
|
23
|
-
}: CanProps<TRole, TPermission>) {
|
|
24
|
-
const allowed = useCan({ roles, permissions, requireAll });
|
|
25
|
-
if (!allowed) return fallback;
|
|
26
|
-
return children;
|
|
27
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { RequireAuthProps } from '../types';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component that requires authentication
|
|
6
|
-
* Optionally checks for specific roles and permissions
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* // Basic authentication check
|
|
11
|
-
* <RequireAuth fallback={<Login />}>
|
|
12
|
-
* <Dashboard />
|
|
13
|
-
* </RequireAuth>
|
|
14
|
-
*
|
|
15
|
-
* // With role check
|
|
16
|
-
* <RequireAuth
|
|
17
|
-
* roles="admin"
|
|
18
|
-
* fallback={<Forbidden />}
|
|
19
|
-
* loadingFallback={<Spinner />}
|
|
20
|
-
* >
|
|
21
|
-
* <AdminPanel />
|
|
22
|
-
* </RequireAuth>
|
|
23
|
-
*
|
|
24
|
-
* // With permission check
|
|
25
|
-
* <RequireAuth
|
|
26
|
-
* permissions={['post:edit', 'post:delete']}
|
|
27
|
-
* fallback={<Forbidden />}
|
|
28
|
-
* >
|
|
29
|
-
* <PostEditor />
|
|
30
|
-
* </RequireAuth>
|
|
31
|
-
*
|
|
32
|
-
* // Complex rule
|
|
33
|
-
* <RequireAuth
|
|
34
|
-
* roles={['admin', 'moderator']}
|
|
35
|
-
* permissions={{
|
|
36
|
-
* operator: 'OR',
|
|
37
|
-
* permissions: ['post:edit', 'post:delete']
|
|
38
|
-
* }}
|
|
39
|
-
* requireAll={false}
|
|
40
|
-
* fallback={<Forbidden />}
|
|
41
|
-
* >
|
|
42
|
-
* <ContentManager />
|
|
43
|
-
* </RequireAuth>
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export function RequireAuth<
|
|
47
|
-
TRole extends string = string,
|
|
48
|
-
TPermission extends string = string,
|
|
49
|
-
>({
|
|
50
|
-
children,
|
|
51
|
-
fallback = null,
|
|
52
|
-
loadingFallback = null,
|
|
53
|
-
roles,
|
|
54
|
-
permissions,
|
|
55
|
-
requireAll = true,
|
|
56
|
-
}: RequireAuthProps<TRole, TPermission>) {
|
|
57
|
-
const { status, can } = useAuthContext();
|
|
58
|
-
|
|
59
|
-
if (status === 'loading' || status === 'idle') {
|
|
60
|
-
return loadingFallback;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (status !== 'authenticated') {
|
|
64
|
-
return fallback;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!roles && !permissions) {
|
|
68
|
-
return children;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const allowed = can({ roles, permissions, requireAll });
|
|
72
|
-
|
|
73
|
-
if (!allowed) {
|
|
74
|
-
return fallback;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return children;
|
|
78
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component that shows children only when authenticated.
|
|
6
|
-
*/
|
|
7
|
-
export function ShowWhenAuthenticated({ children }: { children: ReactNode }) {
|
|
8
|
-
const { status } = useAuthContext();
|
|
9
|
-
return status === 'authenticated' ? children : null;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component that shows children only when there's an error.
|
|
6
|
-
*/
|
|
7
|
-
export function ShowWhenError({ children }: { children: ReactNode }) {
|
|
8
|
-
const { status } = useAuthContext();
|
|
9
|
-
return status === 'error' ? children : null;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component that shows children only while loading.
|
|
6
|
-
*/
|
|
7
|
-
export function ShowWhenLoading({ children }: { children: ReactNode }) {
|
|
8
|
-
const { status } = useAuthContext();
|
|
9
|
-
return status === 'loading' ? children : null;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Component that shows children only when NOT authenticated.
|
|
6
|
-
*/
|
|
7
|
-
export function ShowWhenUnauthenticated({ children }: { children: ReactNode }) {
|
|
8
|
-
const { status } = useAuthContext();
|
|
9
|
-
return status === 'unauthenticated' ? children : null;
|
|
10
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ComponentType } from 'react';
|
|
2
|
-
import type { WithPermissionOptions } from '../types';
|
|
3
|
-
import { useCan } from '../hooks';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Higher-order component that wraps a component with permission checks.
|
|
7
|
-
*/
|
|
8
|
-
export function withPermission<
|
|
9
|
-
TRole extends string = string,
|
|
10
|
-
TPermission extends string = string,
|
|
11
|
-
TProps extends Record<string, unknown> = Record<string, unknown>,
|
|
12
|
-
>(
|
|
13
|
-
Component: ComponentType<TProps>,
|
|
14
|
-
options: WithPermissionOptions<TRole, TPermission>,
|
|
15
|
-
): ComponentType<TProps> {
|
|
16
|
-
const WithPermissionWrapper = (props: TProps) => {
|
|
17
|
-
const allowed = useCan(options);
|
|
18
|
-
if (!allowed) return null;
|
|
19
|
-
return <Component {...props} />;
|
|
20
|
-
};
|
|
21
|
-
WithPermissionWrapper.displayName = `WithPermission(${Component.displayName ?? Component.name ?? 'Component'})`;
|
|
22
|
-
return WithPermissionWrapper as ComponentType<TProps>;
|
|
23
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { AuthSession } from '../types';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook to get the login function.
|
|
6
|
-
*/
|
|
7
|
-
export function useLogin<TCredentials = unknown>() {
|
|
8
|
-
const { login } = useAuthContext();
|
|
9
|
-
return login as ((credentials: TCredentials) => Promise<unknown>) | undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Hook to get the logout function.
|
|
14
|
-
*/
|
|
15
|
-
export function useLogout() {
|
|
16
|
-
const { logout } = useAuthContext();
|
|
17
|
-
return logout;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Hook to get the refresh function.
|
|
22
|
-
*/
|
|
23
|
-
export function useRefresh() {
|
|
24
|
-
const { refresh } = useAuthContext();
|
|
25
|
-
return refresh;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Hook to get the setSession function.
|
|
30
|
-
*/
|
|
31
|
-
export function useSetSession<TSession extends AuthSession>() {
|
|
32
|
-
const { setSession } = useAuthContext();
|
|
33
|
-
return setSession as (session: TSession | null) => Promise<unknown>;
|
|
34
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { AuthSession } from '../types';
|
|
2
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook to access the entire auth context
|
|
6
|
-
*/
|
|
7
|
-
export function useAuth() {
|
|
8
|
-
return useAuthContext();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Hook to get the current auth status
|
|
13
|
-
*/
|
|
14
|
-
export function useAuthStatus() {
|
|
15
|
-
const { status } = useAuthContext();
|
|
16
|
-
return status;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Hook to check if user is authenticated
|
|
21
|
-
*/
|
|
22
|
-
export function useIsAuthenticated() {
|
|
23
|
-
const { status } = useAuthContext();
|
|
24
|
-
return status === 'authenticated';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Hook to get the current session
|
|
29
|
-
*/
|
|
30
|
-
export function useAuthSession<TSession extends AuthSession>() {
|
|
31
|
-
const { session } = useAuthContext();
|
|
32
|
-
return session as TSession | null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Hook to get the current user
|
|
37
|
-
*/
|
|
38
|
-
export function useAuthUser<TUser>() {
|
|
39
|
-
const { user } = useAuthContext();
|
|
40
|
-
return user as TUser | null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Hook to get user roles
|
|
45
|
-
*/
|
|
46
|
-
export function useAuthRoles<TRole extends string = string>() {
|
|
47
|
-
const { roles } = useAuthContext();
|
|
48
|
-
return roles as TRole[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Hook to get user permissions
|
|
53
|
-
*/
|
|
54
|
-
export function useAuthPermissions<TPermission extends string = string>() {
|
|
55
|
-
const { permissions } = useAuthContext();
|
|
56
|
-
return permissions as TPermission[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Hook to get authentication error
|
|
61
|
-
*/
|
|
62
|
-
export function useAuthError() {
|
|
63
|
-
const { error } = useAuthContext();
|
|
64
|
-
return error;
|
|
65
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
PermissionPolicy,
|
|
3
|
-
PermissionRule,
|
|
4
|
-
WithPermissionOptions,
|
|
5
|
-
} from '../types';
|
|
6
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook to check if user has specific permission(s).
|
|
10
|
-
*/
|
|
11
|
-
export function usePermission<TPermission extends string = string>(
|
|
12
|
-
permission: TPermission | TPermission[] | PermissionPolicy<TPermission>,
|
|
13
|
-
options?: { requireAll?: boolean },
|
|
14
|
-
) {
|
|
15
|
-
const { hasPermission } = useAuthContext();
|
|
16
|
-
return hasPermission(permission, options);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Hook to check if user has specific role(s).
|
|
21
|
-
*/
|
|
22
|
-
export function useRole<TRole extends string = string>(
|
|
23
|
-
roles: TRole | TRole[],
|
|
24
|
-
options?: { requireAll?: boolean },
|
|
25
|
-
) {
|
|
26
|
-
const { hasRole } = useAuthContext();
|
|
27
|
-
return hasRole(roles, options);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Hook to check complex permission rules.
|
|
32
|
-
*/
|
|
33
|
-
export function useCan<
|
|
34
|
-
TRole extends string = string,
|
|
35
|
-
TPermission extends string = string,
|
|
36
|
-
>(
|
|
37
|
-
rule:
|
|
38
|
-
| WithPermissionOptions<TRole, TPermission>
|
|
39
|
-
| PermissionRule<TRole, TPermission>,
|
|
40
|
-
) {
|
|
41
|
-
const { can } = useAuthContext();
|
|
42
|
-
return can(rule as PermissionRule<TRole, TPermission>);
|
|
43
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useAuthContext } from '../providers/AuthProvider';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hook to get the current auth token.
|
|
5
|
-
*/
|
|
6
|
-
export function useAuthToken() {
|
|
7
|
-
const { getToken } = useAuthContext();
|
|
8
|
-
return getToken();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Hook to check if token is expired.
|
|
13
|
-
*/
|
|
14
|
-
export function useIsTokenExpired() {
|
|
15
|
-
const { isTokenExpired } = useAuthContext();
|
|
16
|
-
return isTokenExpired();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Hook to get time until token expiry in milliseconds.
|
|
21
|
-
*/
|
|
22
|
-
export function useTimeUntilExpiry() {
|
|
23
|
-
const { getTimeUntilExpiry } = useAuthContext();
|
|
24
|
-
return getTimeUntilExpiry();
|
|
25
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Core
|
|
3
|
-
// ============================================================================
|
|
4
|
-
|
|
5
|
-
export { createAuthAdapter } from "./utils/auth-adapter";
|
|
6
|
-
export { AuthProvider, useAuthContext } from "./providers/AuthProvider";
|
|
7
|
-
|
|
8
|
-
// ============================================================================
|
|
9
|
-
// Storage
|
|
10
|
-
// ============================================================================
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
createStorage,
|
|
14
|
-
createMemoryStorage,
|
|
15
|
-
createBrowserStorage,
|
|
16
|
-
createCookieStorage,
|
|
17
|
-
} from "./utils/storage";
|
|
18
|
-
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// Utilities
|
|
21
|
-
// ============================================================================
|
|
22
|
-
|
|
23
|
-
export { createTokenManager } from "./utils/token-manager";
|
|
24
|
-
export {
|
|
25
|
-
expandPermissions,
|
|
26
|
-
expandRoles,
|
|
27
|
-
checkPermissions,
|
|
28
|
-
checkRoles,
|
|
29
|
-
evaluatePermissionRule,
|
|
30
|
-
} from "./utils/permission-checker";
|
|
31
|
-
|
|
32
|
-
// ============================================================================
|
|
33
|
-
// Client Adapters
|
|
34
|
-
// ============================================================================
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
createGraphQLAuthAdapter,
|
|
38
|
-
createRESTAuthAdapter,
|
|
39
|
-
createAxiosAuthInterceptor,
|
|
40
|
-
createAuthFetch,
|
|
41
|
-
createApolloAuthLink,
|
|
42
|
-
} from "./utils/client-adapters";
|
|
43
|
-
|
|
44
|
-
export type {
|
|
45
|
-
GraphQLClientAdapterOptions,
|
|
46
|
-
RESTClientAdapterOptions,
|
|
47
|
-
} from "./utils/client-adapters";
|
|
48
|
-
|
|
49
|
-
// ============================================================================
|
|
50
|
-
// Hooks
|
|
51
|
-
// ============================================================================
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
useAuth,
|
|
55
|
-
useAuthStatus,
|
|
56
|
-
useIsAuthenticated,
|
|
57
|
-
useAuthSession,
|
|
58
|
-
useAuthUser,
|
|
59
|
-
useAuthRoles,
|
|
60
|
-
useAuthPermissions,
|
|
61
|
-
useAuthError,
|
|
62
|
-
usePermission,
|
|
63
|
-
useRole,
|
|
64
|
-
useCan,
|
|
65
|
-
useAuthToken,
|
|
66
|
-
useIsTokenExpired,
|
|
67
|
-
useTimeUntilExpiry,
|
|
68
|
-
useLogin,
|
|
69
|
-
useLogout,
|
|
70
|
-
useRefresh,
|
|
71
|
-
useSetSession,
|
|
72
|
-
} from "./hooks";
|
|
73
|
-
|
|
74
|
-
// ============================================================================
|
|
75
|
-
// Components
|
|
76
|
-
// ============================================================================
|
|
77
|
-
|
|
78
|
-
export { RequireAuth } from "./components/RequireAuth";
|
|
79
|
-
export { Can } from "./components/Can";
|
|
80
|
-
export { withPermission } from "./components/withPermission";
|
|
81
|
-
export { ShowWhenAuthenticated } from "./components/ShowWhenAuthenticated";
|
|
82
|
-
export { ShowWhenUnauthenticated } from "./components/ShowWhenUnauthenticated";
|
|
83
|
-
export { ShowWhenLoading } from "./components/ShowWhenLoading";
|
|
84
|
-
export { ShowWhenError } from "./components/ShowWhenError";
|
|
85
|
-
|
|
86
|
-
// ============================================================================
|
|
87
|
-
// Types
|
|
88
|
-
// ============================================================================
|
|
89
|
-
|
|
90
|
-
export type {
|
|
91
|
-
// Core types
|
|
92
|
-
AuthStatus,
|
|
93
|
-
TokenType,
|
|
94
|
-
RefreshStrategy,
|
|
95
|
-
AuthSession,
|
|
96
|
-
// Permission types
|
|
97
|
-
PermissionOperator,
|
|
98
|
-
PermissionPolicy,
|
|
99
|
-
PermissionRule,
|
|
100
|
-
PermissionHierarchy,
|
|
101
|
-
RoleHierarchy,
|
|
102
|
-
// State types
|
|
103
|
-
AuthAdapterState,
|
|
104
|
-
AuthAdapterSubscriber,
|
|
105
|
-
// Storage types
|
|
106
|
-
AuthStorage,
|
|
107
|
-
StorageType,
|
|
108
|
-
StorageOptions,
|
|
109
|
-
// Middleware types
|
|
110
|
-
AuthMiddleware,
|
|
111
|
-
// Token manager types
|
|
112
|
-
TokenManager,
|
|
113
|
-
// Adapter types
|
|
114
|
-
AuthAdapterConfig,
|
|
115
|
-
AuthAdapter,
|
|
116
|
-
// Context types
|
|
117
|
-
AuthContextValue,
|
|
118
|
-
// Component prop types
|
|
119
|
-
RequireAuthProps,
|
|
120
|
-
CanProps,
|
|
121
|
-
WithPermissionOptions,
|
|
122
|
-
// Client adapter types
|
|
123
|
-
GraphQLAuthClient,
|
|
124
|
-
RESTAuthClient,
|
|
125
|
-
ClientAdapter,
|
|
126
|
-
// Utility types
|
|
127
|
-
InferSession,
|
|
128
|
-
InferUser,
|
|
129
|
-
InferRole,
|
|
130
|
-
InferPermission,
|
|
131
|
-
InferCredentials,
|
|
132
|
-
} from "./types";
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useSyncExternalStore,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import type { ReactNode } from 'react';
|
|
9
|
-
import type { AuthAdapter, AuthContextValue, AuthSession } from '../types';
|
|
10
|
-
|
|
11
|
-
type AnyAuthContextValue = AuthContextValue<
|
|
12
|
-
unknown,
|
|
13
|
-
string,
|
|
14
|
-
string,
|
|
15
|
-
AuthSession<unknown, string, string>,
|
|
16
|
-
unknown
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
|
-
const AuthContext = createContext<AnyAuthContextValue | undefined>(undefined);
|
|
20
|
-
|
|
21
|
-
type AuthProviderProps<
|
|
22
|
-
TUser = unknown,
|
|
23
|
-
TRole extends string = string,
|
|
24
|
-
TPermission extends string = string,
|
|
25
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
26
|
-
TUser,
|
|
27
|
-
TRole,
|
|
28
|
-
TPermission
|
|
29
|
-
>,
|
|
30
|
-
TCredentials = unknown,
|
|
31
|
-
> = {
|
|
32
|
-
adapter: AuthAdapter<TUser, TRole, TPermission, TSession, TCredentials>;
|
|
33
|
-
children: ReactNode;
|
|
34
|
-
autoSync?: boolean;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* AuthProvider component - wraps your app with authentication context
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```tsx
|
|
42
|
-
* import { AuthProvider, createAuthAdapter } from '@k3mart/react-kit/auth2';
|
|
43
|
-
*
|
|
44
|
-
* const authAdapter = createAuthAdapter({
|
|
45
|
-
* // ... configuration
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* function App() {
|
|
49
|
-
* return (
|
|
50
|
-
* <AuthProvider adapter={authAdapter}>
|
|
51
|
-
* <YourApp />
|
|
52
|
-
* </AuthProvider>
|
|
53
|
-
* );
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export function AuthProvider<
|
|
58
|
-
TUser = unknown,
|
|
59
|
-
TRole extends string = string,
|
|
60
|
-
TPermission extends string = string,
|
|
61
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
62
|
-
TUser,
|
|
63
|
-
TRole,
|
|
64
|
-
TPermission
|
|
65
|
-
>,
|
|
66
|
-
TCredentials = unknown,
|
|
67
|
-
>({
|
|
68
|
-
adapter,
|
|
69
|
-
children,
|
|
70
|
-
autoSync = true,
|
|
71
|
-
}: AuthProviderProps<TUser, TRole, TPermission, TSession, TCredentials>) {
|
|
72
|
-
const state = useSyncExternalStore(
|
|
73
|
-
adapter.subscribe,
|
|
74
|
-
adapter.getState,
|
|
75
|
-
adapter.getState,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (!autoSync) return;
|
|
80
|
-
adapter.sync().catch(() => undefined);
|
|
81
|
-
}, [adapter, autoSync]);
|
|
82
|
-
|
|
83
|
-
const value = useMemo<
|
|
84
|
-
AuthContextValue<TUser, TRole, TPermission, TSession, TCredentials>
|
|
85
|
-
>(() => {
|
|
86
|
-
const login = adapter.login
|
|
87
|
-
? async (credentials: TCredentials) => {
|
|
88
|
-
if (!adapter.login) {
|
|
89
|
-
throw new Error('Login is not configured');
|
|
90
|
-
}
|
|
91
|
-
return await adapter.login(credentials);
|
|
92
|
-
}
|
|
93
|
-
: undefined;
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
state,
|
|
97
|
-
status: state.status,
|
|
98
|
-
session: state.session,
|
|
99
|
-
user: state.user,
|
|
100
|
-
roles: state.roles,
|
|
101
|
-
permissions: state.permissions,
|
|
102
|
-
error: state.error,
|
|
103
|
-
login,
|
|
104
|
-
logout: adapter.logout,
|
|
105
|
-
refresh: adapter.refresh,
|
|
106
|
-
setSession: adapter.setSession,
|
|
107
|
-
hasRole: adapter.hasRole,
|
|
108
|
-
hasPermission: adapter.hasPermission,
|
|
109
|
-
can: adapter.can,
|
|
110
|
-
getToken: adapter.getToken,
|
|
111
|
-
isTokenExpired: adapter.isTokenExpired,
|
|
112
|
-
getTimeUntilExpiry: adapter.getTimeUntilExpiry,
|
|
113
|
-
};
|
|
114
|
-
}, [adapter, state]);
|
|
115
|
-
|
|
116
|
-
const contextValue = value as unknown as AnyAuthContextValue;
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<AuthContext.Provider value={contextValue}>{children}</AuthContext.Provider>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Hook to access auth context
|
|
125
|
-
* Must be used within AuthProvider
|
|
126
|
-
*/
|
|
127
|
-
export function useAuthContext(): AnyAuthContextValue {
|
|
128
|
-
const ctx = useContext(AuthContext);
|
|
129
|
-
if (!ctx) throw new Error('useAuthContext must be used within AuthProvider');
|
|
130
|
-
return ctx;
|
|
131
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { AuthSession, RefreshStrategy } from './core';
|
|
2
|
-
import type { PermissionHierarchy, RoleHierarchy } from './permissions';
|
|
3
|
-
import type { AuthAdapterState } from './state';
|
|
4
|
-
import type { AuthMiddleware } from './middleware';
|
|
5
|
-
import type { TokenManager } from './token-manager';
|
|
6
|
-
import type { AuthStorage } from './storage';
|
|
7
|
-
|
|
8
|
-
export type AuthAdapterConfig<
|
|
9
|
-
TUser = unknown,
|
|
10
|
-
TRole extends string = string,
|
|
11
|
-
TPermission extends string = string,
|
|
12
|
-
TSession extends AuthSession<TUser, TRole, TPermission> = AuthSession<
|
|
13
|
-
TUser,
|
|
14
|
-
TRole,
|
|
15
|
-
TPermission
|
|
16
|
-
>,
|
|
17
|
-
TCredentials = unknown,
|
|
18
|
-
> = {
|
|
19
|
-
storage?: AuthStorage<TSession>;
|
|
20
|
-
loadSession?: () => Promise<TSession | null>;
|
|
21
|
-
login?: (credentials: TCredentials) => Promise<TSession>;
|
|
22
|
-
logout?: (session: TSession | null) => Promise<void> | void;
|
|
23
|
-
refresh?: (session: TSession) => Promise<TSession>;
|
|
24
|
-
resolveUser?: (session: TSession | null) => TUser | null;
|
|
25
|
-
resolveRoles?: (session: TSession | null) => TRole[];
|
|
26
|
-
resolvePermissions?: (session: TSession | null) => TPermission[];
|
|
27
|
-
shouldRefresh?: (session: TSession) => boolean;
|
|
28
|
-
onStateChange?: (
|
|
29
|
-
state: AuthAdapterState<TSession, TUser, TRole, TPermission>,
|
|
30
|
-
) => void;
|
|
31
|
-
|
|
32
|
-
refreshStrategy?: RefreshStrategy;
|
|
33
|
-
refreshThreshold?: number;
|
|
34
|
-
autoRefresh?: boolean;
|
|
35
|
-
permissionHierarchy?: PermissionHierarchy<TPermission>;
|
|
36
|
-
roleHierarchy?: RoleHierarchy<TRole>;
|
|
37
|
-
middleware?: AuthMiddleware<TSession, TUser, TRole, TPermission>[];
|
|
38
|
-
tokenManager?: TokenManager;
|
|
39
|
-
retryConfig?: {
|
|
40
|
-
maxRetries?: number;
|
|
41
|
-
retryDelay?: number;
|
|
42
|
-
retryOn?: (error: unknown) => boolean;
|
|
43
|
-
};
|
|
44
|
-
};
|