@contember/create 2.1.0-beta.2 → 2.2.0-alpha.1
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/development/run.cjs.map +1 -1
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +2 -2
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +1 -2
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +1 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +16 -16
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/version.cjs +2 -2
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/lib/version.js.map +1 -1
- package/dist/development/src/paths.cjs +3 -3
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +2 -2
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +1 -2
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +1 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +16 -16
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/version.cjs +2 -2
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/lib/version.js.map +1 -1
- package/dist/production/src/paths.cjs +3 -3
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/index.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +3 -2
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
- package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
- package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
- package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
- package/resources/templates/default/admin/lib/binding/index.ts +5 -5
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
- package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
- package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/board/board.tsx +2 -2
- package/resources/templates/default/admin/lib/board/index.ts +1 -1
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
- package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
- package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
- package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
- package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
- package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
- package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
- package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
- package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
- package/resources/templates/default/admin/lib/dev/index.ts +2 -2
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
- package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
- package/resources/templates/default/admin/lib/dict.ts +0 -261
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
- package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
- package/resources/templates/default/admin/lib/editor/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
- package/resources/templates/default/admin/lib/errors/index.ts +1 -1
- package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
- package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
- package/resources/templates/default/admin/lib/field/index.ts +2 -1
- package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
- package/resources/templates/default/admin/lib/form/container.tsx +33 -3
- package/resources/templates/default/admin/lib/form/index.ts +6 -5
- package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
- package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
- package/resources/templates/default/admin/lib/form/select.tsx +162 -5
- package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
- package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
- package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
- package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
- package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
- package/resources/templates/default/admin/lib/images/index.ts +1 -1
- package/resources/templates/default/admin/lib/index.ts +54 -0
- package/resources/templates/default/admin/lib/labels/index.ts +2 -2
- package/resources/templates/default/admin/lib/layout/index.ts +3 -3
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
- package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
- package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
- package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/default/admin/lib/select/index.ts +6 -6
- package/resources/templates/default/admin/lib/select/list.tsx +30 -6
- package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
- package/resources/templates/default/admin/lib/select/select.tsx +44 -6
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
- package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
- package/resources/templates/default/admin/lib/tenant/dict.ts +324 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +12 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
- package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
- package/resources/templates/default/admin/lib/tenant/index.ts +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +8 -8
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +1 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/toast/index.ts +2 -2
- package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
- package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
- package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
- package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
- package/resources/templates/default/admin/lib/upload/index.ts +3 -3
- package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
- package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
- package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
- package/resources/templates/default/admin/lib/utils/index.ts +2 -2
- package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
- package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
- package/src/commands/WorkspaceCreateCommand.ts +3 -3
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/src/run.ts +4 -4
|
@@ -4,14 +4,14 @@ import { Slot } from '@radix-ui/react-slot'
|
|
|
4
4
|
import { cva, VariantProps } from 'class-variance-authority'
|
|
5
5
|
import { PanelLeft } from 'lucide-react'
|
|
6
6
|
import { ComponentProps, CSSProperties, ElementRef, forwardRef, PropsWithChildren, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
|
|
7
|
-
import { cn, uic } from '../utils'
|
|
8
|
-
import { useIsMobile } from '../utils/use-mobile'
|
|
9
|
-
import { Button } from './button'
|
|
10
|
-
import { Input } from './input'
|
|
11
|
-
import { Separator } from './separator'
|
|
12
|
-
import { Sheet, SheetContent } from './sheet'
|
|
13
|
-
import { Skeleton } from './skeleton'
|
|
14
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './tooltip'
|
|
7
|
+
import { cn, uic } from '../utils/index.js'
|
|
8
|
+
import { useIsMobile } from '../utils/use-mobile.js'
|
|
9
|
+
import { Button } from './button.js'
|
|
10
|
+
import { Input } from './input.js'
|
|
11
|
+
import { Separator } from './separator.js'
|
|
12
|
+
import { Sheet, SheetContent } from './sheet.js'
|
|
13
|
+
import { Skeleton } from './skeleton.js'
|
|
14
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './tooltip.js'
|
|
15
15
|
|
|
16
16
|
const SIDEBAR_COOKIE_NAME = 'sidebar:state'
|
|
17
17
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group'
|
|
2
2
|
import * as React from 'react'
|
|
3
|
-
import { cn, uic } from '../utils'
|
|
4
|
-
import { toggleConfig, ToggleProps } from './toggle'
|
|
3
|
+
import { cn, uic } from '../utils/index.js'
|
|
4
|
+
import { toggleConfig, ToggleProps } from './toggle.js'
|
|
5
5
|
|
|
6
6
|
const ToggleGroupContext = React.createContext<ToggleProps>({
|
|
7
7
|
size: 'default',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip'
|
|
2
|
-
import { uic } from '../utils'
|
|
3
|
-
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
2
|
+
import { uic } from '../utils/index.js'
|
|
3
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks.js'
|
|
4
4
|
|
|
5
5
|
export const TooltipProvider = TooltipPrimitive.Provider
|
|
6
6
|
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { UploaderDropzoneArea, UploaderDropzoneRoot } from '@contember/react-uploader-dropzone'
|
|
3
3
|
import { useUploaderStateFiles } from '@contember/react-uploader'
|
|
4
|
-
import { UploaderDropzoneAreaUI, UploaderDropzoneWrapperUI, UploaderInactiveDropzoneUI } from './ui'
|
|
4
|
+
import { UploaderDropzoneAreaUI, UploaderDropzoneWrapperUI, UploaderInactiveDropzoneUI } from './ui.js'
|
|
5
5
|
import { ReactNode } from 'react'
|
|
6
6
|
import { UploadIcon } from 'lucide-react'
|
|
7
|
-
import { dict } from '
|
|
8
|
-
import { Button } from '
|
|
7
|
+
import { dict } from '~/lib'
|
|
8
|
+
import { Button } from '~/lib'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* `UploaderDropzone` renders a file drop area UI for uploading files, with optional
|
|
12
|
+
* placeholder customization and conditional display of a loader while uploads are in progress.
|
|
13
|
+
*
|
|
14
|
+
* Requires usage within an uploader context providing file upload state.
|
|
15
|
+
*
|
|
16
|
+
* - Displays a loader when uploads are active and `inactiveOnUpload` is `true`
|
|
17
|
+
* - Supports custom placeholder content via `dropzonePlaceholder`
|
|
18
|
+
*
|
|
19
|
+
* ## Example: Basic usage with custom placeholder
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <UploaderDropzone
|
|
22
|
+
* inactiveOnUpload
|
|
23
|
+
* dropzonePlaceholder={<div>Drop files here or click to upload</div>}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
10
27
|
export const UploaderDropzone = ({ inactiveOnUpload, dropzonePlaceholder }: { inactiveOnUpload?: boolean; dropzonePlaceholder?: ReactNode }) => {
|
|
11
28
|
const filesInProgress = useUploaderStateFiles({ state: ['uploading', 'initial', 'finalizing'] })
|
|
12
29
|
const showLoader = inactiveOnUpload && filesInProgress.length > 0
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './dropzone'
|
|
2
|
-
export * from './ui'
|
|
3
|
-
export * from './view'
|
|
1
|
+
export * from './dropzone.js'
|
|
2
|
+
export * from './ui.js'
|
|
3
|
+
export * from './view.js'
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { DropIndicator } from '
|
|
1
|
+
import { DropIndicator } from '~/lib'
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { RepeaterSortableDropIndicator } from '@contember/react-repeater-dnd-kit'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* UploaderRepeaterDropIndicator is a component that renders a drop indicator for a repeater.
|
|
7
|
+
* It is used to indicate where an item can be dropped in a repeater.
|
|
8
|
+
*/
|
|
5
9
|
export const UploaderRepeaterDropIndicator = ({ position }: { position: 'before' | 'after' }) => (
|
|
6
10
|
<div className={'relative'}>
|
|
7
11
|
<RepeaterSortableDropIndicator position={position}>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { Loader } from '
|
|
2
|
+
import { Loader } from '~/lib'
|
|
3
3
|
import { GripIcon } from 'lucide-react'
|
|
4
|
-
import { uic } from '
|
|
4
|
+
import { uic } from '~/lib'
|
|
5
5
|
|
|
6
6
|
export const UploaderDropzoneWrapperUI = uic('div', { baseClass: 'rounded-sm border border-gray-200 p-1 shadow-sm' })
|
|
7
7
|
export const UploaderDropzoneAreaUI = uic('div', {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CheckIcon, FileIcon, Loader2Icon, StopCircleIcon, XIcon } from 'lucide-react'
|
|
2
|
-
import { Button } from '
|
|
3
|
-
import { Progress } from '
|
|
2
|
+
import { Button } from '~/lib'
|
|
3
|
+
import { Progress } from '~/lib'
|
|
4
4
|
import * as React from 'react'
|
|
5
5
|
import { ReactNode, useEffect } from 'react'
|
|
6
|
-
import { Toast } from '
|
|
7
|
-
import { dict } from '
|
|
6
|
+
import { Toast } from '~/lib'
|
|
7
|
+
import { dict } from '~/lib'
|
|
8
8
|
import {
|
|
9
9
|
UploaderEachFile,
|
|
10
10
|
UploaderError,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
UploaderFileStateSwitch,
|
|
15
15
|
UploaderFileStateUploading,
|
|
16
16
|
} from '@contember/react-uploader'
|
|
17
|
-
import { formatBytes } from '../formatting/formatting'
|
|
18
|
-
import { Loader } from '
|
|
17
|
+
import { formatBytes } from '../formatting/formatting.js'
|
|
18
|
+
import { Loader } from '~/lib'
|
|
19
19
|
|
|
20
20
|
const formatError = (error: unknown) => {
|
|
21
21
|
if (error instanceof UploaderError) {
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
UploaderBase,
|
|
10
10
|
VideoFileDataExtractorProps,
|
|
11
11
|
} from '@contember/react-uploader'
|
|
12
|
-
import { formatBytes, formatDate, formatDuration } from '../formatting'
|
|
13
|
-
import { Button } from '
|
|
12
|
+
import { formatBytes, formatDate, formatDuration } from '../formatting/index.js'
|
|
13
|
+
import { Button } from '~/lib'
|
|
14
14
|
import { EditIcon, FileIcon, InfoIcon, TrashIcon } from 'lucide-react'
|
|
15
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
16
|
-
import { formatImageResizeUrl } from '../images'
|
|
15
|
+
import { Popover, PopoverContent, PopoverTrigger } from '~/lib'
|
|
16
|
+
import { formatImageResizeUrl } from '../images/index.js'
|
|
17
17
|
|
|
18
18
|
export type BaseFileViewProps = {
|
|
19
19
|
baseField?: SugaredRelativeSingleEntity['field']
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { ClassValue, clsx } from 'clsx'
|
|
2
2
|
import { twMerge } from 'tailwind-merge'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* `cn` is a utility function that combines Tailwind CSS class names using `clsx`
|
|
6
|
+
* and merges conflicting classes with `twMerge`.
|
|
7
|
+
*
|
|
8
|
+
* Useful for composing conditional and dynamic className values in React components
|
|
9
|
+
* with Tailwind, ensuring the final output avoids duplicates or conflicts.
|
|
10
|
+
*
|
|
11
|
+
* ## Example: Conditional class merging
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const Button = ({ isPrimary }: { isPrimary?: boolean }) => {
|
|
14
|
+
* return (
|
|
15
|
+
* <button className={cn('px-4 py-2', isPrimary && 'bg-blue-500', 'text-white')}>
|
|
16
|
+
* Click me
|
|
17
|
+
* </button>
|
|
18
|
+
* )
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
4
22
|
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(...inputs))
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import { ComponentType, memo, SetStateAction, useCallback, useState } from 'react'
|
|
2
2
|
import { createRequiredContext } from '@contember/react-utils'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* `createComponentOpenHooks` wraps a component that supports open state management
|
|
6
|
+
* (`open`, `defaultOpen`, `onOpenChange`) and injects context-based control and access hooks.
|
|
7
|
+
*
|
|
8
|
+
* It returns:
|
|
9
|
+
* - A `Component` wrapped with open state context
|
|
10
|
+
* - A `useOpen` hook to access and control the open state
|
|
11
|
+
*
|
|
12
|
+
* This is especially useful for modals, drawers, popovers, and similar toggleable UI components.
|
|
13
|
+
*
|
|
14
|
+
* ## Example: Creating a toggleable modal with context access
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const BaseModal: React.FC<{ open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void }> = ({ open, onOpenChange }) => (
|
|
17
|
+
* <div style={{ display: open ? 'block' : 'none' }}>
|
|
18
|
+
* <button onClick={() => onOpenChange?.(false)}>Close</button>
|
|
19
|
+
* <p>Modal Content</p>
|
|
20
|
+
* </div>
|
|
21
|
+
* )
|
|
22
|
+
*
|
|
23
|
+
* const { Component: ModalWithHooks, useOpen } = createComponentOpenHooks(BaseModal)
|
|
24
|
+
*
|
|
25
|
+
* const App = () => {
|
|
26
|
+
* const [open, setOpen] = useOpen()
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <>
|
|
30
|
+
* <button onClick={() => setOpen(true)}>Open Modal</button>
|
|
31
|
+
* <ModalWithHooks />
|
|
32
|
+
* </>
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
4
37
|
export const createComponentOpenHooks = <
|
|
5
38
|
P extends {
|
|
6
39
|
open?: boolean
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './cn'
|
|
2
|
-
export * from './uic'
|
|
1
|
+
export * from './cn.js'
|
|
2
|
+
export * from './uic.js'
|
|
@@ -47,6 +47,65 @@ export const uiconfig = <T extends ConfigSchema | undefined>(config: Config<T, C
|
|
|
47
47
|
|
|
48
48
|
export type NoInfer<T> = T & { [K in keyof T]: T[K] }
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Props are inferred from the base element and the provided config.
|
|
52
|
+
*
|
|
53
|
+
* `uic` is a utility function that enhances a base React component with configurable
|
|
54
|
+
* styling and structural behaviors using a utility-based class variance system (e.g., `cva`).
|
|
55
|
+
*
|
|
56
|
+
* It wraps the base component and provides features including:
|
|
57
|
+
* - Variant-based styling using `cva` configuration
|
|
58
|
+
* - Optional mapping of variant values to `data-*` attributes
|
|
59
|
+
* - Conditional rendering via `asChild` to support component composition
|
|
60
|
+
* - Structural wrapping of children (`wrapInner`) and of the whole component (`wrapOuter`)
|
|
61
|
+
* - Automatic filtering of unused variant props unless passed in `passVariantProps`
|
|
62
|
+
*
|
|
63
|
+
* The `wrapInner` and `wrapOuter` props in the config allow injecting extra layout structure:
|
|
64
|
+
* - `wrapInner`: Wraps the component's children in a custom element (e.g., for padding or effects)
|
|
65
|
+
* - `wrapOuter`: Wraps the entire rendered component (e.g., for layout constraints or portals)
|
|
66
|
+
*
|
|
67
|
+
* Must be used with a `Config` object that defines styling, variant options, and optional wrappers.
|
|
68
|
+
*
|
|
69
|
+
* ## Example: Basic usage with variant styling
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const Button = uic('button', {
|
|
72
|
+
* baseClass: 'px-4 py-2 font-bold',
|
|
73
|
+
* variants: {
|
|
74
|
+
* intent: {
|
|
75
|
+
* primary: 'bg-blue-500 text-white',
|
|
76
|
+
* secondary: 'bg-gray-500 text-white',
|
|
77
|
+
* },
|
|
78
|
+
* },
|
|
79
|
+
* defaultVariants: { intent: 'primary' },
|
|
80
|
+
* displayName: 'Button',
|
|
81
|
+
* })
|
|
82
|
+
*
|
|
83
|
+
* <Button intent="secondary">Click me</Button>
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* ## Example: Using `wrapInner` and `wrapOuter`
|
|
87
|
+
* ```tsx
|
|
88
|
+
* const Card = uic('div', {
|
|
89
|
+
* baseClass: 'bg-white shadow-md rounded',
|
|
90
|
+
* wrapInner: 'section',
|
|
91
|
+
* wrapOuter: ({ children }) => <div className="p-4 border">{children}</div>,
|
|
92
|
+
* displayName: 'Card',
|
|
93
|
+
* })
|
|
94
|
+
*
|
|
95
|
+
* <Card>
|
|
96
|
+
* <p>Hello world</p>
|
|
97
|
+
* </Card>
|
|
98
|
+
*
|
|
99
|
+
* // Results in:
|
|
100
|
+
* // <div class="p-4 border">
|
|
101
|
+
* // <div class="bg-white shadow-md rounded">
|
|
102
|
+
* // <section>
|
|
103
|
+
* // <p>Hello world</p>
|
|
104
|
+
* // </section>
|
|
105
|
+
* // </div>
|
|
106
|
+
* // </div>
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
50
109
|
export const uic = <El extends React.ElementType, Variants extends ConfigSchema | undefined = undefined>(
|
|
51
110
|
Component: El,
|
|
52
111
|
config: Config<Variants, NoInfer<El>>,
|
|
@@ -2,6 +2,25 @@ import { useEffect, useState } from 'react'
|
|
|
2
2
|
|
|
3
3
|
const MOBILE_BREAKPOINT = 768
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `useIsMobile` is a responsive utility hook that returns a boolean indicating
|
|
7
|
+
* whether the current viewport width is below the mobile breakpoint (768px).
|
|
8
|
+
*
|
|
9
|
+
* Useful for conditional rendering or styling based on mobile layout needs.
|
|
10
|
+
*
|
|
11
|
+
* ## Example: Conditional rendering for mobile
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const MyComponent = () => {
|
|
14
|
+
* const isMobile = useIsMobile()
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <div>
|
|
18
|
+
* {isMobile ? <MobileMenu /> : <DesktopMenu />}
|
|
19
|
+
* </div>
|
|
20
|
+
* )
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
5
24
|
export const useIsMobile = () => {
|
|
6
25
|
const [isMobile, setIsMobile] = useState(() => typeof window !== 'undefined' ? window.innerWidth < MOBILE_BREAKPOINT : false)
|
|
7
26
|
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Assembles the admin UI library (`admin/lib`) from the Contember UI packages.
|
|
3
|
+
//
|
|
4
|
+
// Since v2, `@contember/react-ui-lib` is split into three layered packages:
|
|
5
|
+
// - react-ui-lib-base ui primitives, utils, toast, form primitives, base dict
|
|
6
|
+
// - react-ui-lib-tenant tenant forms/listing/otp (+ tenant dict)
|
|
7
|
+
// - react-ui-lib the remaining high-level UI, depending on the two above
|
|
8
|
+
//
|
|
9
|
+
// The project template ships these merged back into a single, fully-owned
|
|
10
|
+
// `admin/lib` source tree (so the user can freely customise it). This script is
|
|
11
|
+
// the single source of truth for that merge and is used both at package
|
|
12
|
+
// pre-build time and by `scripts/update-ui-lib.sh` when updating an existing
|
|
13
|
+
// project. It also handles the legacy single-package layout for back-compat.
|
|
14
|
+
//
|
|
15
|
+
// Layout produced:
|
|
16
|
+
// base/src/* -> <target>/* (flat)
|
|
17
|
+
// tenant/src/* -> <target>/tenant/*
|
|
18
|
+
// main/src/* -> <target>/* (flat)
|
|
19
|
+
// with the colliding `index.ts` and `form/index.ts` barrels merged, and the
|
|
20
|
+
// `@contember/react-ui-lib-base|tenant` imports rewritten to `~/lib`-relative
|
|
21
|
+
// paths. `tsconfig.json` files are stripped.
|
|
22
|
+
import { existsSync, rmSync, mkdirSync, cpSync, readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs'
|
|
23
|
+
import { join } from 'node:path'
|
|
24
|
+
|
|
25
|
+
const args = process.argv.slice(2)
|
|
26
|
+
const getArg = name => {
|
|
27
|
+
const i = args.indexOf(name)
|
|
28
|
+
return i === -1 ? undefined : args[i + 1]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const packagesDir = getArg('--packages-dir')
|
|
32
|
+
const target = getArg('--target')
|
|
33
|
+
if (!packagesDir || !target) {
|
|
34
|
+
console.error('Usage: assemble-ui-lib.mjs --packages-dir <dir> --target <dir>')
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const mainSrc = join(packagesDir, 'react-ui-lib', 'src')
|
|
39
|
+
const baseSrc = join(packagesDir, 'react-ui-lib-base', 'src')
|
|
40
|
+
const tenantSrc = join(packagesDir, 'react-ui-lib-tenant', 'src')
|
|
41
|
+
|
|
42
|
+
if (!existsSync(mainSrc)) {
|
|
43
|
+
console.error(`Source not found: ${mainSrc}`)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const isSourceFile = name => name.endsWith('.ts') || name.endsWith('.tsx')
|
|
48
|
+
|
|
49
|
+
const walk = function* (dir) {
|
|
50
|
+
for (const entry of readdirSync(dir)) {
|
|
51
|
+
const full = join(dir, entry)
|
|
52
|
+
if (statSync(full).isDirectory()) {
|
|
53
|
+
yield* walk(full)
|
|
54
|
+
} else {
|
|
55
|
+
yield full
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rewriteImports = content =>
|
|
61
|
+
content
|
|
62
|
+
.replaceAll('@contember/react-ui-lib-tenant', '~/lib/tenant')
|
|
63
|
+
.replaceAll('@contember/react-ui-lib-base', '~/lib')
|
|
64
|
+
|
|
65
|
+
// Reset target.
|
|
66
|
+
rmSync(target, { recursive: true, force: true })
|
|
67
|
+
mkdirSync(target, { recursive: true })
|
|
68
|
+
|
|
69
|
+
const split = existsSync(baseSrc) && existsSync(tenantSrc)
|
|
70
|
+
|
|
71
|
+
if (!split) {
|
|
72
|
+
// Legacy single-package layout: copy the source tree, dropping the package
|
|
73
|
+
// barrel (the project consumes granular `~/lib/*` paths, not a root barrel).
|
|
74
|
+
cpSync(mainSrc, target, { recursive: true })
|
|
75
|
+
rmSync(join(target, 'index.ts'), { force: true })
|
|
76
|
+
} else {
|
|
77
|
+
// Base flat into the root, tenant under tenant/, main flat into the root.
|
|
78
|
+
// Main overwrites the colliding `index.ts` and `form/index.ts`; we rebuild
|
|
79
|
+
// those barrels below.
|
|
80
|
+
cpSync(baseSrc, target, { recursive: true })
|
|
81
|
+
cpSync(tenantSrc, join(target, 'tenant'), { recursive: true })
|
|
82
|
+
cpSync(mainSrc, target, { recursive: true })
|
|
83
|
+
|
|
84
|
+
// Merge the top-level barrel: inline base's exports and point tenant at the
|
|
85
|
+
// local tenant/ directory, then drop duplicate re-exports.
|
|
86
|
+
const baseIndex = readFileSync(join(baseSrc, 'index.ts'), 'utf8').trim()
|
|
87
|
+
const mainIndex = readFileSync(join(mainSrc, 'index.ts'), 'utf8')
|
|
88
|
+
const mergedIndex = mainIndex
|
|
89
|
+
.replace(/^export \* from '@contember\/react-ui-lib-base'$/m, baseIndex)
|
|
90
|
+
.replace(/^export \* from '@contember\/react-ui-lib-tenant'$/m, "export * from './tenant'")
|
|
91
|
+
const seen = new Set()
|
|
92
|
+
const dedupedIndex = mergedIndex
|
|
93
|
+
.split('\n')
|
|
94
|
+
.filter(line => {
|
|
95
|
+
const trimmed = line.trim()
|
|
96
|
+
if (trimmed.startsWith('export * from') && seen.has(trimmed)) {
|
|
97
|
+
return false
|
|
98
|
+
}
|
|
99
|
+
if (trimmed.startsWith('export * from')) {
|
|
100
|
+
seen.add(trimmed)
|
|
101
|
+
}
|
|
102
|
+
return true
|
|
103
|
+
})
|
|
104
|
+
.join('\n')
|
|
105
|
+
writeFileSync(join(target, 'index.ts'), dedupedIndex)
|
|
106
|
+
|
|
107
|
+
// Merge the form barrel: base's form primitives live in form/ui after the
|
|
108
|
+
// flat copy, so re-export them via the local ./ui module.
|
|
109
|
+
const mainFormIndex = readFileSync(join(mainSrc, 'form', 'index.ts'), 'utf8')
|
|
110
|
+
const mergedFormIndex = mainFormIndex.replace(
|
|
111
|
+
/^export \{[^}]*\} from '@contember\/react-ui-lib-base'$/m,
|
|
112
|
+
"export * from './ui'",
|
|
113
|
+
)
|
|
114
|
+
writeFileSync(join(target, 'form', 'index.ts'), mergedFormIndex)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Rewrite package imports to local `~/lib` paths and strip tsconfig files.
|
|
118
|
+
for (const file of walk(target)) {
|
|
119
|
+
if (file.endsWith('tsconfig.json')) {
|
|
120
|
+
rmSync(file)
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
if (isSourceFile(file)) {
|
|
124
|
+
const content = readFileSync(file, 'utf8')
|
|
125
|
+
const rewritten = rewriteImports(content)
|
|
126
|
+
if (rewritten !== content) {
|
|
127
|
+
writeFileSync(file, rewritten)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`Assembled admin UI library into ${target} (${split ? 'split' : 'legacy'} layout)`)
|