@giddaa-housing/ui 0.1.0
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/README.md +41 -0
- package/dist/accordion.d.ts +11 -0
- package/dist/accordion.js +124 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert.d.ts +18 -0
- package/dist/alert.js +152 -0
- package/dist/alert.js.map +1 -0
- package/dist/avatar.d.ts +14 -0
- package/dist/avatar.js +152 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +14 -0
- package/dist/badge.js +119 -0
- package/dist/badge.js.map +1 -0
- package/dist/bar-chart.d.ts +136 -0
- package/dist/bar-chart.js +302 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/base.css +32 -0
- package/dist/breadcrumb.d.ts +12 -0
- package/dist/breadcrumb.js +161 -0
- package/dist/breadcrumb.js.map +1 -0
- package/dist/bullet-chart.d.ts +98 -0
- package/dist/bullet-chart.js +189 -0
- package/dist/bullet-chart.js.map +1 -0
- package/dist/button-group.d.ts +18 -0
- package/dist/button-group.js +170 -0
- package/dist/button-group.js.map +1 -0
- package/dist/button.d.ts +19 -0
- package/dist/button.js +146 -0
- package/dist/button.js.map +1 -0
- package/dist/calendar.d.ts +9 -0
- package/dist/calendar.js +293 -0
- package/dist/calendar.js.map +1 -0
- package/dist/card.d.ts +18 -0
- package/dist/card.js +186 -0
- package/dist/card.js.map +1 -0
- package/dist/carousel.d.ts +53 -0
- package/dist/carousel.js +396 -0
- package/dist/carousel.js.map +1 -0
- package/dist/chart.d.ts +122 -0
- package/dist/chart.js +494 -0
- package/dist/chart.js.map +1 -0
- package/dist/checkbox.d.ts +73 -0
- package/dist/checkbox.js +87 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/collapsible.d.ts +8 -0
- package/dist/collapsible.js +82 -0
- package/dist/collapsible.js.map +1 -0
- package/dist/combobox.d.ts +30 -0
- package/dist/combobox.js +713 -0
- package/dist/combobox.js.map +1 -0
- package/dist/date-picker.d.ts +22 -0
- package/dist/date-picker.js +528 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/dialog.d.ts +30 -0
- package/dist/dialog.js +339 -0
- package/dist/dialog.js.map +1 -0
- package/dist/dropdown-menu.d.ts +35 -0
- package/dist/dropdown-menu.js +376 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/dropzone.d.ts +128 -0
- package/dist/dropzone.js +490 -0
- package/dist/dropzone.js.map +1 -0
- package/dist/empty-state.d.ts +17 -0
- package/dist/empty-state.js +146 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/field.d.ts +29 -0
- package/dist/field.js +345 -0
- package/dist/field.js.map +1 -0
- package/dist/files/red-hat-display-latin-300-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-300-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-300-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-300-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-400-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-400-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-400-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-400-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-500-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-500-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-500-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-500-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-600-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-600-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-600-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-600-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-700-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-700-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-700-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-700-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-800-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-800-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-800-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-800-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-900-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-900-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-900-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-900-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-300-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-300-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-300-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-300-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-400-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-400-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-400-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-400-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-500-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-500-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-500-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-500-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-600-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-600-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-600-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-600-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-700-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-700-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-700-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-700-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-800-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-800-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-800-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-800-normal.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-900-italic.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-900-italic.woff2 +0 -0
- package/dist/files/red-hat-display-latin-ext-900-normal.woff +0 -0
- package/dist/files/red-hat-display-latin-ext-900-normal.woff2 +0 -0
- package/dist/funnel-chart.d.ts +84 -0
- package/dist/funnel-chart.js +569 -0
- package/dist/funnel-chart.js.map +1 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +10448 -0
- package/dist/index.js.map +1 -0
- package/dist/input-group.d.ts +31 -0
- package/dist/input-group.js +380 -0
- package/dist/input-group.js.map +1 -0
- package/dist/input-size-context.d.ts +11 -0
- package/dist/input-size-context.js +24 -0
- package/dist/input-size-context.js.map +1 -0
- package/dist/input.d.ts +13 -0
- package/dist/input.js +83 -0
- package/dist/input.js.map +1 -0
- package/dist/item.d.ts +8 -0
- package/dist/item.js +93 -0
- package/dist/item.js.map +1 -0
- package/dist/kpi-card.d.ts +24 -0
- package/dist/kpi-card.js +243 -0
- package/dist/kpi-card.js.map +1 -0
- package/dist/label.d.ts +8 -0
- package/dist/label.js +68 -0
- package/dist/label.js.map +1 -0
- package/dist/line-chart.d.ts +155 -0
- package/dist/line-chart.js +269 -0
- package/dist/line-chart.js.map +1 -0
- package/dist/logo.d.ts +6 -0
- package/dist/logo.js +146 -0
- package/dist/logo.js.map +1 -0
- package/dist/number-input.d.ts +41 -0
- package/dist/number-input.js +418 -0
- package/dist/number-input.js.map +1 -0
- package/dist/page-header.d.ts +13 -0
- package/dist/page-header.js +113 -0
- package/dist/page-header.js.map +1 -0
- package/dist/pagination.d.ts +35 -0
- package/dist/pagination.js +352 -0
- package/dist/pagination.js.map +1 -0
- package/dist/password-input.d.ts +13 -0
- package/dist/password-input.js +356 -0
- package/dist/password-input.js.map +1 -0
- package/dist/phone-input.d.ts +21 -0
- package/dist/phone-input.js +573 -0
- package/dist/phone-input.js.map +1 -0
- package/dist/photo-gallery.d.ts +42 -0
- package/dist/photo-gallery.js +756 -0
- package/dist/photo-gallery.js.map +1 -0
- package/dist/pie-chart.d.ts +125 -0
- package/dist/pie-chart.js +192 -0
- package/dist/pie-chart.js.map +1 -0
- package/dist/popover.d.ts +20 -0
- package/dist/popover.js +169 -0
- package/dist/popover.js.map +1 -0
- package/dist/progress.d.ts +28 -0
- package/dist/progress.js +315 -0
- package/dist/progress.js.map +1 -0
- package/dist/radio-group.d.ts +32 -0
- package/dist/radio-group.js +100 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/red-hat-display.css +2 -0
- package/dist/rich-text-editor.d.ts +16 -0
- package/dist/rich-text-editor.js +1000 -0
- package/dist/rich-text-editor.js.map +1 -0
- package/dist/search-input.d.ts +19 -0
- package/dist/search-input.js +411 -0
- package/dist/search-input.js.map +1 -0
- package/dist/select.d.ts +21 -0
- package/dist/select.js +305 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.d.ts +10 -0
- package/dist/separator.js +72 -0
- package/dist/separator.js.map +1 -0
- package/dist/sheet.d.ts +24 -0
- package/dist/sheet.js +282 -0
- package/dist/sheet.js.map +1 -0
- package/dist/sidebar.d.ts +70 -0
- package/dist/sidebar.js +1078 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/size-context.d.ts +11 -0
- package/dist/size-context.js +22 -0
- package/dist/size-context.js.map +1 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.js +48 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/sparkline.d.ts +94 -0
- package/dist/sparkline.js +568 -0
- package/dist/sparkline.js.map +1 -0
- package/dist/stepper.d.ts +43 -0
- package/dist/stepper.js +296 -0
- package/dist/stepper.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/switch.d.ts +29 -0
- package/dist/switch.js +108 -0
- package/dist/switch.js.map +1 -0
- package/dist/tab-list.d.ts +38 -0
- package/dist/tab-list.js +394 -0
- package/dist/tab-list.js.map +1 -0
- package/dist/table.d.ts +69 -0
- package/dist/table.js +197 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.d.ts +18 -0
- package/dist/tabs.js +159 -0
- package/dist/tabs.js.map +1 -0
- package/dist/tag.d.ts +25 -0
- package/dist/tag.js +160 -0
- package/dist/tag.js.map +1 -0
- package/dist/textarea.d.ts +12 -0
- package/dist/textarea.js +78 -0
- package/dist/textarea.js.map +1 -0
- package/dist/theme/giddaa.css +2 -0
- package/dist/time-picker.d.ts +13 -0
- package/dist/time-picker.js +472 -0
- package/dist/time-picker.js.map +1 -0
- package/dist/toast.d.ts +23 -0
- package/dist/toast.js +330 -0
- package/dist/toast.js.map +1 -0
- package/dist/tooltip.d.ts +11 -0
- package/dist/tooltip.js +96 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/tree-map.d.ts +127 -0
- package/dist/tree-map.js +652 -0
- package/dist/tree-map.js.map +1 -0
- package/package.json +328 -0
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
// src/components/ui/rich-text-editor.tsx
|
|
2
|
+
import { Color } from "@tiptap/extension-color";
|
|
3
|
+
import { Image } from "@tiptap/extension-image";
|
|
4
|
+
import { Placeholder } from "@tiptap/extension-placeholder";
|
|
5
|
+
import { TextAlign } from "@tiptap/extension-text-align";
|
|
6
|
+
import { TextStyle } from "@tiptap/extension-text-style";
|
|
7
|
+
import { EditorContent, useEditor, useEditorState } from "@tiptap/react";
|
|
8
|
+
import { StarterKit } from "@tiptap/starter-kit";
|
|
9
|
+
import {
|
|
10
|
+
AlignCenter,
|
|
11
|
+
AlignJustify,
|
|
12
|
+
AlignLeft,
|
|
13
|
+
AlignRight,
|
|
14
|
+
Baseline,
|
|
15
|
+
Bold,
|
|
16
|
+
ChevronDown,
|
|
17
|
+
Code2,
|
|
18
|
+
ImageIcon,
|
|
19
|
+
Italic,
|
|
20
|
+
Link2,
|
|
21
|
+
List,
|
|
22
|
+
ListOrdered,
|
|
23
|
+
Quote,
|
|
24
|
+
Redo2,
|
|
25
|
+
Underline,
|
|
26
|
+
Undo2
|
|
27
|
+
} from "lucide-react";
|
|
28
|
+
import * as React from "react";
|
|
29
|
+
|
|
30
|
+
// src/lib/cn.ts
|
|
31
|
+
import { clsx } from "clsx";
|
|
32
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
33
|
+
var twMerge = extendTailwindMerge({
|
|
34
|
+
extend: {
|
|
35
|
+
classGroups: {
|
|
36
|
+
"font-size": [
|
|
37
|
+
{
|
|
38
|
+
text: [
|
|
39
|
+
"gdt-display",
|
|
40
|
+
"gdt-h1",
|
|
41
|
+
"gdt-h2",
|
|
42
|
+
"gdt-h3",
|
|
43
|
+
"gdt-h4",
|
|
44
|
+
"gdt-h5",
|
|
45
|
+
"gdt-xl",
|
|
46
|
+
"gdt-lg",
|
|
47
|
+
"gdt-md",
|
|
48
|
+
"gdt-sm",
|
|
49
|
+
"gdt-xs",
|
|
50
|
+
"gdt-subtext",
|
|
51
|
+
"gdt-capitalized"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
function cn(...inputs) {
|
|
59
|
+
return twMerge(clsx(inputs));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/components/ui/button.tsx
|
|
63
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
64
|
+
import { cva } from "class-variance-authority";
|
|
65
|
+
import { Loader } from "lucide-react";
|
|
66
|
+
|
|
67
|
+
// src/components/ui/size-context.tsx
|
|
68
|
+
import { createContext, useContext } from "react";
|
|
69
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
70
|
+
var SizeContext = createContext(void 0);
|
|
71
|
+
function SizeProvider({
|
|
72
|
+
children,
|
|
73
|
+
size
|
|
74
|
+
}) {
|
|
75
|
+
if (!size) {
|
|
76
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ jsx(SizeContext.Provider, { value: size, children });
|
|
79
|
+
}
|
|
80
|
+
function useComponentSize(size, fallback = "md") {
|
|
81
|
+
const inheritedSize = useContext(SizeContext);
|
|
82
|
+
return size ?? inheritedSize ?? fallback;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/components/ui/button.tsx
|
|
86
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
87
|
+
var buttonVariants = cva(
|
|
88
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-full bg-clip-padding whitespace-nowrap font-bold transition-[background-color,color,border-color,box-shadow,transform] outline-none select-none focus-visible:border-line-focus focus-visible:shadow-[0px_0px_0px_2px_var(--color-line-focus)] active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-invalid:border-line-danger aria-invalid:ring-3 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
89
|
+
{
|
|
90
|
+
variants: {
|
|
91
|
+
variant: {
|
|
92
|
+
primary: "bg-action-primary text-fg-on-brand hover:bg-action-primary-hover active:bg-action-primary-pressed",
|
|
93
|
+
"primary-outline": "border-2 border-action-primary bg-transparent text-fg-brand hover:bg-surface-brand-subtle active:bg-surface-brand-subtle data-focused:bg-surface-brand-subtle data-pressed:bg-surface-brand-subtle",
|
|
94
|
+
secondary: "bg-surface-brand-subtle text-fg-brand hover:bg-action-primary-hover hover:text-fg-on-brand active:bg-action-primary-pressed active:text-fg-on-brand data-focused:bg-action-primary-hover data-pressed:bg-action-primary-pressed data-focused:text-fg-on-brand data-pressed:text-fg-on-brand",
|
|
95
|
+
"secondary-outline": "border-2 border-action-secondary bg-transparent text-fg-brand hover:bg-surface-brand-subtle active:bg-surface-brand-subtle data-focused:bg-surface-brand-subtle data-pressed:bg-surface-brand-subtle",
|
|
96
|
+
tertiary: "bg-action-tertiary text-fg-primary hover:bg-action-tertiary-hover active:bg-action-tertiary-pressed data-focused:bg-action-tertiary-hover data-pressed:bg-action-tertiary-pressed",
|
|
97
|
+
"tertiary-outline": "border border-line-strong bg-transparent text-fg-primary hover:bg-surface active:bg-surface-raised data-focused:bg-surface data-pressed:bg-surface-raised",
|
|
98
|
+
ghost: "bg-transparent text-fg-primary hover:bg-surface active:bg-surface-raised data-focused:bg-surface data-pressed:bg-surface-raised",
|
|
99
|
+
danger: "bg-action-danger text-fg-on-brand hover:bg-action-danger-hover active:bg-action-danger-pressed data-focused:bg-action-danger-hover data-pressed:bg-action-danger-pressed",
|
|
100
|
+
"glass-overlay": "bg-surface-glass-overlay-button text-fg-on-brand",
|
|
101
|
+
"link-brand": "border-transparent bg-transparent px-0 text-fg-brand hover:underline active:underline active:opacity-70",
|
|
102
|
+
"link-neutral": "border-transparent bg-transparent px-0 text-fg-secondary hover:underline active:underline active:opacity-70"
|
|
103
|
+
},
|
|
104
|
+
size: {
|
|
105
|
+
sm: "h-8 gap-2 px-3.5 text-gdt-xs has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg:not([class*='size-'])]:size-3.5",
|
|
106
|
+
md: "h-10 gap-2 px-4.5 text-gdt-sm has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",
|
|
107
|
+
lg: "h-12.5 gap-2.5 px-5.5 text-gdt-md has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5 [&_svg:not([class*='size-'])]:size-4.5",
|
|
108
|
+
xl: "h-14 gap-3 px-6.5 text-gdt-lg has-data-[icon=inline-end]:pr-6 has-data-[icon=inline-start]:pl-6 [&_svg:not([class*='size-'])]:size-5",
|
|
109
|
+
icon: "size-10",
|
|
110
|
+
"icon-xs": "size-6 text-gdt-xs [&_svg:not([class*='size-'])]:size-3",
|
|
111
|
+
"icon-sm": "size-8 text-gdt-sm [&_svg:not([class*='size-'])]:size-3.5",
|
|
112
|
+
"icon-lg": "size-12.5 text-gdt-md [&_svg:not([class*='size-'])]:size-4.5",
|
|
113
|
+
"icon-xl": "size-14 text-gdt-lg [&_svg:not([class*='size-'])]:size-5"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
defaultVariants: {
|
|
117
|
+
variant: "primary",
|
|
118
|
+
size: "md"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
function Button({
|
|
123
|
+
className,
|
|
124
|
+
variant = "primary",
|
|
125
|
+
size,
|
|
126
|
+
isLoading = false,
|
|
127
|
+
children,
|
|
128
|
+
disabled = false,
|
|
129
|
+
...props
|
|
130
|
+
}) {
|
|
131
|
+
const inheritedSize = useComponentSize();
|
|
132
|
+
const resolvedSize = size ?? inheritedSize;
|
|
133
|
+
const _disabled = disabled || isLoading;
|
|
134
|
+
return /* @__PURE__ */ jsxs(
|
|
135
|
+
ButtonPrimitive,
|
|
136
|
+
{
|
|
137
|
+
"data-slot": "button",
|
|
138
|
+
className: cn(buttonVariants({ variant, size: resolvedSize, className })),
|
|
139
|
+
disabled: _disabled,
|
|
140
|
+
...props,
|
|
141
|
+
children: [
|
|
142
|
+
isLoading && /* @__PURE__ */ jsx2(Loader, { className: "size-4 animate-spin" }),
|
|
143
|
+
" ",
|
|
144
|
+
children
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/components/ui/dropdown-menu.tsx
|
|
151
|
+
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
|
|
152
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
153
|
+
import { CheckIcon, ChevronRightIcon } from "lucide-react";
|
|
154
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
155
|
+
function DropdownMenu({
|
|
156
|
+
children,
|
|
157
|
+
size,
|
|
158
|
+
...props
|
|
159
|
+
}) {
|
|
160
|
+
return /* @__PURE__ */ jsx3(SizeProvider, { size, children: /* @__PURE__ */ jsx3(MenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props, children }) });
|
|
161
|
+
}
|
|
162
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
163
|
+
return /* @__PURE__ */ jsx3(MenuPrimitive.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
164
|
+
}
|
|
165
|
+
var dropdownMenuContentVariants = cva2(
|
|
166
|
+
"relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto border border-line-subtle bg-canvas text-fg-primary shadow-(--elevation-e1-shadow) duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
167
|
+
{
|
|
168
|
+
variants: {
|
|
169
|
+
size: {
|
|
170
|
+
sm: "rounded-lg p-1",
|
|
171
|
+
md: "rounded-xl p-1.5",
|
|
172
|
+
lg: "rounded-[18px] p-2"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
defaultVariants: {
|
|
176
|
+
size: "md"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
var dropdownMenuItemVariants = cva2(
|
|
181
|
+
"group/dropdown-menu-item relative flex w-full cursor-pointer items-center font-normal text-fg-primary outline-none transition-colors select-none focus:bg-surface focus:text-fg-primary data-highlighted:bg-surface data-highlighted:text-fg-primary data-[variant=destructive]:text-fg-danger data-[variant=destructive]:focus:bg-surface-danger-subtle data-[variant=destructive]:focus:text-fg-danger data-[variant=destructive]:data-highlighted:bg-surface-danger-subtle data-[variant=destructive]:data-highlighted:text-fg-danger data-disabled:pointer-events-none data-disabled:text-fg-caption-placeholder data-disabled:opacity-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 data-[variant=destructive]:[&_svg]:text-fg-danger",
|
|
182
|
+
{
|
|
183
|
+
variants: {
|
|
184
|
+
size: {
|
|
185
|
+
sm: "gap-1.5 rounded-md px-3 py-1.5 text-gdt-xs [&_svg:not([class*='size-'])]:size-3.5",
|
|
186
|
+
md: "gap-2 rounded-md px-4 py-2 text-gdt-sm [&_svg:not([class*='size-'])]:size-4",
|
|
187
|
+
lg: "gap-2.5 rounded-md px-4 py-2.5 text-gdt-md [&_svg:not([class*='size-'])]:size-4.5"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
defaultVariants: {
|
|
191
|
+
size: "md"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
var dropdownMenuLabelVariants = cva2(
|
|
196
|
+
"font-medium text-fg-secondary data-inset:pl-8",
|
|
197
|
+
{
|
|
198
|
+
variants: {
|
|
199
|
+
size: {
|
|
200
|
+
sm: "px-3 py-1 text-gdt-xs",
|
|
201
|
+
md: "px-3 py-1 text-gdt-xs",
|
|
202
|
+
lg: "px-4 py-1.5 text-gdt-sm"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
defaultVariants: {
|
|
206
|
+
size: "md"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
function DropdownMenuContent({
|
|
211
|
+
align = "start",
|
|
212
|
+
alignOffset = 0,
|
|
213
|
+
side = "bottom",
|
|
214
|
+
sideOffset = 6,
|
|
215
|
+
className,
|
|
216
|
+
...props
|
|
217
|
+
}) {
|
|
218
|
+
const resolvedSize = useComponentSize();
|
|
219
|
+
return /* @__PURE__ */ jsx3(MenuPrimitive.Portal, { children: /* @__PURE__ */ jsx3(
|
|
220
|
+
MenuPrimitive.Positioner,
|
|
221
|
+
{
|
|
222
|
+
className: "isolate z-50 outline-none",
|
|
223
|
+
align,
|
|
224
|
+
alignOffset,
|
|
225
|
+
side,
|
|
226
|
+
sideOffset,
|
|
227
|
+
children: /* @__PURE__ */ jsx3(
|
|
228
|
+
MenuPrimitive.Popup,
|
|
229
|
+
{
|
|
230
|
+
"data-slot": "dropdown-menu-content",
|
|
231
|
+
"data-size": resolvedSize,
|
|
232
|
+
className: cn(
|
|
233
|
+
dropdownMenuContentVariants({ size: resolvedSize }),
|
|
234
|
+
className
|
|
235
|
+
),
|
|
236
|
+
...props
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
) });
|
|
241
|
+
}
|
|
242
|
+
function DropdownMenuRadioGroup({ ...props }) {
|
|
243
|
+
return /* @__PURE__ */ jsx3(
|
|
244
|
+
MenuPrimitive.RadioGroup,
|
|
245
|
+
{
|
|
246
|
+
"data-slot": "dropdown-menu-radio-group",
|
|
247
|
+
...props
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
function DropdownMenuRadioItem({
|
|
252
|
+
className,
|
|
253
|
+
children,
|
|
254
|
+
inset,
|
|
255
|
+
...props
|
|
256
|
+
}) {
|
|
257
|
+
const resolvedSize = useComponentSize();
|
|
258
|
+
return /* @__PURE__ */ jsxs2(
|
|
259
|
+
MenuPrimitive.RadioItem,
|
|
260
|
+
{
|
|
261
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
262
|
+
"data-inset": inset,
|
|
263
|
+
"data-size": resolvedSize,
|
|
264
|
+
className: cn(
|
|
265
|
+
dropdownMenuItemVariants({ size: resolvedSize }),
|
|
266
|
+
"pr-10 data-inset:pl-8",
|
|
267
|
+
className
|
|
268
|
+
),
|
|
269
|
+
...props,
|
|
270
|
+
children: [
|
|
271
|
+
/* @__PURE__ */ jsx3(
|
|
272
|
+
"span",
|
|
273
|
+
{
|
|
274
|
+
className: "pointer-events-none absolute right-3 flex items-center justify-center text-fg-brand",
|
|
275
|
+
"data-slot": "dropdown-menu-radio-item-indicator",
|
|
276
|
+
children: /* @__PURE__ */ jsx3(MenuPrimitive.RadioItemIndicator, { children: /* @__PURE__ */ jsx3(CheckIcon, {}) })
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
children
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/components/ui/input.tsx
|
|
286
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
287
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
288
|
+
|
|
289
|
+
// src/components/ui/input-size-context.tsx
|
|
290
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
291
|
+
import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
|
|
292
|
+
var InputSizeContext = createContext2(
|
|
293
|
+
void 0
|
|
294
|
+
);
|
|
295
|
+
function useInputComponentSize(size, fallback = "md") {
|
|
296
|
+
const inheritedSize = useContext2(InputSizeContext);
|
|
297
|
+
return size ?? inheritedSize ?? fallback;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/components/ui/input.tsx
|
|
301
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
302
|
+
var inputVariants = cva3(
|
|
303
|
+
"flex w-full min-w-0 rounded-full border border-line bg-canvas text-fg-primary transition-[background-color,border-color,box-shadow,color] outline-none file:inline-flex file:border-0 file:bg-transparent file:font-normal file:text-fg-primary placeholder:text-fg-muted hover:border-line-strong focus-visible:border-line-focus focus-visible:inset-ring-1 inset-ring-line-focus disabled:pointer-events-none disabled:cursor-not-allowed disabled:border-line-subtle disabled:bg-surface disabled:text-fg-muted disabled:placeholder:text-fg-muted aria-invalid:border-line-danger aria-invalid:text-fg-danger aria-invalid:placeholder:text-fg-danger aria-invalid:shadow-none",
|
|
304
|
+
{
|
|
305
|
+
variants: {
|
|
306
|
+
size: {
|
|
307
|
+
sm: "h-8 px-3 text-gdt-xs font-normal file:text-gdt-xs",
|
|
308
|
+
md: "h-10 px-3.5 text-gdt-sm font-normal file:text-gdt-sm",
|
|
309
|
+
lg: "h-12 px-4 text-gdt-md font-normal file:text-gdt-md",
|
|
310
|
+
xl: "h-14 px-4.5 text-gdt-lg font-normal file:text-gdt-lg"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
defaultVariants: {
|
|
314
|
+
size: "md"
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
function Input({ className, size, type, ...props }) {
|
|
319
|
+
const resolvedSize = useInputComponentSize(size);
|
|
320
|
+
return /* @__PURE__ */ jsx5(
|
|
321
|
+
InputPrimitive,
|
|
322
|
+
{
|
|
323
|
+
type,
|
|
324
|
+
"data-slot": "input",
|
|
325
|
+
"data-size": resolvedSize,
|
|
326
|
+
className: cn(inputVariants({ size: resolvedSize }), className),
|
|
327
|
+
...props
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/components/ui/popover.tsx
|
|
333
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
334
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
335
|
+
function Popover({ ...props }) {
|
|
336
|
+
return /* @__PURE__ */ jsx6(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
337
|
+
}
|
|
338
|
+
function PopoverTrigger({ ...props }) {
|
|
339
|
+
return /* @__PURE__ */ jsx6(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
340
|
+
}
|
|
341
|
+
function PopoverContent({
|
|
342
|
+
className,
|
|
343
|
+
align = "center",
|
|
344
|
+
alignOffset = 0,
|
|
345
|
+
side = "bottom",
|
|
346
|
+
sideOffset = 6,
|
|
347
|
+
showArrow = true,
|
|
348
|
+
size = "md",
|
|
349
|
+
children,
|
|
350
|
+
...props
|
|
351
|
+
}) {
|
|
352
|
+
return /* @__PURE__ */ jsx6(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx6(
|
|
353
|
+
PopoverPrimitive.Positioner,
|
|
354
|
+
{
|
|
355
|
+
align,
|
|
356
|
+
alignOffset,
|
|
357
|
+
side,
|
|
358
|
+
sideOffset,
|
|
359
|
+
className: "isolate z-50",
|
|
360
|
+
children: /* @__PURE__ */ jsxs3(
|
|
361
|
+
PopoverPrimitive.Popup,
|
|
362
|
+
{
|
|
363
|
+
"data-slot": "popover-content",
|
|
364
|
+
className: cn(
|
|
365
|
+
"z-50 relative flex w-72 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col rounded-lg border-0 bg-surface-overlay py-4 text-gdt-sm text-fg-primary shadow-2 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 has-[&_[data-slot=popover-footer]]:pb-0",
|
|
366
|
+
className
|
|
367
|
+
),
|
|
368
|
+
...props,
|
|
369
|
+
children: [
|
|
370
|
+
/* @__PURE__ */ jsx6(SizeProvider, { size, children }),
|
|
371
|
+
showArrow ? /* @__PURE__ */ jsx6(PopoverPrimitive.Arrow, { className: "relative block w-3 h-1.5 overflow-clip data-[side=bottom]:top-[-6px] data-[side=left]:right-[-9px] data-[side=left]:rotate-90 data-[side=right]:left-[-9px] data-[side=right]:-rotate-90 data-[side=top]:bottom-[-6px] data-[side=top]:rotate-180 before:content-[''] before:absolute before:bottom-0 before:left-1/2 before:w-[calc(6px*sqrt(2))] before:h-[calc(6px*sqrt(2))] before:bg-surface-overlay before:border before:border-line before:[transform:translate(-50%,50%)_rotate(45deg)]" }) : null
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
)
|
|
375
|
+
}
|
|
376
|
+
) });
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/components/ui/rich-text-editor.tsx
|
|
380
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
381
|
+
var SIZES = {
|
|
382
|
+
sm: {
|
|
383
|
+
width: "max-w-[420px]",
|
|
384
|
+
content: "min-h-[140px]",
|
|
385
|
+
contentPad: "px-4 py-3",
|
|
386
|
+
text: "text-gdt-xs",
|
|
387
|
+
icon: "[&_svg:not([class*='size-'])]:size-3.5",
|
|
388
|
+
button: "h-7 min-w-7 px-1",
|
|
389
|
+
toolbarPad: "px-2 py-1.5",
|
|
390
|
+
toolbarGap: "gap-0.5",
|
|
391
|
+
divider: "h-4"
|
|
392
|
+
},
|
|
393
|
+
md: {
|
|
394
|
+
width: "max-w-[520px]",
|
|
395
|
+
content: "min-h-[172px]",
|
|
396
|
+
contentPad: "px-5 py-4",
|
|
397
|
+
text: "text-gdt-sm",
|
|
398
|
+
icon: "[&_svg:not([class*='size-'])]:size-4",
|
|
399
|
+
button: "h-8 min-w-8 px-1.5",
|
|
400
|
+
toolbarPad: "px-2.5 py-2",
|
|
401
|
+
toolbarGap: "gap-0.5",
|
|
402
|
+
divider: "h-5"
|
|
403
|
+
},
|
|
404
|
+
lg: {
|
|
405
|
+
width: "max-w-[600px]",
|
|
406
|
+
content: "min-h-[206px]",
|
|
407
|
+
contentPad: "px-6 py-5",
|
|
408
|
+
text: "text-gdt-md",
|
|
409
|
+
icon: "[&_svg:not([class*='size-'])]:size-[18px]",
|
|
410
|
+
button: "h-9 min-w-9 px-2",
|
|
411
|
+
toolbarPad: "px-3 py-2.5",
|
|
412
|
+
toolbarGap: "gap-1",
|
|
413
|
+
divider: "h-6"
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
var TEXT_COLORS = [
|
|
417
|
+
{ label: "Default", value: "" },
|
|
418
|
+
{ label: "Forest", value: "#2f5a2c" },
|
|
419
|
+
{ label: "Brass", value: "#b8861a" },
|
|
420
|
+
{ label: "Clay", value: "#b2542b" },
|
|
421
|
+
{ label: "Moss", value: "#4e4d29" },
|
|
422
|
+
{ label: "Stone", value: "#5c5648" },
|
|
423
|
+
{ label: "Ink", value: "#1f1c18" }
|
|
424
|
+
];
|
|
425
|
+
var BLOCK_OPTIONS = [
|
|
426
|
+
{ value: "paragraph", label: "Normal" },
|
|
427
|
+
{ value: "h1", label: "Heading 1" },
|
|
428
|
+
{ value: "h2", label: "Heading 2" },
|
|
429
|
+
{ value: "h3", label: "Heading 3" }
|
|
430
|
+
];
|
|
431
|
+
function toolbarControlClass(tokens, active) {
|
|
432
|
+
return cn(
|
|
433
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center rounded-md font-medium text-fg-secondary outline-none transition-colors select-none",
|
|
434
|
+
"hover:bg-action-tertiary-hover hover:text-fg-primary",
|
|
435
|
+
"focus-visible:ring-2 focus-visible:ring-line-focus",
|
|
436
|
+
"disabled:pointer-events-none disabled:opacity-40 data-disabled:pointer-events-none data-disabled:opacity-40",
|
|
437
|
+
tokens.button,
|
|
438
|
+
tokens.icon,
|
|
439
|
+
tokens.text,
|
|
440
|
+
active && "bg-action-primary text-fg-on-brand hover:bg-action-primary-hover hover:text-fg-on-brand"
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
function ToolbarButton({
|
|
444
|
+
tokens,
|
|
445
|
+
label,
|
|
446
|
+
active,
|
|
447
|
+
disabled,
|
|
448
|
+
onClick,
|
|
449
|
+
children
|
|
450
|
+
}) {
|
|
451
|
+
return /* @__PURE__ */ jsx7(
|
|
452
|
+
"button",
|
|
453
|
+
{
|
|
454
|
+
type: "button",
|
|
455
|
+
"aria-label": label,
|
|
456
|
+
title: label,
|
|
457
|
+
"aria-pressed": active,
|
|
458
|
+
disabled,
|
|
459
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
460
|
+
onClick,
|
|
461
|
+
className: toolbarControlClass(tokens, active),
|
|
462
|
+
children
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
function ToolbarDivider({ tokens }) {
|
|
467
|
+
return /* @__PURE__ */ jsx7(
|
|
468
|
+
"span",
|
|
469
|
+
{
|
|
470
|
+
"aria-hidden": "true",
|
|
471
|
+
className: cn("mx-1 w-px shrink-0 self-center bg-line", tokens.divider)
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
function BlockControl({
|
|
476
|
+
tokens,
|
|
477
|
+
value,
|
|
478
|
+
disabled,
|
|
479
|
+
onChange
|
|
480
|
+
}) {
|
|
481
|
+
const current = BLOCK_OPTIONS.find((option) => option.value === value);
|
|
482
|
+
return /* @__PURE__ */ jsxs4(DropdownMenu, { children: [
|
|
483
|
+
/* @__PURE__ */ jsxs4(
|
|
484
|
+
DropdownMenuTrigger,
|
|
485
|
+
{
|
|
486
|
+
disabled,
|
|
487
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
488
|
+
className: cn(
|
|
489
|
+
toolbarControlClass(tokens),
|
|
490
|
+
"w-auto justify-between gap-1 px-2"
|
|
491
|
+
),
|
|
492
|
+
children: [
|
|
493
|
+
/* @__PURE__ */ jsx7("span", { className: "whitespace-nowrap", children: current?.label ?? "Normal" }),
|
|
494
|
+
/* @__PURE__ */ jsx7(ChevronDown, { className: "size-3.5 opacity-70" })
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ jsx7(DropdownMenuContent, { className: "min-w-40", children: /* @__PURE__ */ jsx7(
|
|
499
|
+
DropdownMenuRadioGroup,
|
|
500
|
+
{
|
|
501
|
+
value,
|
|
502
|
+
onValueChange: (next) => onChange(next),
|
|
503
|
+
children: BLOCK_OPTIONS.map((option) => /* @__PURE__ */ jsx7(DropdownMenuRadioItem, { value: option.value, children: option.label }, option.value))
|
|
504
|
+
}
|
|
505
|
+
) })
|
|
506
|
+
] });
|
|
507
|
+
}
|
|
508
|
+
function ColorControl({
|
|
509
|
+
tokens,
|
|
510
|
+
value,
|
|
511
|
+
disabled,
|
|
512
|
+
onChange
|
|
513
|
+
}) {
|
|
514
|
+
const [open, setOpen] = React.useState(false);
|
|
515
|
+
const active = value !== "";
|
|
516
|
+
return /* @__PURE__ */ jsxs4(Popover, { open, onOpenChange: setOpen, children: [
|
|
517
|
+
/* @__PURE__ */ jsx7(
|
|
518
|
+
PopoverTrigger,
|
|
519
|
+
{
|
|
520
|
+
disabled,
|
|
521
|
+
"aria-label": "Text colour",
|
|
522
|
+
title: "Text colour",
|
|
523
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
524
|
+
className: toolbarControlClass(tokens, false),
|
|
525
|
+
children: /* @__PURE__ */ jsxs4("span", { className: "relative inline-flex flex-col items-center", children: [
|
|
526
|
+
/* @__PURE__ */ jsx7(Baseline, { className: active ? "text-fg-brand" : void 0 }),
|
|
527
|
+
/* @__PURE__ */ jsx7(
|
|
528
|
+
"span",
|
|
529
|
+
{
|
|
530
|
+
"aria-hidden": "true",
|
|
531
|
+
className: "mt-px h-0.5 w-3 rounded-full",
|
|
532
|
+
style: { backgroundColor: active ? value : "currentColor" }
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
] })
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
/* @__PURE__ */ jsx7(
|
|
539
|
+
PopoverContent,
|
|
540
|
+
{
|
|
541
|
+
showArrow: false,
|
|
542
|
+
align: "start",
|
|
543
|
+
sideOffset: 8,
|
|
544
|
+
className: "w-auto py-3",
|
|
545
|
+
children: /* @__PURE__ */ jsx7("div", { className: "grid grid-cols-4 gap-2 px-4", children: TEXT_COLORS.map((color) => {
|
|
546
|
+
const isSelected = color.value === value;
|
|
547
|
+
return /* @__PURE__ */ jsx7(
|
|
548
|
+
"button",
|
|
549
|
+
{
|
|
550
|
+
type: "button",
|
|
551
|
+
title: color.label,
|
|
552
|
+
"aria-label": color.label,
|
|
553
|
+
"aria-pressed": isSelected,
|
|
554
|
+
onClick: () => {
|
|
555
|
+
onChange(color.value);
|
|
556
|
+
setOpen(false);
|
|
557
|
+
},
|
|
558
|
+
className: cn(
|
|
559
|
+
"flex size-7 items-center justify-center rounded-full border transition-[box-shadow,border-color] outline-none",
|
|
560
|
+
"hover:border-line-strong focus-visible:ring-2 focus-visible:ring-line-focus",
|
|
561
|
+
isSelected ? "border-line-focus ring-2 ring-line-focus/40" : "border-line"
|
|
562
|
+
),
|
|
563
|
+
children: /* @__PURE__ */ jsx7(
|
|
564
|
+
"span",
|
|
565
|
+
{
|
|
566
|
+
className: cn(
|
|
567
|
+
"flex size-5 items-center justify-center rounded-full text-gdt-xs font-bold",
|
|
568
|
+
color.value === "" && "text-fg-secondary"
|
|
569
|
+
),
|
|
570
|
+
style: color.value ? { backgroundColor: color.value, color: "#fff" } : void 0,
|
|
571
|
+
children: "A"
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
},
|
|
575
|
+
color.label
|
|
576
|
+
);
|
|
577
|
+
}) })
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
] });
|
|
581
|
+
}
|
|
582
|
+
function LinkControl({
|
|
583
|
+
tokens,
|
|
584
|
+
active,
|
|
585
|
+
currentHref,
|
|
586
|
+
disabled,
|
|
587
|
+
onApply,
|
|
588
|
+
onRemove
|
|
589
|
+
}) {
|
|
590
|
+
const [open, setOpen] = React.useState(false);
|
|
591
|
+
const [href, setHref] = React.useState("");
|
|
592
|
+
function handleOpenChange(next) {
|
|
593
|
+
if (next) setHref(currentHref);
|
|
594
|
+
setOpen(next);
|
|
595
|
+
}
|
|
596
|
+
function handleSubmit(event) {
|
|
597
|
+
event.preventDefault();
|
|
598
|
+
const trimmed = href.trim();
|
|
599
|
+
if (trimmed) onApply(trimmed);
|
|
600
|
+
else onRemove();
|
|
601
|
+
setOpen(false);
|
|
602
|
+
}
|
|
603
|
+
return /* @__PURE__ */ jsxs4(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
604
|
+
/* @__PURE__ */ jsx7(
|
|
605
|
+
PopoverTrigger,
|
|
606
|
+
{
|
|
607
|
+
disabled,
|
|
608
|
+
"aria-label": "Insert link",
|
|
609
|
+
title: "Insert link",
|
|
610
|
+
"aria-pressed": active,
|
|
611
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
612
|
+
className: toolbarControlClass(tokens, active),
|
|
613
|
+
children: /* @__PURE__ */ jsx7(Link2, {})
|
|
614
|
+
}
|
|
615
|
+
),
|
|
616
|
+
/* @__PURE__ */ jsx7(PopoverContent, { showArrow: false, align: "start", sideOffset: 8, children: /* @__PURE__ */ jsxs4("form", { className: "flex flex-col gap-3 px-4", onSubmit: handleSubmit, children: [
|
|
617
|
+
/* @__PURE__ */ jsx7(
|
|
618
|
+
Input,
|
|
619
|
+
{
|
|
620
|
+
autoFocus: true,
|
|
621
|
+
size: "sm",
|
|
622
|
+
type: "url",
|
|
623
|
+
placeholder: "https://example.com",
|
|
624
|
+
value: href,
|
|
625
|
+
onChange: (event) => setHref(event.target.value)
|
|
626
|
+
}
|
|
627
|
+
),
|
|
628
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
|
|
629
|
+
/* @__PURE__ */ jsx7(
|
|
630
|
+
Button,
|
|
631
|
+
{
|
|
632
|
+
type: "button",
|
|
633
|
+
variant: "tertiary-outline",
|
|
634
|
+
size: "sm",
|
|
635
|
+
disabled: !active,
|
|
636
|
+
onClick: () => {
|
|
637
|
+
onRemove();
|
|
638
|
+
setOpen(false);
|
|
639
|
+
},
|
|
640
|
+
children: "Remove"
|
|
641
|
+
}
|
|
642
|
+
),
|
|
643
|
+
/* @__PURE__ */ jsx7(Button, { type: "submit", size: "sm", children: "Apply" })
|
|
644
|
+
] })
|
|
645
|
+
] }) })
|
|
646
|
+
] });
|
|
647
|
+
}
|
|
648
|
+
var ALIGN_OPTIONS = [
|
|
649
|
+
{ value: "left", label: "Left", Icon: AlignLeft },
|
|
650
|
+
{ value: "center", label: "Center", Icon: AlignCenter },
|
|
651
|
+
{ value: "right", label: "Right", Icon: AlignRight },
|
|
652
|
+
{ value: "justify", label: "Justify", Icon: AlignJustify }
|
|
653
|
+
];
|
|
654
|
+
function AlignControl({
|
|
655
|
+
tokens,
|
|
656
|
+
value,
|
|
657
|
+
disabled,
|
|
658
|
+
onChange
|
|
659
|
+
}) {
|
|
660
|
+
const current = ALIGN_OPTIONS.find((option) => option.value === value);
|
|
661
|
+
const Icon = current?.Icon ?? AlignLeft;
|
|
662
|
+
return /* @__PURE__ */ jsxs4(DropdownMenu, { children: [
|
|
663
|
+
/* @__PURE__ */ jsx7(
|
|
664
|
+
DropdownMenuTrigger,
|
|
665
|
+
{
|
|
666
|
+
disabled,
|
|
667
|
+
"aria-label": "Text alignment",
|
|
668
|
+
title: "Text alignment",
|
|
669
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
670
|
+
className: toolbarControlClass(tokens, value !== "left"),
|
|
671
|
+
children: /* @__PURE__ */ jsx7(Icon, {})
|
|
672
|
+
}
|
|
673
|
+
),
|
|
674
|
+
/* @__PURE__ */ jsx7(DropdownMenuContent, { className: "min-w-36", children: /* @__PURE__ */ jsx7(
|
|
675
|
+
DropdownMenuRadioGroup,
|
|
676
|
+
{
|
|
677
|
+
value,
|
|
678
|
+
onValueChange: (next) => onChange(next),
|
|
679
|
+
children: ALIGN_OPTIONS.map(
|
|
680
|
+
({ value: optionValue, label, Icon: OptionIcon }) => /* @__PURE__ */ jsxs4(DropdownMenuRadioItem, { value: optionValue, children: [
|
|
681
|
+
/* @__PURE__ */ jsx7(OptionIcon, {}),
|
|
682
|
+
label
|
|
683
|
+
] }, optionValue)
|
|
684
|
+
)
|
|
685
|
+
}
|
|
686
|
+
) })
|
|
687
|
+
] });
|
|
688
|
+
}
|
|
689
|
+
var EMPTY_STATE = {
|
|
690
|
+
block: "paragraph",
|
|
691
|
+
align: "left",
|
|
692
|
+
color: "",
|
|
693
|
+
linkHref: "",
|
|
694
|
+
isBold: false,
|
|
695
|
+
isItalic: false,
|
|
696
|
+
isUnderline: false,
|
|
697
|
+
isBulletList: false,
|
|
698
|
+
isOrderedList: false,
|
|
699
|
+
isBlockquote: false,
|
|
700
|
+
isCodeBlock: false,
|
|
701
|
+
isLink: false,
|
|
702
|
+
canUndo: false,
|
|
703
|
+
canRedo: false
|
|
704
|
+
};
|
|
705
|
+
function RichTextEditor({
|
|
706
|
+
value,
|
|
707
|
+
defaultValue,
|
|
708
|
+
onChange,
|
|
709
|
+
size,
|
|
710
|
+
placeholder = "Start writing, or paste your content here. Format text and add lists, links, and images using the toolbar above.",
|
|
711
|
+
disabled = false,
|
|
712
|
+
className,
|
|
713
|
+
"aria-label": ariaLabel = "Rich text editor"
|
|
714
|
+
}) {
|
|
715
|
+
const resolvedSize = useComponentSize(size);
|
|
716
|
+
const tokens = SIZES[resolvedSize];
|
|
717
|
+
const [focused, setFocused] = React.useState(false);
|
|
718
|
+
const editor = useEditor({
|
|
719
|
+
immediatelyRender: false,
|
|
720
|
+
editable: !disabled,
|
|
721
|
+
content: value ?? defaultValue ?? "",
|
|
722
|
+
extensions: [
|
|
723
|
+
StarterKit.configure({
|
|
724
|
+
link: {
|
|
725
|
+
openOnClick: false,
|
|
726
|
+
HTMLAttributes: { rel: "noopener noreferrer nofollow" }
|
|
727
|
+
}
|
|
728
|
+
}),
|
|
729
|
+
TextStyle,
|
|
730
|
+
Color,
|
|
731
|
+
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
732
|
+
Image.configure({ inline: false, allowBase64: true }),
|
|
733
|
+
Placeholder.configure({ placeholder })
|
|
734
|
+
],
|
|
735
|
+
editorProps: {
|
|
736
|
+
attributes: {
|
|
737
|
+
"aria-label": ariaLabel,
|
|
738
|
+
role: "textbox",
|
|
739
|
+
"aria-multiline": "true",
|
|
740
|
+
class: cn("tiptap focus:outline-none", tokens.text)
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
onFocus: () => setFocused(true),
|
|
744
|
+
onBlur: () => setFocused(false),
|
|
745
|
+
onUpdate: ({ editor: instance }) => onChange?.(instance.getHTML())
|
|
746
|
+
});
|
|
747
|
+
React.useEffect(() => {
|
|
748
|
+
editor?.setEditable(!disabled);
|
|
749
|
+
}, [editor, disabled]);
|
|
750
|
+
React.useEffect(() => {
|
|
751
|
+
if (!editor || value === void 0) return;
|
|
752
|
+
if (value !== editor.getHTML()) {
|
|
753
|
+
editor.commands.setContent(value, { emitUpdate: false });
|
|
754
|
+
}
|
|
755
|
+
}, [editor, value]);
|
|
756
|
+
const state = useEditorState({
|
|
757
|
+
editor,
|
|
758
|
+
selector: ({ editor: instance }) => {
|
|
759
|
+
if (!instance) return EMPTY_STATE;
|
|
760
|
+
const block = instance.isActive("heading", { level: 1 }) ? "h1" : instance.isActive("heading", { level: 2 }) ? "h2" : instance.isActive("heading", { level: 3 }) ? "h3" : "paragraph";
|
|
761
|
+
const align = instance.isActive({ textAlign: "center" }) ? "center" : instance.isActive({ textAlign: "right" }) ? "right" : instance.isActive({ textAlign: "justify" }) ? "justify" : "left";
|
|
762
|
+
return {
|
|
763
|
+
block,
|
|
764
|
+
align,
|
|
765
|
+
color: instance.getAttributes("textStyle").color ?? "",
|
|
766
|
+
linkHref: instance.getAttributes("link").href ?? "",
|
|
767
|
+
isBold: instance.isActive("bold"),
|
|
768
|
+
isItalic: instance.isActive("italic"),
|
|
769
|
+
isUnderline: instance.isActive("underline"),
|
|
770
|
+
isBulletList: instance.isActive("bulletList"),
|
|
771
|
+
isOrderedList: instance.isActive("orderedList"),
|
|
772
|
+
isBlockquote: instance.isActive("blockquote"),
|
|
773
|
+
isCodeBlock: instance.isActive("codeBlock"),
|
|
774
|
+
isLink: instance.isActive("link"),
|
|
775
|
+
canUndo: instance.can().undo(),
|
|
776
|
+
canRedo: instance.can().redo()
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
const s = state ?? EMPTY_STATE;
|
|
781
|
+
function setBlock(next) {
|
|
782
|
+
if (!editor) return;
|
|
783
|
+
const chain = editor.chain().focus();
|
|
784
|
+
if (next === "paragraph") chain.setParagraph().run();
|
|
785
|
+
else chain.toggleHeading({ level: Number(next[1]) }).run();
|
|
786
|
+
}
|
|
787
|
+
function setAlign(next) {
|
|
788
|
+
editor?.chain().focus().setTextAlign(next).run();
|
|
789
|
+
}
|
|
790
|
+
function setColor(next) {
|
|
791
|
+
if (!editor) return;
|
|
792
|
+
if (next) editor.chain().focus().setColor(next).run();
|
|
793
|
+
else editor.chain().focus().unsetColor().run();
|
|
794
|
+
}
|
|
795
|
+
function applyLink(href) {
|
|
796
|
+
editor?.chain().focus().extendMarkRange("link").setLink({ href }).run();
|
|
797
|
+
}
|
|
798
|
+
function removeLink() {
|
|
799
|
+
editor?.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
800
|
+
}
|
|
801
|
+
function insertImage() {
|
|
802
|
+
const url = window.prompt("Image URL");
|
|
803
|
+
if (url) editor?.chain().focus().setImage({ src: url }).run();
|
|
804
|
+
}
|
|
805
|
+
return /* @__PURE__ */ jsxs4(
|
|
806
|
+
"div",
|
|
807
|
+
{
|
|
808
|
+
"data-slot": "rich-text-editor",
|
|
809
|
+
"data-disabled": disabled || void 0,
|
|
810
|
+
"data-focused": focused || void 0,
|
|
811
|
+
className: cn(
|
|
812
|
+
"group/editor flex w-full flex-col overflow-hidden rounded-2xl border bg-surface text-fg-primary shadow-1 transition-[border-color,box-shadow]",
|
|
813
|
+
disabled ? "border-line-subtle opacity-60" : focused ? "border-line-focus ring-2 ring-line-focus/35" : "border-line hover:border-line-strong",
|
|
814
|
+
tokens.width,
|
|
815
|
+
className
|
|
816
|
+
),
|
|
817
|
+
children: [
|
|
818
|
+
/* @__PURE__ */ jsxs4(
|
|
819
|
+
"div",
|
|
820
|
+
{
|
|
821
|
+
role: "toolbar",
|
|
822
|
+
"aria-label": "Formatting",
|
|
823
|
+
"aria-orientation": "horizontal",
|
|
824
|
+
className: cn(
|
|
825
|
+
"flex flex-wrap items-center bg-surface-raised",
|
|
826
|
+
tokens.toolbarPad,
|
|
827
|
+
tokens.toolbarGap
|
|
828
|
+
),
|
|
829
|
+
children: [
|
|
830
|
+
/* @__PURE__ */ jsx7(
|
|
831
|
+
BlockControl,
|
|
832
|
+
{
|
|
833
|
+
tokens,
|
|
834
|
+
value: s.block,
|
|
835
|
+
disabled,
|
|
836
|
+
onChange: setBlock
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
/* @__PURE__ */ jsx7(
|
|
840
|
+
ToolbarButton,
|
|
841
|
+
{
|
|
842
|
+
tokens,
|
|
843
|
+
label: "Bold",
|
|
844
|
+
active: s.isBold,
|
|
845
|
+
disabled,
|
|
846
|
+
onClick: () => editor?.chain().focus().toggleBold().run(),
|
|
847
|
+
children: /* @__PURE__ */ jsx7(Bold, {})
|
|
848
|
+
}
|
|
849
|
+
),
|
|
850
|
+
/* @__PURE__ */ jsx7(
|
|
851
|
+
ToolbarButton,
|
|
852
|
+
{
|
|
853
|
+
tokens,
|
|
854
|
+
label: "Italic",
|
|
855
|
+
active: s.isItalic,
|
|
856
|
+
disabled,
|
|
857
|
+
onClick: () => editor?.chain().focus().toggleItalic().run(),
|
|
858
|
+
children: /* @__PURE__ */ jsx7(Italic, {})
|
|
859
|
+
}
|
|
860
|
+
),
|
|
861
|
+
/* @__PURE__ */ jsx7(
|
|
862
|
+
ToolbarButton,
|
|
863
|
+
{
|
|
864
|
+
tokens,
|
|
865
|
+
label: "Underline",
|
|
866
|
+
active: s.isUnderline,
|
|
867
|
+
disabled,
|
|
868
|
+
onClick: () => editor?.chain().focus().toggleUnderline().run(),
|
|
869
|
+
children: /* @__PURE__ */ jsx7(Underline, {})
|
|
870
|
+
}
|
|
871
|
+
),
|
|
872
|
+
/* @__PURE__ */ jsx7(
|
|
873
|
+
ColorControl,
|
|
874
|
+
{
|
|
875
|
+
tokens,
|
|
876
|
+
value: s.color,
|
|
877
|
+
disabled,
|
|
878
|
+
onChange: setColor
|
|
879
|
+
}
|
|
880
|
+
),
|
|
881
|
+
/* @__PURE__ */ jsx7(ToolbarDivider, { tokens }),
|
|
882
|
+
/* @__PURE__ */ jsx7(
|
|
883
|
+
ToolbarButton,
|
|
884
|
+
{
|
|
885
|
+
tokens,
|
|
886
|
+
label: "Numbered list",
|
|
887
|
+
active: s.isOrderedList,
|
|
888
|
+
disabled,
|
|
889
|
+
onClick: () => editor?.chain().focus().toggleOrderedList().run(),
|
|
890
|
+
children: /* @__PURE__ */ jsx7(ListOrdered, {})
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
/* @__PURE__ */ jsx7(
|
|
894
|
+
ToolbarButton,
|
|
895
|
+
{
|
|
896
|
+
tokens,
|
|
897
|
+
label: "Bullet list",
|
|
898
|
+
active: s.isBulletList,
|
|
899
|
+
disabled,
|
|
900
|
+
onClick: () => editor?.chain().focus().toggleBulletList().run(),
|
|
901
|
+
children: /* @__PURE__ */ jsx7(List, {})
|
|
902
|
+
}
|
|
903
|
+
),
|
|
904
|
+
/* @__PURE__ */ jsx7(
|
|
905
|
+
AlignControl,
|
|
906
|
+
{
|
|
907
|
+
tokens,
|
|
908
|
+
value: s.align,
|
|
909
|
+
disabled,
|
|
910
|
+
onChange: setAlign
|
|
911
|
+
}
|
|
912
|
+
),
|
|
913
|
+
/* @__PURE__ */ jsx7(ToolbarDivider, { tokens }),
|
|
914
|
+
/* @__PURE__ */ jsx7(
|
|
915
|
+
LinkControl,
|
|
916
|
+
{
|
|
917
|
+
tokens,
|
|
918
|
+
active: s.isLink,
|
|
919
|
+
currentHref: s.linkHref,
|
|
920
|
+
disabled,
|
|
921
|
+
onApply: applyLink,
|
|
922
|
+
onRemove: removeLink
|
|
923
|
+
}
|
|
924
|
+
),
|
|
925
|
+
/* @__PURE__ */ jsx7(
|
|
926
|
+
ToolbarButton,
|
|
927
|
+
{
|
|
928
|
+
tokens,
|
|
929
|
+
label: "Quote",
|
|
930
|
+
active: s.isBlockquote,
|
|
931
|
+
disabled,
|
|
932
|
+
onClick: () => editor?.chain().focus().toggleBlockquote().run(),
|
|
933
|
+
children: /* @__PURE__ */ jsx7(Quote, {})
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
/* @__PURE__ */ jsx7(
|
|
937
|
+
ToolbarButton,
|
|
938
|
+
{
|
|
939
|
+
tokens,
|
|
940
|
+
label: "Code block",
|
|
941
|
+
active: s.isCodeBlock,
|
|
942
|
+
disabled,
|
|
943
|
+
onClick: () => editor?.chain().focus().toggleCodeBlock().run(),
|
|
944
|
+
children: /* @__PURE__ */ jsx7(Code2, {})
|
|
945
|
+
}
|
|
946
|
+
),
|
|
947
|
+
/* @__PURE__ */ jsx7(
|
|
948
|
+
ToolbarButton,
|
|
949
|
+
{
|
|
950
|
+
tokens,
|
|
951
|
+
label: "Insert image",
|
|
952
|
+
disabled,
|
|
953
|
+
onClick: insertImage,
|
|
954
|
+
children: /* @__PURE__ */ jsx7(ImageIcon, {})
|
|
955
|
+
}
|
|
956
|
+
),
|
|
957
|
+
/* @__PURE__ */ jsx7(ToolbarDivider, { tokens }),
|
|
958
|
+
/* @__PURE__ */ jsx7(
|
|
959
|
+
ToolbarButton,
|
|
960
|
+
{
|
|
961
|
+
tokens,
|
|
962
|
+
label: "Undo",
|
|
963
|
+
disabled: disabled || !s.canUndo,
|
|
964
|
+
onClick: () => editor?.chain().focus().undo().run(),
|
|
965
|
+
children: /* @__PURE__ */ jsx7(Undo2, {})
|
|
966
|
+
}
|
|
967
|
+
),
|
|
968
|
+
/* @__PURE__ */ jsx7(
|
|
969
|
+
ToolbarButton,
|
|
970
|
+
{
|
|
971
|
+
tokens,
|
|
972
|
+
label: "Redo",
|
|
973
|
+
disabled: disabled || !s.canRedo,
|
|
974
|
+
onClick: () => editor?.chain().focus().redo().run(),
|
|
975
|
+
children: /* @__PURE__ */ jsx7(Redo2, {})
|
|
976
|
+
}
|
|
977
|
+
)
|
|
978
|
+
]
|
|
979
|
+
}
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ jsx7("div", { className: "h-px w-full shrink-0 bg-line-subtle" }),
|
|
982
|
+
/* @__PURE__ */ jsx7(
|
|
983
|
+
EditorContent,
|
|
984
|
+
{
|
|
985
|
+
editor,
|
|
986
|
+
className: cn(
|
|
987
|
+
"gdt-rich-text min-w-0 flex-1 overflow-y-auto",
|
|
988
|
+
tokens.content,
|
|
989
|
+
tokens.contentPad
|
|
990
|
+
)
|
|
991
|
+
}
|
|
992
|
+
)
|
|
993
|
+
]
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
export {
|
|
998
|
+
RichTextEditor
|
|
999
|
+
};
|
|
1000
|
+
//# sourceMappingURL=rich-text-editor.js.map
|