@contember/create 2.1.0-alpha.30 → 2.1.0-alpha.36
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 +6 -4
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +6 -4
- package/dist/development/run.js.map +1 -1
- 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.map +1 -1
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +4 -7
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +4 -7
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.js.map +1 -1
- 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.map +1 -1
- package/dist/development/src/paths.js.map +1 -1
- package/dist/production/run.cjs +6 -4
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +6 -4
- package/dist/production/run.js.map +1 -1
- 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.map +1 -1
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +4 -7
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +4 -7
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.js.map +1 -1
- 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.map +1 -1
- package/dist/production/src/paths.js.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/package.json +12 -7
- package/resources/templates/default/.github/workflows/deploy.yaml +1 -1
- package/resources/templates/default/admin/.env.production +6 -0
- package/resources/templates/default/admin/app/pages/tenant.tsx +2 -2
- package/resources/templates/default/admin/lib/binding/binding.tsx +0 -2
- package/resources/templates/default/admin/lib/binding/hooks.tsx +14 -8
- package/resources/templates/default/admin/lib/binding/identity.tsx +31 -30
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +12 -8
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +10 -12
- package/resources/templates/default/admin/lib/board/board.tsx +59 -45
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +49 -35
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +47 -38
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +128 -105
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +8 -4
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +1 -4
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +14 -14
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +34 -20
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +0 -1
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +24 -30
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +2 -3
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +0 -3
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +35 -29
- package/resources/templates/default/admin/lib/datagrid/index.ts +21 -21
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +0 -1
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +2 -7
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +32 -37
- package/resources/templates/default/admin/lib/datagrid/table.tsx +7 -5
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +10 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +10 -7
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +10 -13
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +23 -16
- package/resources/templates/default/admin/lib/dict.ts +14 -4
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +20 -8
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +22 -10
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +0 -2
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +155 -33
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +3 -1
- package/resources/templates/default/admin/lib/editor/common/editor-canvas.tsx +5 -3
- package/resources/templates/default/admin/lib/editor/common/editor-editable-canvas.tsx +0 -1
- package/resources/templates/default/admin/lib/editor/common/editor-inline-toolbar.tsx +4 -1
- package/resources/templates/default/admin/lib/editor/common/elements/AnchorRenderer.tsx +18 -16
- package/resources/templates/default/admin/lib/editor/common/elements/BlockElement.tsx +46 -34
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +2 -7
- package/resources/templates/default/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +1 -5
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +16 -9
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +11 -6
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +6 -7
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +31 -25
- package/resources/templates/default/admin/lib/form/container.tsx +20 -14
- package/resources/templates/default/admin/lib/form/inputs.tsx +10 -6
- package/resources/templates/default/admin/lib/form/select.tsx +74 -42
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +56 -56
- package/resources/templates/default/admin/lib/form/upload.tsx +61 -65
- package/resources/templates/default/admin/lib/labels/enum-labels.ts +6 -3
- package/resources/templates/default/admin/lib/labels/field-labels.ts +4 -2
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +36 -26
- package/resources/templates/default/admin/lib/layout/slots.tsx +1 -4
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +10 -4
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +21 -12
- package/resources/templates/default/admin/lib/select/create-new.tsx +0 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +0 -1
- package/resources/templates/default/admin/lib/select/list.tsx +33 -28
- package/resources/templates/default/admin/lib/select/multi-select.tsx +66 -70
- package/resources/templates/default/admin/lib/select/select.tsx +77 -72
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +84 -82
- package/resources/templates/default/admin/lib/select/ui.tsx +7 -5
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +21 -8
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +21 -12
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +9 -5
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +12 -7
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +26 -7
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +31 -19
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +9 -5
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +21 -8
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +9 -5
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +25 -12
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +3 -4
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +2 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +5 -3
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +13 -2
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +17 -11
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +6 -4
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +86 -59
- package/resources/templates/default/admin/lib/toast/toast.tsx +24 -22
- package/resources/templates/default/admin/lib/toast/toaster.tsx +0 -1
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +4 -3
- package/resources/templates/default/admin/lib/ui/button.tsx +2 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +12 -8
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +17 -14
- package/resources/templates/default/admin/lib/ui/loader.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/menu.tsx +3 -11
- package/resources/templates/default/admin/lib/ui/overlay.tsx +11 -9
- package/resources/templates/default/admin/lib/ui/popover.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +11 -11
- package/resources/templates/default/admin/lib/ui/select.tsx +1 -2
- package/resources/templates/default/admin/lib/ui/sheet.tsx +6 -5
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +41 -30
- package/resources/templates/default/admin/lib/ui/switch.tsx +5 -3
- package/resources/templates/default/admin/lib/ui/textarea.tsx +7 -4
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +9 -5
- package/resources/templates/default/admin/lib/ui/toggle.tsx +3 -4
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -1
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +14 -10
- package/resources/templates/default/admin/lib/upload/repeater.tsx +0 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +0 -4
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +27 -11
- package/resources/templates/default/admin/lib/upload/view.tsx +129 -67
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +10 -6
- package/resources/templates/default/admin/lib/utils/uic.tsx +24 -14
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +1 -3
- package/resources/templates/default/admin/package.json +2 -3
- package/resources/templates/default/admin/vite.config.ts +1 -1
- package/src/commands/WorkspaceCreateCommand.ts +0 -1
- package/src/lib/TemplateInstaller.ts +3 -6
- package/src/run.ts +8 -7
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/resources/templates/default/admin/postcss.config.js +0 -5
|
@@ -3,18 +3,7 @@ import { dataAttribute } from '@contember/utilities'
|
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot'
|
|
4
4
|
import { cva, VariantProps } from 'class-variance-authority'
|
|
5
5
|
import { PanelLeft } from 'lucide-react'
|
|
6
|
-
import {
|
|
7
|
-
ComponentProps,
|
|
8
|
-
CSSProperties,
|
|
9
|
-
ElementRef,
|
|
10
|
-
forwardRef,
|
|
11
|
-
PropsWithChildren,
|
|
12
|
-
ReactNode,
|
|
13
|
-
useCallback,
|
|
14
|
-
useEffect,
|
|
15
|
-
useMemo,
|
|
16
|
-
useState,
|
|
17
|
-
} from 'react'
|
|
6
|
+
import { ComponentProps, CSSProperties, ElementRef, forwardRef, PropsWithChildren, ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
|
|
18
7
|
import { cn, uic } from '../utils'
|
|
19
8
|
import { useIsMobile } from '../utils/use-mobile'
|
|
20
9
|
import { Button } from './button'
|
|
@@ -52,7 +41,10 @@ interface SidebarProviderProps extends PropsWithChildren {
|
|
|
52
41
|
const [ctx, useSidebar] = createRequiredContext<SidebarContext>('SidebarContext')
|
|
53
42
|
|
|
54
43
|
export const SidebarProvider = ({
|
|
55
|
-
defaultOpen = true,
|
|
44
|
+
defaultOpen = true,
|
|
45
|
+
open: openProp,
|
|
46
|
+
onOpenChange,
|
|
47
|
+
children,
|
|
56
48
|
}: SidebarProviderProps) => {
|
|
57
49
|
const isMobile = useIsMobile()
|
|
58
50
|
const [openMobile, setOpenMobile] = useState(false)
|
|
@@ -70,6 +62,7 @@ export const SidebarProvider = ({
|
|
|
70
62
|
_setOpen(openState)
|
|
71
63
|
}
|
|
72
64
|
|
|
65
|
+
// biome-ignore lint/suspicious/noDocumentCookie: sidebar state persistence
|
|
73
66
|
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
|
|
74
67
|
},
|
|
75
68
|
[onOpenChange, open],
|
|
@@ -80,8 +73,8 @@ export const SidebarProvider = ({
|
|
|
80
73
|
useEffect(() => {
|
|
81
74
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
82
75
|
if (
|
|
83
|
-
event.key === SIDEBAR_KEYBOARD_SHORTCUT
|
|
84
|
-
(event.metaKey || event.ctrlKey)
|
|
76
|
+
event.key === SIDEBAR_KEYBOARD_SHORTCUT
|
|
77
|
+
&& (event.metaKey || event.ctrlKey)
|
|
85
78
|
) {
|
|
86
79
|
event.preventDefault()
|
|
87
80
|
toggleSidebar()
|
|
@@ -92,6 +85,7 @@ export const SidebarProvider = ({
|
|
|
92
85
|
return () => window.removeEventListener('keydown', handleKeyDown)
|
|
93
86
|
}, [toggleSidebar])
|
|
94
87
|
|
|
88
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentional
|
|
95
89
|
const contextValue = useMemo(
|
|
96
90
|
() => ({
|
|
97
91
|
state: open ? 'expanded' : 'collapsed',
|
|
@@ -116,7 +110,8 @@ export const SidebarProvider = ({
|
|
|
116
110
|
SidebarProvider.displayName = 'SidebarProvider'
|
|
117
111
|
|
|
118
112
|
export const SidebarLayout = uic('div', {
|
|
119
|
-
baseClass:
|
|
113
|
+
baseClass:
|
|
114
|
+
'group/sidebar-wrapper grid min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar max-h-screen max-w-[100vw] overflow-y-auto md:grid-cols-[auto_1fr_auto]',
|
|
120
115
|
// Add grid template columns
|
|
121
116
|
style: {
|
|
122
117
|
'--sidebar-width': SIDEBAR_WIDTH,
|
|
@@ -169,7 +164,8 @@ const SidebarDesktopGap = uic('div', {
|
|
|
169
164
|
],
|
|
170
165
|
variants: {
|
|
171
166
|
variant: {
|
|
172
|
-
floating:
|
|
167
|
+
floating:
|
|
168
|
+
'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))] 2xl:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon-large)_+_theme(spacing.4))]',
|
|
173
169
|
inset: 'group-data-[collapsible=icon]:w-5',
|
|
174
170
|
sidebar: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) 2xl:group-data-[collapsible=icon]:w-(--sidebar-width-icon-large)',
|
|
175
171
|
},
|
|
@@ -181,20 +177,25 @@ const SidebarInner = uic('div', {
|
|
|
181
177
|
baseClass: 'duration-200 fixed inset-y-0 z-10 hidden h-svh transition-[left,right,width] ease-linear md:block',
|
|
182
178
|
variants: {
|
|
183
179
|
side: {
|
|
184
|
-
left:
|
|
185
|
-
|
|
180
|
+
left:
|
|
181
|
+
'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] 2xl:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width-large)*-1)]',
|
|
182
|
+
right:
|
|
183
|
+
'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] 2xl:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width-large)*-1)]',
|
|
186
184
|
},
|
|
187
185
|
variant: {
|
|
188
|
-
floating:
|
|
186
|
+
floating:
|
|
187
|
+
'p-2 w-(--sidebar-width) 2xl:w-(--sidebar-width-large) group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)] 2xl:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon-large)_+_theme(spacing.4)_+2px)]',
|
|
189
188
|
inset: 'p-2 w-(--sidebar-width) 2xl:w-(--sidebar-width-large) group-data-[collapsible=icon]:w-5',
|
|
190
|
-
sidebar:
|
|
189
|
+
sidebar:
|
|
190
|
+
'w-(--sidebar-width) 2xl:w-(--sidebar-width-large) group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=left]:border-gray-200 group-data-[side=right]:border-l 2xl:group-data-[collapsible=icon]:w-(--sidebar-width-icon-large)',
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
193
|
variantsAsDataAttrs: ['variant', 'side'],
|
|
194
|
-
wrapInner: ({ children }) =>
|
|
194
|
+
wrapInner: ({ children }) => (
|
|
195
195
|
<div data-sidebar="sidebar" className="grid h-full w-full grid-rows-[auto_1fr_auto]">
|
|
196
196
|
{children}
|
|
197
|
-
</div
|
|
197
|
+
</div>
|
|
198
|
+
),
|
|
198
199
|
displayName: 'SidebarInner',
|
|
199
200
|
})
|
|
200
201
|
|
|
@@ -251,7 +252,6 @@ export const Sidebar = forwardRef<HTMLDivElement, SidebarProps>(
|
|
|
251
252
|
)
|
|
252
253
|
Sidebar.displayName = 'Sidebar'
|
|
253
254
|
|
|
254
|
-
|
|
255
255
|
export const SidebarTrigger = forwardRef<ElementRef<typeof Button>, ComponentProps<typeof Button>>(({
|
|
256
256
|
className,
|
|
257
257
|
onClick,
|
|
@@ -260,10 +260,18 @@ export const SidebarTrigger = forwardRef<ElementRef<typeof Button>, ComponentPro
|
|
|
260
260
|
const { toggleSidebar } = useSidebar()
|
|
261
261
|
|
|
262
262
|
return (
|
|
263
|
-
<Button
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
<Button
|
|
264
|
+
ref={ref}
|
|
265
|
+
data-sidebar="trigger"
|
|
266
|
+
variant="ghost"
|
|
267
|
+
size="icon"
|
|
268
|
+
className={cn('h-7 w-7', className)}
|
|
269
|
+
onClick={event => {
|
|
270
|
+
onClick?.(event)
|
|
271
|
+
toggleSidebar()
|
|
272
|
+
}}
|
|
273
|
+
{...props}
|
|
274
|
+
>
|
|
267
275
|
<PanelLeft size={16} />
|
|
268
276
|
<span className="sr-only">Toggle Sidebar</span>
|
|
269
277
|
</Button>
|
|
@@ -473,7 +481,9 @@ export const SidebarMenuButton = forwardRef<HTMLAnchorElement, SidebarMenuButton
|
|
|
473
481
|
side="right"
|
|
474
482
|
align="center"
|
|
475
483
|
hidden={state !== 'collapsed' || isMobile}
|
|
476
|
-
>
|
|
484
|
+
>
|
|
485
|
+
{tooltip}
|
|
486
|
+
</TooltipContent>
|
|
477
487
|
</Tooltip>
|
|
478
488
|
)
|
|
479
489
|
},
|
|
@@ -497,7 +507,8 @@ export const SidebarMenuAction = uic('button', {
|
|
|
497
507
|
},
|
|
498
508
|
variants: {
|
|
499
509
|
showInHover: {
|
|
500
|
-
true:
|
|
510
|
+
true:
|
|
511
|
+
'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0',
|
|
501
512
|
},
|
|
502
513
|
},
|
|
503
514
|
displayName: '',
|
|
@@ -3,7 +3,9 @@ import * as React from 'react'
|
|
|
3
3
|
import { uic } from '../utils'
|
|
4
4
|
|
|
5
5
|
export const Switch = uic(SwitchPrimitives.Root, {
|
|
6
|
-
baseClass:
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
baseClass:
|
|
7
|
+
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
|
8
|
+
afterChildren: (
|
|
9
|
+
<SwitchPrimitives.Thumb className="pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0" />
|
|
10
|
+
),
|
|
9
11
|
})
|
|
@@ -15,10 +15,13 @@ export const Textarea = uic('textarea', {
|
|
|
15
15
|
displayName: 'Textarea',
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
export const TextareaAutosize = forwardRef<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export const TextareaAutosize = forwardRef<
|
|
19
|
+
HTMLTextAreaElement,
|
|
20
|
+
ComponentProps<typeof Textarea> & {
|
|
21
|
+
minRows?: number
|
|
22
|
+
maxRows?: number
|
|
23
|
+
}
|
|
24
|
+
>(({ minRows, maxRows, ...props }, ref) => {
|
|
22
25
|
const innerRef = useRef<HTMLTextAreaElement | null>(null)
|
|
23
26
|
useAutoHeightTextArea(innerRef, props.value?.toString() ?? '', minRows ?? 3, maxRows ?? 100)
|
|
24
27
|
|
|
@@ -10,8 +10,8 @@ const ToggleGroupContext = React.createContext<ToggleProps>({
|
|
|
10
10
|
|
|
11
11
|
const ToggleGroup = React.forwardRef<
|
|
12
12
|
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
13
|
-
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root>
|
|
14
|
-
ToggleProps
|
|
13
|
+
& React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root>
|
|
14
|
+
& ToggleProps
|
|
15
15
|
>(({ className, variant, size, children, ...props }, ref) => (
|
|
16
16
|
<ToggleGroupPrimitive.Root
|
|
17
17
|
ref={ref}
|
|
@@ -30,12 +30,16 @@ const ToggleGroupItemInner = uic(ToggleGroupPrimitive.Item, toggleConfig)
|
|
|
30
30
|
|
|
31
31
|
const ToggleGroupItem = React.forwardRef<
|
|
32
32
|
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
33
|
-
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item>
|
|
34
|
-
ToggleProps
|
|
33
|
+
& React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item>
|
|
34
|
+
& ToggleProps
|
|
35
35
|
>(({ className, children, variant, size, ...props }, ref) => {
|
|
36
36
|
const context = React.useContext(ToggleGroupContext)
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return (
|
|
39
|
+
<ToggleGroupItemInner ref={ref} className={className} variant={context.variant || variant} size={context.size || size} {...props}>
|
|
40
|
+
{children}
|
|
41
|
+
</ToggleGroupItemInner>
|
|
42
|
+
)
|
|
39
43
|
})
|
|
40
44
|
|
|
41
45
|
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
|
|
@@ -2,12 +2,12 @@ import * as TogglePrimitive from '@radix-ui/react-toggle'
|
|
|
2
2
|
import { ConfigVariants, uic, uiconfig } from '../utils'
|
|
3
3
|
|
|
4
4
|
export const toggleConfig = uiconfig({
|
|
5
|
-
baseClass:
|
|
5
|
+
baseClass:
|
|
6
|
+
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent data-[active]:shadow-inner data-[active]:text-accent-foreground',
|
|
6
7
|
variants: {
|
|
7
8
|
variant: {
|
|
8
9
|
default: 'bg-transparent',
|
|
9
|
-
outline:
|
|
10
|
-
'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
10
|
+
outline: 'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
11
11
|
},
|
|
12
12
|
size: {
|
|
13
13
|
default: 'h-8 px-3',
|
|
@@ -23,5 +23,4 @@ export const toggleConfig = uiconfig({
|
|
|
23
23
|
|
|
24
24
|
export type ToggleProps = ConfigVariants<Exclude<typeof toggleConfig.variants, undefined>>
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
export const Toggle = uic(TogglePrimitive.Root, toggleConfig)
|
|
@@ -9,7 +9,8 @@ export const { Component: Tooltip, useOpen: useTooltipOpenState } = createCompon
|
|
|
9
9
|
export const TooltipTrigger = TooltipPrimitive.Trigger
|
|
10
10
|
|
|
11
11
|
export const TooltipContent = uic(TooltipPrimitive.Content, {
|
|
12
|
-
baseClass:
|
|
12
|
+
baseClass:
|
|
13
|
+
'z-50 overflow-hidden p-2 text-sm text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
13
14
|
variants: {
|
|
14
15
|
variant: {
|
|
15
16
|
default: 'rounded-md border border-gray-200 bg-popover shadow-md',
|
|
@@ -7,7 +7,6 @@ import { UploadIcon } from 'lucide-react'
|
|
|
7
7
|
import { dict } from '../dict'
|
|
8
8
|
import { Button } from '../ui/button'
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
export const UploaderDropzone = ({ inactiveOnUpload, dropzonePlaceholder }: { inactiveOnUpload?: boolean; dropzonePlaceholder?: ReactNode }) => {
|
|
12
11
|
const filesInProgress = useUploaderStateFiles({ state: ['uploading', 'initial', 'finalizing'] })
|
|
13
12
|
const showLoader = inactiveOnUpload && filesInProgress.length > 0
|
|
@@ -17,15 +16,20 @@ export const UploaderDropzone = ({ inactiveOnUpload, dropzonePlaceholder }: { in
|
|
|
17
16
|
<UploaderDropzoneWrapperUI>
|
|
18
17
|
{showLoader
|
|
19
18
|
? <UploaderInactiveDropzoneUI />
|
|
20
|
-
:
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
: (
|
|
20
|
+
<UploaderDropzoneArea>
|
|
21
|
+
{dropzonePlaceholder ?? (
|
|
22
|
+
<UploaderDropzoneAreaUI>
|
|
23
|
+
<UploadIcon className={'w-12 h-12 text-gray-400'} />
|
|
24
|
+
<div className={'font-semibold text-sm'}>{dict.uploader.dropFiles}</div>
|
|
25
|
+
<div className={'text-xs'}>{dict.uploader.or}</div>
|
|
26
|
+
<div className={'flex gap-2 items-center text-xs'}>
|
|
27
|
+
<Button size={'sm'} variant={'outline'}>{dict.uploader.browseFiles}</Button>
|
|
28
|
+
</div>
|
|
29
|
+
</UploaderDropzoneAreaUI>
|
|
30
|
+
)}
|
|
31
|
+
</UploaderDropzoneArea>
|
|
32
|
+
)}
|
|
29
33
|
</UploaderDropzoneWrapperUI>
|
|
30
34
|
</UploaderDropzoneRoot>
|
|
31
35
|
)
|
|
@@ -2,7 +2,6 @@ import { DropIndicator } from '../ui/sortable'
|
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { RepeaterSortableDropIndicator } from '@contember/react-repeater-dnd-kit'
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export const UploaderRepeaterDropIndicator = ({ position }: { position: 'before' | 'after' }) => (
|
|
7
6
|
<div className={'relative'}>
|
|
8
7
|
<RepeaterSortableDropIndicator position={position}>
|
|
@@ -21,12 +21,10 @@ export const UploaderDropzoneAreaUI = uic('div', {
|
|
|
21
21
|
},
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
|
|
25
24
|
export const UploaderItemUI = uic('div', {
|
|
26
25
|
baseClass: 'rounded-sm border border-gray-200 p-1 shadow-sm bg-gray-100 flex gap-2 relative',
|
|
27
26
|
})
|
|
28
27
|
|
|
29
|
-
|
|
30
28
|
export const UploaderInactiveDropzoneUI = uic('div', {
|
|
31
29
|
baseClass: 'h-40 w-40 flex flex-col pointer-events-none relative',
|
|
32
30
|
beforeChildren: <Loader position="absolute" />,
|
|
@@ -43,5 +41,3 @@ export const UploaderRepeaterHandleUI = uic('button', {
|
|
|
43
41
|
baseClass: 'absolute top-0 left-0 h-6 w-6 inline-flex justify-center align-center opacity-10 hover:opacity-100 transition-opacity z-10',
|
|
44
42
|
beforeChildren: <GripIcon size={16} />,
|
|
45
43
|
})
|
|
46
|
-
|
|
47
|
-
|
|
@@ -5,11 +5,18 @@ import * as React from 'react'
|
|
|
5
5
|
import { ReactNode, useEffect } from 'react'
|
|
6
6
|
import { Toast } from '../toast'
|
|
7
7
|
import { dict } from '../dict'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
UploaderEachFile,
|
|
10
|
+
UploaderError,
|
|
11
|
+
UploaderFileStateError,
|
|
12
|
+
UploaderFileStateFinalizing,
|
|
13
|
+
UploaderFileStateSuccess,
|
|
14
|
+
UploaderFileStateSwitch,
|
|
15
|
+
UploaderFileStateUploading,
|
|
16
|
+
} from '@contember/react-uploader'
|
|
9
17
|
import { formatBytes } from '../formatting/formatting'
|
|
10
18
|
import { Loader } from '../ui/loader'
|
|
11
19
|
|
|
12
|
-
|
|
13
20
|
const formatError = (error: unknown) => {
|
|
14
21
|
if (error instanceof UploaderError) {
|
|
15
22
|
return dict.uploader.uploadErrors[error.options.type]
|
|
@@ -18,7 +25,11 @@ const formatError = (error: unknown) => {
|
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
const AbortButton = ({ state: { file: { abortController } } }: { state: UploaderFileStateFinalizing | UploaderFileStateUploading }) => {
|
|
21
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
<Button className="p-1 h-5 text-red-500" variant="ghost" size={'sm'} onClick={() => abortController.abort()}>
|
|
30
|
+
<StopCircleIcon className="h-3 w-3" />
|
|
31
|
+
</Button>
|
|
32
|
+
)
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
const DismissButton = ({ state }: { state: UploaderFileStateSuccess | UploaderFileStateError }) => {
|
|
@@ -29,7 +40,11 @@ const DismissButton = ({ state }: { state: UploaderFileStateSuccess | UploaderFi
|
|
|
29
40
|
return () => clearTimeout(timeout)
|
|
30
41
|
}, [state])
|
|
31
42
|
|
|
32
|
-
return
|
|
43
|
+
return (
|
|
44
|
+
<Button className="p-1 h-5" variant="ghost" size={'sm'} onClick={() => state.dismiss()}>
|
|
45
|
+
<XIcon className="h-3 w-3" />
|
|
46
|
+
</Button>
|
|
47
|
+
)
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
const UploadError = ({ state: { error } }: { state: UploaderFileStateError }) => {
|
|
@@ -40,7 +55,9 @@ const UploadError = ({ state: { error } }: { state: UploaderFileStateError }) =>
|
|
|
40
55
|
return <div className="text-red-700 text-xs font-semibold">{formattedError}</div>
|
|
41
56
|
}
|
|
42
57
|
|
|
43
|
-
export const UploaderFileProgressUI = (
|
|
58
|
+
export const UploaderFileProgressUI = (
|
|
59
|
+
{ file, progress, info, actions }: { file: File; progress?: number; actions?: ReactNode; info?: ReactNode },
|
|
60
|
+
) => {
|
|
44
61
|
const fileName = file.name
|
|
45
62
|
const extension = file.name.split('.').pop()?.toUpperCase()
|
|
46
63
|
|
|
@@ -66,7 +83,6 @@ export const UploaderFileProgressUI = ({ file, progress, info, actions }: { file
|
|
|
66
83
|
)
|
|
67
84
|
}
|
|
68
85
|
|
|
69
|
-
|
|
70
86
|
export const UploaderProgress = () => {
|
|
71
87
|
const [open, setOpen] = React.useState(true)
|
|
72
88
|
|
|
@@ -94,12 +110,12 @@ export const UploaderProgress = () => {
|
|
|
94
110
|
file={it.file.file}
|
|
95
111
|
progress={100}
|
|
96
112
|
actions={<AbortButton state={it} />}
|
|
97
|
-
info={
|
|
113
|
+
info={
|
|
98
114
|
<div className="text-gray-400 text-xs inline-flex gap-1 items-center">
|
|
99
115
|
<Loader2Icon className="animate-spin h-3 w-3 inline-block" />
|
|
100
116
|
{formatBytes(it.file.file.size)}
|
|
101
117
|
</div>
|
|
102
|
-
|
|
118
|
+
}
|
|
103
119
|
/>
|
|
104
120
|
)}
|
|
105
121
|
error={it => (
|
|
@@ -114,12 +130,12 @@ export const UploaderProgress = () => {
|
|
|
114
130
|
file={it.file.file}
|
|
115
131
|
progress={100}
|
|
116
132
|
actions={<DismissButton state={it} />}
|
|
117
|
-
info={
|
|
133
|
+
info={
|
|
118
134
|
<div className="flex gap-1 items-center text-green-600 ">
|
|
119
135
|
<CheckIcon className="w-3 h-3" />
|
|
120
|
-
<div className="text-green-600 text-xs ">
|
|
136
|
+
<div className="text-green-600 text-xs ">Done ({formatBytes(it.file.file.size)})</div>
|
|
121
137
|
</div>
|
|
122
|
-
|
|
138
|
+
}
|
|
123
139
|
/>
|
|
124
140
|
)}
|
|
125
141
|
/>
|