@payloadcms/ui 4.0.0-internal.9726517 → 4.0.0-internal.a6582c6
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/css/app.css +121 -0
- package/dist/css/forms.css +0 -6
- package/dist/css/spacing.css +11 -3
- package/dist/css/z-index.css +1 -0
- package/dist/elements/AddNewRelation/index.css +0 -1
- package/dist/elements/AppHeader/index.css +0 -3
- package/dist/elements/AppHeader/index.d.ts.map +1 -1
- package/dist/elements/AppHeader/index.js +5 -1
- package/dist/elements/AppHeader/index.js.map +1 -1
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js +2 -2
- package/dist/elements/BulkUpload/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/BulkUpload/FileSidebar/index.css +4 -0
- package/dist/elements/CodeEditor/index.css +0 -5
- package/dist/elements/CommandPalette/index.css +0 -7
- package/dist/elements/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/elements/DatePicker/DatePicker.js +1 -0
- package/dist/elements/DatePicker/DatePicker.js.map +1 -1
- package/dist/elements/DatePicker/index.css +1 -1
- package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
- package/dist/elements/DeleteDocument/index.js +16 -1
- package/dist/elements/DeleteDocument/index.js.map +1 -1
- package/dist/elements/EditMany/DrawerContent.js +2 -2
- package/dist/elements/EditMany/DrawerContent.js.map +1 -1
- package/dist/elements/FileDetails/StaticFileDetails/index.css +8 -9
- package/dist/elements/FileManager/FilePreview/index.css +3 -3
- package/dist/elements/FileManager/index.css +36 -23
- package/dist/elements/FileManager/index.d.ts.map +1 -1
- package/dist/elements/FileManager/index.js +15 -4
- package/dist/elements/FileManager/index.js.map +1 -1
- package/dist/elements/Hierarchy/ColumnBrowser/ColumnItem/index.css +0 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js +109 -89
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.d.ts.map +1 -1
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js +2 -0
- package/dist/elements/Hierarchy/Tree/HierarchySidebarTab.server.js.map +1 -1
- package/dist/elements/Hierarchy/Tree/TreeNode/index.css +0 -1
- package/dist/elements/InputStepper/index.css +0 -1
- package/dist/elements/Locked/index.css +0 -8
- package/dist/elements/Locked/index.d.ts.map +1 -1
- package/dist/elements/Locked/index.js +70 -64
- package/dist/elements/Locked/index.js.map +1 -1
- package/dist/elements/MiniCarousel/index.css +39 -37
- package/dist/elements/Nav/SidebarTabs/index.client.d.ts.map +1 -1
- package/dist/elements/Nav/SidebarTabs/index.client.js +12 -5
- package/dist/elements/Nav/SidebarTabs/index.client.js.map +1 -1
- package/dist/elements/Nav/SidebarTabs/index.css +0 -5
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts +1 -0
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.d.ts.map +1 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js +2 -1
- package/dist/elements/Nav/SidebarTabs/renderTabServerFn.js.map +1 -1
- package/dist/elements/NavGroup/index.css +0 -1
- package/dist/elements/PreviewButton/index.d.ts +1 -2
- package/dist/elements/PreviewButton/index.d.ts.map +1 -1
- package/dist/elements/PreviewButton/index.js +11 -5
- package/dist/elements/PreviewButton/index.js.map +1 -1
- package/dist/elements/PreviewSizes/index.css +8 -9
- package/dist/elements/ReactSelect/ClearIndicator/index.css +0 -1
- package/dist/elements/ReactSelect/MultiValue/index.css +0 -1
- package/dist/elements/ReactSelect/MultiValueLabel/index.css +2 -2
- package/dist/elements/ReactSelect/index.css +0 -3
- package/dist/elements/RelationshipTable/Pagination.d.ts +0 -1
- package/dist/elements/RelationshipTable/Pagination.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/Pagination.js +27 -77
- package/dist/elements/RelationshipTable/Pagination.js.map +1 -1
- package/dist/elements/RelationshipTable/index.d.ts +1 -0
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +36 -3
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- package/dist/elements/RenderTitle/index.css +4 -0
- package/dist/elements/RenderTitle/index.d.ts.map +1 -1
- package/dist/elements/RenderTitle/index.js +18 -13
- package/dist/elements/RenderTitle/index.js.map +1 -1
- package/dist/elements/SelectRow/index.d.ts +4 -3
- package/dist/elements/SelectRow/index.d.ts.map +1 -1
- package/dist/elements/SelectRow/index.js +10 -7
- package/dist/elements/SelectRow/index.js.map +1 -1
- package/dist/elements/SidebarToggle/index.css +0 -17
- package/dist/elements/SortColumn/index.d.ts.map +1 -1
- package/dist/elements/SortColumn/index.js +42 -38
- package/dist/elements/SortColumn/index.js.map +1 -1
- package/dist/elements/TableSection/index.css +0 -1
- package/dist/elements/Tooltip/index.css +15 -34
- package/dist/elements/Tooltip/index.d.ts +11 -3
- package/dist/elements/Tooltip/index.d.ts.map +1 -1
- package/dist/elements/Tooltip/index.js +151 -85
- package/dist/elements/Tooltip/index.js.map +1 -1
- package/dist/elements/Upload/index.css +0 -5
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +3 -3
- package/dist/fields/Blocks/index.js +3 -3
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/Input.d.ts +2 -0
- package/dist/fields/Checkbox/Input.d.ts.map +1 -1
- package/dist/fields/Checkbox/Input.js +32 -26
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/index.css +37 -73
- package/dist/fields/FieldError/index.css +0 -9
- package/dist/fields/FieldError/index.d.ts.map +1 -1
- package/dist/fields/FieldError/index.js +19 -9
- package/dist/fields/FieldError/index.js.map +1 -1
- package/dist/fields/Join/index.css +9 -0
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +13 -9
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.css +0 -7
- package/dist/fields/Relationship/Input.d.ts.map +1 -1
- package/dist/fields/Relationship/Input.js +32 -14
- package/dist/fields/Relationship/Input.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.css +1 -1
- package/dist/fields/Slug/index.css +0 -1
- package/dist/fields/Slug/index.d.ts.map +1 -1
- package/dist/fields/Slug/index.js +75 -111
- package/dist/fields/Slug/index.js.map +1 -1
- package/dist/fields/Upload/index.css +19 -4
- package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
- package/dist/forms/Form/fieldReducer.js +3 -1
- package/dist/forms/Form/fieldReducer.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +6 -1
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/types.d.ts +1 -1
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/forms/WatchChildErrors/index.d.ts.map +1 -1
- package/dist/forms/WatchChildErrors/index.js +2 -2
- package/dist/forms/WatchChildErrors/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +1 -3
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +8 -2
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/providers/DocumentTitle/index.d.ts +1 -0
- package/dist/providers/DocumentTitle/index.d.ts.map +1 -1
- package/dist/providers/DocumentTitle/index.js +2 -0
- package/dist/providers/DocumentTitle/index.js.map +1 -1
- package/dist/providers/Embed/index.d.ts +24 -0
- package/dist/providers/Embed/index.d.ts.map +1 -0
- package/dist/providers/Embed/index.js +105 -0
- package/dist/providers/Embed/index.js.map +1 -0
- package/dist/providers/FormErrorHandler/index.d.ts +20 -0
- package/dist/providers/FormErrorHandler/index.d.ts.map +1 -0
- package/dist/providers/FormErrorHandler/index.js +6 -0
- package/dist/providers/FormErrorHandler/index.js.map +1 -0
- package/dist/providers/Root/index.d.ts +1 -0
- package/dist/providers/Root/index.d.ts.map +1 -1
- package/dist/providers/Root/index.js +33 -27
- package/dist/providers/Root/index.js.map +1 -1
- package/dist/providers/SidebarTabs/index.d.ts +3 -2
- package/dist/providers/SidebarTabs/index.d.ts.map +1 -1
- package/dist/providers/SidebarTabs/index.js.map +1 -1
- package/dist/providers/Theme/index.d.ts +3 -0
- package/dist/providers/Theme/index.d.ts.map +1 -1
- package/dist/providers/Theme/index.js +107 -95
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/styles.css +13 -10
- package/dist/utilities/combineFieldLabel.d.ts.map +1 -1
- package/dist/utilities/combineFieldLabel.js +5 -1
- package/dist/utilities/combineFieldLabel.js.map +1 -1
- package/dist/utilities/generateFieldID.d.ts +1 -1
- package/dist/utilities/generateFieldID.d.ts.map +1 -1
- package/dist/utilities/generateFieldID.js +2 -2
- package/dist/utilities/generateFieldID.js.map +1 -1
- package/dist/utilities/getRequestEmbed.d.ts +14 -0
- package/dist/utilities/getRequestEmbed.d.ts.map +1 -0
- package/dist/utilities/getRequestEmbed.js +10 -0
- package/dist/utilities/getRequestEmbed.js.map +1 -0
- package/dist/utilities/handleServerFunctions.d.ts +32 -8
- package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
- package/dist/utilities/handleServerFunctions.js +17 -37
- package/dist/utilities/handleServerFunctions.js.map +1 -1
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +18 -2
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/utilities/serverFunctionRegistry.d.ts +12 -7
- package/dist/utilities/serverFunctionRegistry.d.ts.map +1 -1
- package/dist/utilities/serverFunctionRegistry.js +25 -7
- package/dist/utilities/serverFunctionRegistry.js.map +1 -1
- package/dist/utilities/slugify.d.ts.map +1 -1
- package/dist/utilities/slugify.js +49 -6
- package/dist/utilities/slugify.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/index.css +0 -8
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js +4 -4
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/RenderWidget.js.map +1 -1
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js +10 -10
- package/dist/views/Dashboard/Default/ModularDashboard/renderWidget/renderWidgetServerFn.js.map +1 -1
- package/dist/views/Edit/index.css +61 -53
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +4 -0
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/Logout/index.d.ts.map +1 -1
- package/dist/views/Logout/index.js +11 -0
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/Root/index.d.ts +12 -1
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +10 -3
- package/dist/views/Root/index.js.map +1 -1
- package/package.json +6 -11
- package/dist/elements/RelationshipTable/Pagination.css +0 -39
- package/dist/scss/app.scss +0 -183
- package/dist/scss/colors.scss +0 -191
- package/dist/scss/custom.css +0 -1
- package/dist/scss/queries.scss +0 -27
- package/dist/scss/styles.scss +0 -9
- package/dist/scss/svg.scss +0 -10
- package/dist/scss/toastify.scss +0 -61
- package/dist/scss/vars.scss +0 -192
- package/dist/scss/z-index.scss +0 -9
|
@@ -10,7 +10,7 @@ import { useTranslation } from '../../providers/Translation/index.js';
|
|
|
10
10
|
import './index.css';
|
|
11
11
|
const baseClass = 'sort-column';
|
|
12
12
|
export const SortColumn = props => {
|
|
13
|
-
const $ = _c(
|
|
13
|
+
const $ = _c(21);
|
|
14
14
|
const {
|
|
15
15
|
name,
|
|
16
16
|
appearance,
|
|
@@ -56,22 +56,29 @@ export const SortColumn = props => {
|
|
|
56
56
|
descClasses = $[5];
|
|
57
57
|
}
|
|
58
58
|
const isSorted = sort === asc || sort === desc;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
let t1;
|
|
60
|
+
if ($[6] !== Label || $[7] !== appearance || $[8] !== asc || $[9] !== ascClasses || $[10] !== desc || $[11] !== descClasses || $[12] !== disable || $[13] !== handleSortChange || $[14] !== isSorted || $[15] !== label || $[16] !== t) {
|
|
61
|
+
const descLabel = t("general:sortByLabelDirection", {
|
|
62
|
+
direction: t("general:descending"),
|
|
63
|
+
label
|
|
64
|
+
});
|
|
65
|
+
const ascLabel = t("general:sortByLabelDirection", {
|
|
66
|
+
direction: t("general:ascending"),
|
|
67
|
+
label
|
|
68
|
+
});
|
|
69
|
+
const t2 = appearance && `${baseClass}--appearance-${appearance}`;
|
|
70
|
+
const t3 = isSorted && `${baseClass}--sorted`;
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[18] !== t2 || $[19] !== t3) {
|
|
73
|
+
t4 = [baseClass, t2, t3].filter(Boolean);
|
|
74
|
+
$[18] = t2;
|
|
75
|
+
$[19] = t3;
|
|
76
|
+
$[20] = t4;
|
|
77
|
+
} else {
|
|
78
|
+
t4 = $[20];
|
|
79
|
+
}
|
|
80
|
+
t1 = _jsxs("div", {
|
|
81
|
+
className: t4.join(" "),
|
|
75
82
|
children: [_jsx("span", {
|
|
76
83
|
className: `${baseClass}__label`,
|
|
77
84
|
children: Label ?? _jsx(FieldLabel, {
|
|
@@ -82,23 +89,19 @@ export const SortColumn = props => {
|
|
|
82
89
|
}), !disable && _jsxs("div", {
|
|
83
90
|
className: `${baseClass}__buttons`,
|
|
84
91
|
children: [_jsx("button", {
|
|
85
|
-
"aria-label":
|
|
86
|
-
direction: t("general:descending"),
|
|
87
|
-
label
|
|
88
|
-
}),
|
|
92
|
+
"aria-label": descLabel,
|
|
89
93
|
className: [...descClasses, `${baseClass}__button`].filter(Boolean).join(" "),
|
|
90
94
|
onClick: () => void handleSortChange(desc),
|
|
95
|
+
title: descLabel,
|
|
91
96
|
type: "button",
|
|
92
97
|
children: _jsx(ChevronIcon, {
|
|
93
98
|
size: 16
|
|
94
99
|
})
|
|
95
100
|
}), _jsx("button", {
|
|
96
|
-
"aria-label":
|
|
97
|
-
direction: t("general:ascending"),
|
|
98
|
-
label
|
|
99
|
-
}),
|
|
101
|
+
"aria-label": ascLabel,
|
|
100
102
|
className: [...ascClasses, `${baseClass}__button`].filter(Boolean).join(" "),
|
|
101
103
|
onClick: () => void handleSortChange(asc),
|
|
104
|
+
title: ascLabel,
|
|
102
105
|
type: "button",
|
|
103
106
|
children: _jsx(ChevronIcon, {
|
|
104
107
|
direction: "up",
|
|
@@ -107,20 +110,21 @@ export const SortColumn = props => {
|
|
|
107
110
|
})]
|
|
108
111
|
})]
|
|
109
112
|
});
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
113
|
+
$[6] = Label;
|
|
114
|
+
$[7] = appearance;
|
|
115
|
+
$[8] = asc;
|
|
116
|
+
$[9] = ascClasses;
|
|
117
|
+
$[10] = desc;
|
|
118
|
+
$[11] = descClasses;
|
|
119
|
+
$[12] = disable;
|
|
120
|
+
$[13] = handleSortChange;
|
|
121
|
+
$[14] = isSorted;
|
|
122
|
+
$[15] = label;
|
|
123
|
+
$[16] = t;
|
|
124
|
+
$[17] = t1;
|
|
121
125
|
} else {
|
|
122
|
-
|
|
126
|
+
t1 = $[17];
|
|
123
127
|
}
|
|
124
|
-
return
|
|
128
|
+
return t1;
|
|
125
129
|
};
|
|
126
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","FieldLabel","ChevronIcon","useListQuery","useTranslation","baseClass","SortColumn","props","$","name","appearance","disable","t0","Label","label","undefined","handleSortChange","query","t","sort","desc","asc","ascClasses","push","descClasses","isSorted","t1","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","FieldLabel","ChevronIcon","useListQuery","useTranslation","baseClass","SortColumn","props","$","name","appearance","disable","t0","Label","label","undefined","handleSortChange","query","t","sort","desc","asc","ascClasses","push","descClasses","isSorted","t1","descLabel","direction","ascLabel","t2","t3","t4","filter","Boolean","_jsxs","className","join","children","_jsx","hideLocale","unstyled","onClick","title","type","size"],"sources":["../../../src/elements/SortColumn/index.tsx"],"sourcesContent":["'use client'\nimport type { StaticLabel } from 'payload'\n\nimport React from 'react'\n\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport './index.css'\n\nexport type SortColumnProps = {\n readonly appearance?: 'condensed' | 'default'\n readonly disable?: boolean\n readonly Label: React.ReactNode\n readonly label?: StaticLabel\n readonly name: string\n}\n\nconst baseClass = 'sort-column'\n\nexport const SortColumn: React.FC<SortColumnProps> = (props) => {\n const { name, appearance, disable = false, Label, label } = props\n const { handleSortChange, query } = useListQuery()\n const { t } = useTranslation()\n\n const { sort } = query\n\n const desc = `-${name}`\n const asc = name\n\n const ascClasses = [`${baseClass}__asc`]\n if (sort === asc) {\n ascClasses.push(`${baseClass}--active`)\n }\n\n const descClasses = [`${baseClass}__desc`]\n if (sort === desc) {\n descClasses.push(`${baseClass}--active`)\n }\n\n const isSorted = sort === asc || sort === desc\n\n const descLabel = t('general:sortByLabelDirection', {\n direction: t('general:descending'),\n label,\n })\n const ascLabel = t('general:sortByLabelDirection', {\n direction: t('general:ascending'),\n label,\n })\n\n return (\n <div\n className={[\n baseClass,\n appearance && `${baseClass}--appearance-${appearance}`,\n isSorted && `${baseClass}--sorted`,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <span className={`${baseClass}__label`}>\n {Label ?? <FieldLabel hideLocale label={label} unstyled />}\n </span>\n {!disable && (\n <div className={`${baseClass}__buttons`}>\n <button\n aria-label={descLabel}\n className={[...descClasses, `${baseClass}__button`].filter(Boolean).join(' ')}\n onClick={() => void handleSortChange(desc)}\n title={descLabel}\n type=\"button\"\n >\n <ChevronIcon size={16} />\n </button>\n <button\n aria-label={ascLabel}\n className={[...ascClasses, `${baseClass}__button`].filter(Boolean).join(' ')}\n onClick={() => void handleSortChange(asc)}\n title={ascLabel}\n type=\"button\"\n >\n <ChevronIcon direction=\"up\" size={16} />\n </button>\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
--caret-height: 7px;
|
|
5
5
|
--caret-offset: 4px;
|
|
6
6
|
--caret-border-color: var(--color-border);
|
|
7
|
-
--tooltip-x: -50%;
|
|
8
7
|
--tooltip-caret-x: 0px;
|
|
8
|
+
--tooltip-caret-y: 0px;
|
|
9
9
|
--tooltip-max-width: none;
|
|
10
10
|
|
|
11
|
+
position: fixed;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
z-index: var(--z-portal-element);
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
|
|
11
17
|
opacity: 0;
|
|
12
18
|
background-color: var(--color-bg-tooltip);
|
|
13
|
-
position: absolute;
|
|
14
|
-
z-index: 3;
|
|
15
|
-
left: 50%;
|
|
16
19
|
max-width: var(--tooltip-max-width);
|
|
17
20
|
padding: var(--spacer-1);
|
|
18
21
|
color: var(--color-text-ontooltip);
|
|
@@ -26,6 +29,11 @@
|
|
|
26
29
|
box-shadow: var(--elevation-300-tooltip);
|
|
27
30
|
visibility: hidden;
|
|
28
31
|
|
|
32
|
+
&[data-wrap] {
|
|
33
|
+
white-space: normal;
|
|
34
|
+
overflow-wrap: break-word;
|
|
35
|
+
}
|
|
36
|
+
|
|
29
37
|
&.field-error {
|
|
30
38
|
background-color: var(--color-bg-danger);
|
|
31
39
|
color: var(--color-text-ondanger);
|
|
@@ -51,11 +59,6 @@
|
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
.tooltip--wrap {
|
|
55
|
-
white-space: normal;
|
|
56
|
-
overflow-wrap: break-word;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
62
|
.tooltip__caret {
|
|
60
63
|
position: absolute;
|
|
61
64
|
pointer-events: none;
|
|
@@ -76,7 +79,6 @@
|
|
|
76
79
|
.tooltip--show {
|
|
77
80
|
visibility: visible;
|
|
78
81
|
opacity: 1;
|
|
79
|
-
transition: opacity 0.2s ease-in-out;
|
|
80
82
|
cursor: default;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -94,13 +96,6 @@
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
.tooltip--position-top {
|
|
97
|
-
top: 0;
|
|
98
|
-
transform: translate3d(
|
|
99
|
-
var(--tooltip-x),
|
|
100
|
-
calc(-100% - var(--caret-height) - var(--caret-offset) + 1px),
|
|
101
|
-
0
|
|
102
|
-
);
|
|
103
|
-
|
|
104
99
|
.tooltip__caret {
|
|
105
100
|
--color-border: var(--ramp-grey-700);
|
|
106
101
|
top: calc(100% - 0.5px);
|
|
@@ -112,13 +107,6 @@
|
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
.tooltip--position-bottom {
|
|
115
|
-
top: 100%;
|
|
116
|
-
transform: translate3d(
|
|
117
|
-
var(--tooltip-x),
|
|
118
|
-
calc(var(--caret-height) + var(--caret-offset) - 1px),
|
|
119
|
-
0
|
|
120
|
-
);
|
|
121
|
-
|
|
122
110
|
.tooltip__caret {
|
|
123
111
|
bottom: calc(100% - 0.5px);
|
|
124
112
|
transform: rotate(180deg);
|
|
@@ -134,28 +122,21 @@
|
|
|
134
122
|
}
|
|
135
123
|
|
|
136
124
|
.tooltip--position-left {
|
|
137
|
-
top: 50%;
|
|
138
|
-
left: 0;
|
|
139
|
-
transform: translate3d(calc(-100% - var(--caret-height) - var(--caret-offset)), -50%, 0);
|
|
140
|
-
|
|
141
125
|
.tooltip__caret {
|
|
142
126
|
top: calc(50% + 0.5px);
|
|
143
127
|
left: calc(100% - 0.5px);
|
|
144
|
-
transform: translateY(calc(1 * var(--caret-width) / 2
|
|
128
|
+
transform: translateY(calc(1 * var(--caret-width) / 2 + var(--tooltip-caret-y)))
|
|
129
|
+
rotate(-90deg);
|
|
145
130
|
transform-origin: top left;
|
|
146
131
|
}
|
|
147
132
|
}
|
|
148
133
|
|
|
149
134
|
.tooltip--position-right {
|
|
150
|
-
top: 50%;
|
|
151
|
-
left: 100%;
|
|
152
|
-
transform: translate3d(calc(var(--caret-height) + var(--caret-offset)), -50%, 0);
|
|
153
|
-
|
|
154
135
|
.tooltip__caret {
|
|
155
136
|
top: calc(50% + 0.5px);
|
|
156
137
|
left: unset;
|
|
157
138
|
right: calc(100% - 0.5px);
|
|
158
|
-
transform: translateY(calc(1 * var(--caret-width) / 2)) rotate(90deg);
|
|
139
|
+
transform: translateY(calc(1 * var(--caret-width) / 2 + var(--tooltip-caret-y))) rotate(90deg);
|
|
159
140
|
transform-origin: top right;
|
|
160
141
|
}
|
|
161
142
|
}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './index.css';
|
|
3
|
+
type Side = 'bottom' | 'left' | 'right' | 'top';
|
|
3
4
|
export type Props = {
|
|
4
5
|
alignCaret?: 'center' | 'left' | 'right';
|
|
5
|
-
boundingRef?: React.RefObject<HTMLElement | null>;
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
8
8
|
delay?: number;
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Applied to the portaled tooltip element, so it can be located independent of its
|
|
11
|
+
* position in the DOM (e.g. by tests).
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
position?: Side;
|
|
10
15
|
show?: boolean;
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
17
|
+
* Disables adaptive placement: the tooltip always renders on `position` (or its
|
|
18
|
+
* default) instead of flipping to whichever side has room. It does not affect
|
|
19
|
+
* portaling - every tooltip is portaled to `document.body` regardless. @default false
|
|
13
20
|
*/
|
|
14
21
|
staticPositioning?: boolean;
|
|
15
22
|
};
|
|
16
23
|
export declare const Tooltip: React.FC<Props>;
|
|
24
|
+
export {};
|
|
17
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Tooltip/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/Tooltip/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoE,MAAM,OAAO,CAAA;AAGxF,OAAO,aAAa,CAAA;AAOpB,KAAK,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAA;AAE/C,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,IAAI,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAwCD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAyOnC,CAAA"}
|
|
@@ -2,24 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import { autoUpdate, computePosition, flip, hide, offset, shift, size } from '@floating-ui/dom';
|
|
6
|
+
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
7
8
|
import './index.css';
|
|
8
|
-
// Breathing room (px) between a shifted tooltip and its clipping edge. Maps to `--spacer-1`.
|
|
9
9
|
const EDGE_GUTTER = 4;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
while (current) {
|
|
13
|
-
const {
|
|
14
|
-
overflowX
|
|
15
|
-
} = window.getComputedStyle(current);
|
|
16
|
-
if (overflowX === 'auto' || overflowX === 'clip' || overflowX === 'hidden' || overflowX === 'scroll') {
|
|
17
|
-
return current.getBoundingClientRect();
|
|
18
|
-
}
|
|
19
|
-
current = current.parentElement;
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
10
|
+
const TOP_BOTTOM_OFFSET = 10;
|
|
11
|
+
const LEFT_RIGHT_OFFSET = 11;
|
|
23
12
|
const TooltipCaret = () => {
|
|
24
13
|
const $ = _c(2);
|
|
25
14
|
const clipId = React.useId();
|
|
@@ -55,10 +44,24 @@ const TooltipCaret = () => {
|
|
|
55
44
|
}
|
|
56
45
|
return t0;
|
|
57
46
|
};
|
|
47
|
+
const isTriggerHidden = element => {
|
|
48
|
+
if (typeof element.checkVisibility === 'function') {
|
|
49
|
+
return !element.checkVisibility();
|
|
50
|
+
}
|
|
51
|
+
// Fallback for browsers without `checkVisibility`: an element collapsed by a
|
|
52
|
+
// `display: none` ancestor has no client rects.
|
|
53
|
+
return element.getClientRects().length === 0;
|
|
54
|
+
};
|
|
55
|
+
const toPlacement = (side, alignCaret) => {
|
|
56
|
+
if (side === 'left' || side === 'right' || alignCaret === 'center') {
|
|
57
|
+
return side;
|
|
58
|
+
}
|
|
59
|
+
return `${side}-${alignCaret === 'left' ? 'start' : 'end'}`;
|
|
60
|
+
};
|
|
58
61
|
export const Tooltip = props => {
|
|
59
62
|
const {
|
|
63
|
+
id,
|
|
60
64
|
alignCaret = 'center',
|
|
61
|
-
boundingRef,
|
|
62
65
|
children,
|
|
63
66
|
className,
|
|
64
67
|
delay = 500,
|
|
@@ -66,15 +69,16 @@ export const Tooltip = props => {
|
|
|
66
69
|
show: showFromProps = true,
|
|
67
70
|
staticPositioning = false
|
|
68
71
|
} = props;
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const [
|
|
72
|
-
const [
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
const generatedID = React.useId();
|
|
73
|
+
const tooltipID = id || generatedID;
|
|
74
|
+
const [show, setShow] = useState(showFromProps);
|
|
75
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
76
|
+
const [placement, setPlacement] = useState(positionFromProps || 'top');
|
|
77
|
+
// A hidden marker rendered where the tooltip used to live in the DOM, so its
|
|
78
|
+
// parent element can be used as the floating-ui reference for the portaled tooltip.
|
|
79
|
+
const triggerMarkerRef = useRef(null);
|
|
80
|
+
const floatingRef = useRef(null);
|
|
81
|
+
const updateTokenRef = useRef(0);
|
|
78
82
|
useEffect(() => {
|
|
79
83
|
let timerID;
|
|
80
84
|
// do not use the delay on transition-out
|
|
@@ -91,83 +95,145 @@ export const Tooltip = props => {
|
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
}, [showFromProps, delay]);
|
|
98
|
+
// Keep the tooltip mounted for the duration of its fade-out transition so the
|
|
99
|
+
// portal doesn't disappear abruptly when `show` flips back to false.
|
|
94
100
|
useEffect(() => {
|
|
95
|
-
if (
|
|
101
|
+
if (show) {
|
|
102
|
+
setIsMounted(true);
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
// Matches the `.tooltip--show` opacity transition duration.
|
|
106
|
+
const timeoutID = setTimeout(() => setIsMounted(false), 200);
|
|
107
|
+
return () => {
|
|
108
|
+
clearTimeout(timeoutID);
|
|
109
|
+
};
|
|
110
|
+
}, [show]);
|
|
111
|
+
const updatePosition = useCallback(async () => {
|
|
112
|
+
const trigger = triggerMarkerRef.current?.parentElement;
|
|
113
|
+
const floatingElement = floatingRef.current;
|
|
114
|
+
if (!trigger || !floatingElement) {
|
|
108
115
|
return;
|
|
109
116
|
}
|
|
110
|
-
const
|
|
111
|
-
const boundary =
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
const token = ++updateTokenRef.current;
|
|
118
|
+
const boundary = 'clippingAncestors';
|
|
119
|
+
const canFlip = !staticPositioning && !positionFromProps;
|
|
120
|
+
const {
|
|
121
|
+
middlewareData,
|
|
122
|
+
placement: resolvedPlacement,
|
|
123
|
+
x,
|
|
124
|
+
y
|
|
125
|
+
} = await computePosition(trigger, floatingElement, {
|
|
126
|
+
middleware: [offset(({
|
|
127
|
+
placement: currentPlacement
|
|
128
|
+
}) => currentPlacement.startsWith('left') || currentPlacement.startsWith('right') ? LEFT_RIGHT_OFFSET : TOP_BOTTOM_OFFSET), ...(canFlip ? [flip({
|
|
129
|
+
boundary,
|
|
130
|
+
padding: EDGE_GUTTER
|
|
131
|
+
})] : []), ...(staticPositioning ? [] : [shift({
|
|
132
|
+
boundary,
|
|
133
|
+
padding: EDGE_GUTTER
|
|
134
|
+
}), size({
|
|
135
|
+
apply({
|
|
136
|
+
availableWidth,
|
|
137
|
+
elements
|
|
138
|
+
}) {
|
|
139
|
+
const shouldWrap = elements.floating.scrollWidth > availableWidth;
|
|
140
|
+
elements.floating.toggleAttribute('data-wrap', shouldWrap);
|
|
141
|
+
elements.floating.style.setProperty('--tooltip-max-width', shouldWrap ? `${Math.floor(availableWidth)}px` : '');
|
|
142
|
+
},
|
|
143
|
+
boundary,
|
|
144
|
+
padding: EDGE_GUTTER
|
|
145
|
+
})]), hide({
|
|
146
|
+
boundary: 'clippingAncestors'
|
|
147
|
+
})],
|
|
148
|
+
placement: toPlacement(positionFromProps || 'top', alignCaret),
|
|
149
|
+
strategy: 'fixed'
|
|
150
|
+
});
|
|
151
|
+
// A newer call already applied a fresher position - discard this stale result.
|
|
152
|
+
if (token !== updateTokenRef.current) {
|
|
153
|
+
return;
|
|
129
154
|
}
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
const hidden = isTriggerHidden(trigger) || Boolean(middlewareData.hide?.referenceHidden);
|
|
156
|
+
Object.assign(floatingElement.style, {
|
|
157
|
+
left: `${x}px`,
|
|
158
|
+
top: `${y}px`,
|
|
159
|
+
visibility: hidden ? 'hidden' : ''
|
|
160
|
+
});
|
|
161
|
+
const resolvedSide = resolvedPlacement.split('-')[0];
|
|
162
|
+
const isHorizontalSide = resolvedSide === 'left' || resolvedSide === 'right';
|
|
163
|
+
const shiftX = !isHorizontalSide && alignCaret === 'center' ? middlewareData.shift?.x || 0 : 0;
|
|
164
|
+
const shiftY = isHorizontalSide ? middlewareData.shift?.y || 0 : 0;
|
|
165
|
+
floatingElement.style.setProperty('--tooltip-caret-x', shiftX ? `${-shiftX}px` : '0px');
|
|
166
|
+
floatingElement.style.setProperty('--tooltip-caret-y', shiftY ? `${-shiftY}px` : '0px');
|
|
167
|
+
setPlacement(resolvedSide);
|
|
168
|
+
}, [alignCaret, positionFromProps, staticPositioning]);
|
|
169
|
+
const setFloatingElement = useCallback(element => {
|
|
170
|
+
floatingRef.current = element;
|
|
171
|
+
void updatePosition();
|
|
172
|
+
}, [updatePosition]);
|
|
173
|
+
// While mounted, let floating-ui keep the portaled tooltip aligned to its trigger
|
|
174
|
+
// as the page scrolls, the trigger resizes or moves, or a hidden ancestor becomes
|
|
175
|
+
// visible again - instead of manually re-measuring on window scroll/resize alone.
|
|
132
176
|
useLayoutEffect(() => {
|
|
133
|
-
|
|
177
|
+
const trigger_0 = triggerMarkerRef.current?.parentElement;
|
|
178
|
+
const floatingElement_0 = floatingRef.current;
|
|
179
|
+
if (!isMounted || !trigger_0 || !floatingElement_0) {
|
|
134
180
|
return;
|
|
135
181
|
}
|
|
136
|
-
|
|
137
|
-
|
|
182
|
+
const cleanupAutoUpdate = autoUpdate(trigger_0, floatingElement_0, updatePosition, {
|
|
183
|
+
elementResize: 'ResizeObserver' in window
|
|
184
|
+
});
|
|
185
|
+
// autoUpdate's own layout-shift tracking gives up once the trigger's rect
|
|
186
|
+
// collapses to zero (e.g. behind a `display: none` ancestor), so it can't
|
|
187
|
+
// tell when the trigger becomes visible again. Watch for that separately.
|
|
188
|
+
const visibilityObserver = typeof IntersectionObserver === 'function' ? new IntersectionObserver(() => void updatePosition(), {
|
|
189
|
+
threshold: 0
|
|
190
|
+
}) : null;
|
|
191
|
+
visibilityObserver?.observe(trigger_0);
|
|
192
|
+
const visualViewport = window.visualViewport;
|
|
193
|
+
visualViewport?.addEventListener('resize', updatePosition);
|
|
194
|
+
visualViewport?.addEventListener('scroll', updatePosition);
|
|
195
|
+
return () => {
|
|
196
|
+
cleanupAutoUpdate();
|
|
197
|
+
visibilityObserver?.disconnect();
|
|
198
|
+
visualViewport?.removeEventListener('resize', updatePosition);
|
|
199
|
+
visualViewport?.removeEventListener('scroll', updatePosition);
|
|
200
|
+
};
|
|
201
|
+
}, [isMounted, updatePosition]);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
const trigger_1 = triggerMarkerRef.current?.parentElement;
|
|
204
|
+
if (!show || !trigger_1) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const describedByIDs = trigger_1.getAttribute('aria-describedby')?.split(' ') || [];
|
|
208
|
+
if (!describedByIDs.includes(tooltipID)) {
|
|
209
|
+
trigger_1.setAttribute('aria-describedby', [...describedByIDs, tooltipID].join(' '));
|
|
210
|
+
}
|
|
138
211
|
return () => {
|
|
139
|
-
|
|
212
|
+
const remainingIDs = (trigger_1.getAttribute('aria-describedby')?.split(' ') || []).filter(describedByID => describedByID !== tooltipID);
|
|
213
|
+
if (remainingIDs.length) {
|
|
214
|
+
trigger_1.setAttribute('aria-describedby', remainingIDs.join(' '));
|
|
215
|
+
} else {
|
|
216
|
+
trigger_1.removeAttribute('aria-describedby');
|
|
217
|
+
}
|
|
140
218
|
};
|
|
141
|
-
}, [show,
|
|
142
|
-
// The first aside is always on top. The purpose of that is that it can reliably be used for the interaction observer (as it's not moving around), to calculate the position of the actual tooltip.
|
|
219
|
+
}, [show, tooltipID]);
|
|
143
220
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
144
|
-
children: [
|
|
221
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
145
222
|
"aria-hidden": "true",
|
|
146
|
-
|
|
147
|
-
ref: ref,
|
|
223
|
+
ref: triggerMarkerRef,
|
|
148
224
|
style: {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
className: ['tooltip', className, show && 'tooltip--show', maxWidth && 'tooltip--wrap', `tooltip--caret-${alignCaret}`, `tooltip--position-${positionFromProps || position}`].filter(Boolean).join(' '),
|
|
157
|
-
style: {
|
|
158
|
-
...(maxWidth ? {
|
|
159
|
-
'--tooltip-max-width': `${maxWidth}px`
|
|
160
|
-
} : {}),
|
|
161
|
-
...(shiftX ? {
|
|
162
|
-
'--tooltip-caret-x': `${-shiftX}px`,
|
|
163
|
-
'--tooltip-x': `calc(-50% + ${shiftX}px)`
|
|
164
|
-
} : {})
|
|
165
|
-
},
|
|
225
|
+
display: 'none'
|
|
226
|
+
}
|
|
227
|
+
}), isMounted && /*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("aside", {
|
|
228
|
+
className: ['tooltip', className, show && 'tooltip--show', `tooltip--caret-${alignCaret}`, `tooltip--position-${placement}`].filter(Boolean).join(' '),
|
|
229
|
+
id: tooltipID,
|
|
230
|
+
ref: setFloatingElement,
|
|
231
|
+
role: "tooltip",
|
|
166
232
|
children: [/*#__PURE__*/_jsx(TooltipCaret, {}), /*#__PURE__*/_jsx("div", {
|
|
167
233
|
className: "tooltip-content",
|
|
168
234
|
children: children
|
|
169
235
|
})]
|
|
170
|
-
})]
|
|
236
|
+
}), document.body)]
|
|
171
237
|
});
|
|
172
238
|
};
|
|
173
239
|
//# sourceMappingURL=index.js.map
|