datocms-react-ui 3.1.0-next.6 → 3.1.0-next.9
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 +3 -2
- package/dist/DateInput.d.ts +2 -0
- package/dist/DateInput.js +2 -0
- package/dist/DateTimeInput.d.ts +2 -0
- package/dist/DateTimeInput.js +2 -0
- package/dist/DateTimeRangeInput.d.ts +2 -0
- package/dist/DateTimeRangeInput.js +2 -0
- package/dist/FieldTypeAvatar.d.ts +2 -0
- package/dist/FieldTypeAvatar.js +2 -0
- package/dist/FieldTypeName.d.ts +2 -0
- package/dist/FieldTypeName.js +2 -0
- package/dist/FilterBuilder.d.ts +2 -0
- package/dist/FilterBuilder.js +2 -0
- package/dist/RecordRow.d.ts +2 -0
- package/dist/RecordRow.js +2 -0
- package/dist/UploadCard.js +2 -2
- package/dist/UploadPreview.d.ts +2 -2
- package/dist/UploadPreview.js +1 -1
- package/dist/UserRow.d.ts +2 -0
- package/dist/UserRow.js +2 -0
- package/dist/react-ui/src/Canvas.d.ts +7 -1
- package/dist/react-ui/src/Canvas.js +26 -4
- package/dist/react-ui/src/ctxAnswer.js +21 -0
- package/dist/react-ui/src/ctxDateSettings.js +7 -5
- package/dist/react-ui/src/ctxRecordPresentation.js +34 -0
- package/dist/react-ui/src/ctxUploads.js +23 -0
- package/dist/styles.css +634 -45
- package/dist/ui-public/icons/index.js +285 -280
- package/dist/ui-public/icons/lucide/braces.js +22 -0
- package/dist/ui-public/icons/lucide/hash.js +47 -0
- package/dist/ui-public/icons/lucide/letter-text.js +28 -0
- package/dist/ui-public/icons/lucide/rows-3.js +32 -0
- package/dist/ui-public/icons/lucide/toggle-right.js +32 -0
- package/dist/ui-public/locales/en.js +74 -5
- package/dist/ui-public/src/Message.d.ts +3 -4
- package/dist/ui-public/src/UiTextKey.d.ts +1 -1
- package/dist/ui-public/src/actions/Actions/ActionTooltip.js +1 -1
- package/dist/ui-public/src/actions/Actions/registry.d.ts +2 -2
- package/dist/ui-public/src/actions/Actions/registry.js +2 -2
- package/dist/ui-public/src/actions/Button.d.ts +10 -10
- package/dist/ui-public/src/actions/Button.js +1 -1
- package/dist/ui-public/src/actions/Dropdown/Menu.d.ts +2 -2
- package/dist/ui-public/src/actions/Dropdown/Option.d.ts +7 -7
- package/dist/ui-public/src/actions/Dropdown/index.d.ts +1 -1
- package/dist/ui-public/src/actions/Dropdown/triggers/ButtonTrigger.d.ts +5 -5
- package/dist/ui-public/src/actions/Dropdown/triggers/DropdownTriggerButton.d.ts +2 -2
- package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.d.ts +6 -6
- package/dist/ui-public/src/actions/Dropdown/triggers/IconTrigger.js +1 -1
- package/dist/ui-public/src/actions/EditorToolbar/Button.d.ts +1 -1
- package/dist/ui-public/src/actions/MultipleSelectionActionBar.d.ts +1 -1
- package/dist/ui-public/src/actions/SplitButton/Caret.js +2 -2
- package/dist/ui-public/src/actions/SplitButton/Halves.js +1 -1
- package/dist/ui-public/src/actions/SplitButton/index.d.ts +3 -3
- package/dist/ui-public/src/actions/disabledReason.d.ts +4 -4
- package/dist/ui-public/src/content/Avatar.d.ts +3 -3
- package/dist/ui-public/src/content/Avatar.js +2 -2
- package/dist/ui-public/src/content/CodeSnippet.d.ts +1 -1
- package/dist/ui-public/src/content/CopyableValue.d.ts +1 -1
- package/dist/ui-public/src/content/EnvironmentPill.d.ts +1 -1
- package/dist/ui-public/src/content/EnvironmentPill.js +1 -1
- package/dist/ui-public/src/content/FieldTypeAvatar.d.ts +22 -0
- package/dist/ui-public/src/content/FieldTypeAvatar.js +35 -0
- package/dist/ui-public/src/content/FieldTypeName.d.ts +19 -0
- package/dist/ui-public/src/content/FieldTypeName.js +25 -0
- package/dist/ui-public/src/content/IconAvatar.d.ts +3 -2
- package/dist/ui-public/src/content/ItemStatus.d.ts +1 -1
- package/dist/ui-public/src/content/Pill.d.ts +1 -1
- package/dist/ui-public/src/content/SmartDate.d.ts +1 -1
- package/dist/ui-public/src/content/UploadPreview/asset.js +200 -0
- package/dist/ui-public/src/content/UploadPreview/audio.js +120 -0
- package/dist/ui-public/src/content/{UploadPreview.d.ts → UploadPreview/box.d.ts} +10 -10
- package/dist/ui-public/src/content/{UploadPreview.js → UploadPreview/box.js} +7 -7
- package/dist/ui-public/src/content/{uploadPreviewFit.d.ts → UploadPreview/fit.d.ts} +2 -2
- package/dist/ui-public/src/content/{uploadPreviewFit.js → UploadPreview/fit.js} +3 -3
- package/dist/ui-public/src/content/UploadPreview/index.d.ts +61 -0
- package/dist/ui-public/src/content/UploadPreview/index.js +36 -0
- package/dist/ui-public/src/content/UploadPreview/presentation.js +63 -0
- package/dist/ui-public/src/content/UploadPreview/thumbhash.js +91 -0
- package/dist/ui-public/src/content/UploadPreview/upload.d.ts +104 -0
- package/dist/ui-public/src/content/UploadPreview/upload.js +112 -0
- package/dist/ui-public/src/content/UsageMeter.d.ts +1 -1
- package/dist/ui-public/src/content/ValidityTriangles.d.ts +1 -1
- package/dist/ui-public/src/feedback/BlankSlate.d.ts +5 -5
- package/dist/ui-public/src/feedback/Callout.d.ts +5 -5
- package/dist/ui-public/src/feedback/Callout.js +1 -1
- package/dist/ui-public/src/feedback/ProgressBar.d.ts +4 -4
- package/dist/ui-public/src/feedback/Spinner.d.ts +6 -6
- package/dist/ui-public/src/feedback/Spinner.js +1 -1
- package/dist/ui-public/src/form/DateInput.d.ts +13 -0
- package/dist/ui-public/src/form/DateInput.js +16 -0
- package/dist/ui-public/src/form/DateTimeInput/Base.d.ts +89 -0
- package/dist/ui-public/src/form/DateTimeInput/Base.js +330 -0
- package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.d.ts +29 -0
- package/dist/ui-public/src/form/DateTimeInput/CalendarGrid.js +195 -0
- package/dist/ui-public/src/form/DateTimeInput/dateText.js +38 -0
- package/dist/ui-public/src/form/DateTimeInput/index.d.ts +10 -0
- package/dist/ui-public/src/form/DateTimeInput/index.js +18 -0
- package/dist/ui-public/src/form/DateTimeInput/value.js +31 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/Panel.js +167 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/index.d.ts +123 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/index.js +186 -0
- package/dist/ui-public/src/form/DateTimeRangeInput/rangeLabel.js +46 -0
- package/dist/ui-public/src/form/FieldHint.d.ts +2 -2
- package/dist/ui-public/src/form/FieldWrapper.d.ts +9 -9
- package/dist/ui-public/src/form/FieldWrapper.js +3 -3
- package/dist/ui-public/src/form/FilterBuilder/Editor.js +123 -0
- package/dist/ui-public/src/form/FilterBuilder/index.d.ts +9 -0
- package/dist/ui-public/src/form/FilterBuilder/index.js +294 -0
- package/dist/ui-public/src/form/FilterBuilder/types.d.ts +188 -0
- package/dist/ui-public/src/form/FilterBuilder/values.js +86 -0
- package/dist/ui-public/src/form/InputGroup.d.ts +2 -2
- package/dist/ui-public/src/form/InputGroup.js +1 -1
- package/dist/ui-public/src/form/KeyValueList.d.ts +1 -1
- package/dist/ui-public/src/form/Label.d.ts +2 -2
- package/dist/ui-public/src/form/RadioGroupInput.d.ts +2 -2
- package/dist/ui-public/src/form/RadioGroupInput.js +1 -1
- package/dist/ui-public/src/form/SelectInput/SelectMenu.d.ts +2 -2
- package/dist/ui-public/src/form/SelectInput/index.d.ts +3 -3
- package/dist/ui-public/src/form/SwitchInput.d.ts +2 -2
- package/dist/ui-public/src/form/SwitchList.d.ts +1 -1
- package/dist/ui-public/src/form/SwitchList.js +1 -1
- package/dist/ui-public/src/form/TableList.d.ts +2 -2
- package/dist/ui-public/src/form/TextareaInput.js +1 -1
- package/dist/ui-public/src/form/inputProps.d.ts +6 -6
- package/dist/ui-public/src/hooks/useAsyncSelectOptions.d.ts +1 -1
- package/dist/ui-public/src/hooks/useSmartRowClick.d.ts +1 -1
- package/dist/ui-public/src/hooks/useSmartRowClick.js +1 -1
- package/dist/ui-public/src/layout/Page/PageGroup.d.ts +2 -2
- package/dist/ui-public/src/layout/Page/PageGroup.js +1 -1
- package/dist/ui-public/src/layout/Pane/FormHeader.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/FormHeader.js +1 -1
- package/dist/ui-public/src/layout/Pane/ListFilter.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/ListPresets.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/PaneHeader.d.ts +1 -1
- package/dist/ui-public/src/layout/Pane/index.d.ts +8 -8
- package/dist/ui-public/src/layout/Pane/index.js +17 -8
- package/dist/ui-public/src/layout/SidebarPanel.d.ts +1 -1
- package/dist/ui-public/src/layout/SplitPane/Rail.js +1 -1
- package/dist/ui-public/src/layout/SplitPane/index.d.ts +6 -6
- package/dist/ui-public/src/layout/SplitPane/index.js +16 -2
- package/dist/ui-public/src/layout/Toolbar/AddNewButton.d.ts +2 -2
- package/dist/ui-public/src/layout/Toolbar/Help.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/Help.js +2 -2
- package/dist/ui-public/src/layout/Toolbar/Note.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Note.js +1 -1
- package/dist/ui-public/src/layout/Toolbar/Pagination.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Pagination.js +1 -1
- package/dist/ui-public/src/layout/Toolbar/PresetsTitle.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/PresetsTitle.js +2 -2
- package/dist/ui-public/src/layout/Toolbar/PrimaryButton.d.ts +3 -3
- package/dist/ui-public/src/layout/Toolbar/Root.d.ts +1 -1
- package/dist/ui-public/src/layout/Toolbar/Root.js +4 -1
- package/dist/ui-public/src/layout/Toolbar/ToolbarTitleTrigger.js +1 -1
- package/dist/ui-public/src/lists/CardList.d.ts +3 -3
- package/dist/ui-public/src/lists/EmptySlot.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/User.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/Value.d.ts +1 -1
- package/dist/ui-public/src/lists/InfoList/Value.js +1 -1
- package/dist/ui-public/src/lists/InfoList/index.d.ts +3 -3
- package/dist/ui-public/src/lists/InfoList/index.js +1 -1
- package/dist/ui-public/src/lists/MediaCard.d.ts +7 -7
- package/dist/ui-public/src/lists/RecordRow/Image.d.ts +24 -0
- package/dist/ui-public/src/lists/RecordRow/Image.js +22 -0
- package/dist/ui-public/src/lists/RecordRow/List.d.ts +26 -0
- package/dist/ui-public/src/lists/RecordRow/List.js +30 -0
- package/dist/ui-public/src/lists/RecordRow/context.js +31 -0
- package/dist/ui-public/src/lists/RecordRow/index.d.ts +94 -0
- package/dist/ui-public/src/lists/RecordRow/index.js +122 -0
- package/dist/ui-public/src/lists/RecordRow/presentation.js +73 -0
- package/dist/ui-public/src/lists/RecordRow/types.d.ts +58 -0
- package/dist/ui-public/src/lists/RowList.d.ts +5 -5
- package/dist/ui-public/src/lists/SettingsList.d.ts +3 -3
- package/dist/ui-public/src/lists/SettingsList.js +2 -2
- package/dist/ui-public/src/lists/Table/Row.d.ts +5 -5
- package/dist/ui-public/src/lists/Table/Table.d.ts +3 -3
- package/dist/ui-public/src/lists/Table/TreeToggle.d.ts +2 -2
- package/dist/ui-public/src/lists/Table/TreeToggle.js +5 -4
- package/dist/ui-public/src/lists/Table/cells/LinkCell.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Action.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Action.js +1 -1
- package/dist/ui-public/src/lists/TreeRow/Link.d.ts +1 -1
- package/dist/ui-public/src/lists/TreeRow/Link.js +1 -1
- package/dist/ui-public/src/lists/UploadCard.d.ts +66 -3
- package/dist/ui-public/src/lists/UploadCard.js +116 -7
- package/dist/ui-public/src/lists/UserRow.d.ts +122 -0
- package/dist/ui-public/src/lists/UserRow.js +104 -0
- package/dist/ui-public/src/lists/dnd/DragHandle.d.ts +2 -2
- package/dist/ui-public/src/lists/dnd/SortableList.d.ts +1 -1
- package/dist/ui-public/src/lists/dnd/dropTargetClassName.d.ts +1 -1
- package/dist/ui-public/src/lists/dnd/tree/SortableTree.d.ts +2 -2
- package/dist/ui-public/src/navigation/Chevron.d.ts +4 -4
- package/dist/ui-public/src/navigation/Chevron.js +1 -1
- package/dist/ui-public/src/navigation/Link.d.ts +5 -5
- package/dist/ui-public/src/navigation/Link.js +1 -1
- package/dist/ui-public/src/navigation/NavList.d.ts +1 -1
- package/dist/ui-public/src/navigation/NavList.js +1 -1
- package/dist/ui-public/src/navigation/NavigationProvider.d.ts +1 -1
- package/dist/ui-public/src/navigation/SegmentedControl.d.ts +2 -2
- package/dist/ui-public/src/navigation/SettingsMenu.d.ts +8 -8
- package/dist/ui-public/src/navigation/SettingsMenu.js +1 -1
- package/dist/ui-public/src/navigation/SidebarTree/SidebarTreeNode.d.ts +4 -4
- package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.d.ts +1 -1
- package/dist/ui-public/src/overlays/FullscreenModal/TitleContext.js +1 -1
- package/dist/ui-public/src/overlays/NewZIndex.d.ts +1 -1
- package/dist/ui-public/src/overlays/NewZIndex.js +1 -1
- package/dist/ui-public/src/overlays/Popover.d.ts +1 -1
- package/dist/ui-public/src/overlays/PortalWrapper.js +1 -1
- package/dist/ui-public/src/overlays/useModalClose.js +3 -3
- package/dist/ui-public/src/patterns/ListDetail/FloatingDetail.js +2 -2
- package/dist/ui-public/src/patterns/ListDetail/Page.d.ts +8 -9
- package/dist/ui-public/src/patterns/ListDetail/Page.js +4 -5
- package/dist/ui-public/src/patterns/ListDetail/Panel.d.ts +2 -2
- package/dist/ui-public/src/patterns/ListDetail/Panel.js +1 -1
- package/dist/ui-public/src/patterns/ListDetail/Split.d.ts +9 -10
- package/dist/ui-public/src/patterns/ListDetail/Split.js +5 -5
- package/dist/ui-public/src/patterns/ListFormPage.d.ts +3 -3
- package/dist/ui-public/src/patterns/ListFormPage.js +1 -1
- package/dist/ui-public/src/semantic/Heading.d.ts +1 -1
- package/dist/ui-public/src/semantic/Heading.js +1 -1
- package/dist/ui-public/src/semantic/Image.js +1 -1
- package/dist/ui-public/src/semantic/Nav.d.ts +3 -3
- package/dist/ui-public/src/semantic/Nav.js +3 -3
- package/dist/ui-public/src/semantic/RawButton.d.ts +3 -3
- package/dist/ui-public/src/semantic/RawButton.js +1 -1
- package/dist/ui-public/src/semantic/Search.d.ts +1 -1
- package/dist/ui-public/src/semantic/Search.js +1 -1
- package/dist/ui-public/src/utils/fieldTypes.d.ts +29 -0
- package/dist/ui-public/src/utils/fieldTypes.js +94 -0
- package/dist/ui-public/src/utils/format.d.ts +21 -0
- package/dist/ui-public/src/utils/format.js +20 -0
- package/dist/ui-public/src/utils/formatDate.d.ts +10 -2
- package/dist/ui-public/src/utils/formatDate.js +4 -4
- package/dist/ui-public/src/utils/tickBatcher.js +44 -0
- package/dist/ui-public/src/utils/timezones.js +277 -0
- package/dist/ui-public/src/utils/weekStartForLocale.js +25 -0
- package/dist/utils/fieldTypes.d.ts +1 -0
- package/dist/utils/fieldTypes.js +2 -0
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.js +2 -0
- package/package.json +2 -2
- package/dist/ui-public/icons/custom/fieldgroup-boolean.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-color.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-datetime.js +0 -49
- package/dist/ui-public/icons/custom/fieldgroup-json.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-location.js +0 -19
- package/dist/ui-public/icons/custom/fieldgroup-media.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-number.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-reference.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-rich_text.js +0 -18
- package/dist/ui-public/icons/custom/fieldgroup-seo.js +0 -22
- package/dist/ui-public/icons/custom/fieldgroup-structured_text.js +0 -61
- package/dist/ui-public/icons/lucide/receipt.js +0 -26
|
@@ -10,7 +10,7 @@ export type RowListProps = {
|
|
|
10
10
|
* @default "default"
|
|
11
11
|
*/
|
|
12
12
|
density?: 'default' | 'compact';
|
|
13
|
-
/** Only for the
|
|
13
|
+
/** Only for the position of the list in its container (a margin), not for its look */
|
|
14
14
|
className?: string;
|
|
15
15
|
/** The rows (RowList.Item) */
|
|
16
16
|
children: ReactNode;
|
|
@@ -21,9 +21,9 @@ export type RowListProps = {
|
|
|
21
21
|
* of a section, use NavList: it adds the navigation landmark.
|
|
22
22
|
*/
|
|
23
23
|
declare function BaseRowList({ density, className, children, }: RowListProps): React.JSX.Element;
|
|
24
|
-
/** The row opens a page of
|
|
24
|
+
/** The row opens a page of DatoCMS. It is selected while the page is open. */
|
|
25
25
|
type LinkRow = {
|
|
26
|
-
/** The page of
|
|
26
|
+
/** The page of DatoCMS: the path with its query */
|
|
27
27
|
to: string;
|
|
28
28
|
/** Runs on a click, before the page opens */
|
|
29
29
|
onClick?: () => void;
|
|
@@ -53,13 +53,13 @@ export type RowListItemProps = RowListItemAction & {
|
|
|
53
53
|
/**
|
|
54
54
|
* The text of the row is subtle and its images fade, but the user can
|
|
55
55
|
* still open it. Use it for an element that is off (for example a
|
|
56
|
-
* disabled plugin), with a Pill that
|
|
56
|
+
* disabled plugin), with a Pill that says it.
|
|
57
57
|
* @default false
|
|
58
58
|
*/
|
|
59
59
|
muted?: boolean;
|
|
60
60
|
/**
|
|
61
61
|
* The user can drag the row to a new position. Give the argument of the
|
|
62
|
-
* children of SortableItem
|
|
62
|
+
* children of SortableItem , with `handle` on the SortableItem:
|
|
63
63
|
* the row shows a grip at its left.
|
|
64
64
|
*/
|
|
65
65
|
sortable?: SortableItemApi;
|
|
@@ -14,7 +14,7 @@ export type SettingsListRowProps = {
|
|
|
14
14
|
/**
|
|
15
15
|
* The current value. A long value gets an ellipsis (in a narrow list, it
|
|
16
16
|
* goes on more lines), and a value on more lines (an address) has each
|
|
17
|
-
* line
|
|
17
|
+
* line on the right. An action without a value (for example "Log out
|
|
18
18
|
* everywhere") has no value.
|
|
19
19
|
*/
|
|
20
20
|
value?: ReactNode;
|
|
@@ -25,11 +25,11 @@ export type SettingsListRowProps = {
|
|
|
25
25
|
*/
|
|
26
26
|
action?: ReactNode;
|
|
27
27
|
};
|
|
28
|
-
/** A setting or an action: the text
|
|
28
|
+
/** A setting or an action: the text on the left, the value and the control on the right */
|
|
29
29
|
declare function Row({ title, description, value, action }: SettingsListRowProps): React.JSX.Element;
|
|
30
30
|
/**
|
|
31
31
|
* The settings of a wide page: one row for each value that the user changes
|
|
32
|
-
* or for each action, with the control always visible
|
|
32
|
+
* or for each action, with the control always visible on the right. Put it
|
|
33
33
|
* in a Page.Group. For facts to read, use InfoList. For a list of items,
|
|
34
34
|
* use CardList.
|
|
35
35
|
*/
|
|
@@ -9,7 +9,7 @@ function BaseSettingsList({ className, children }) {
|
|
|
9
9
|
children
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
/** A setting or an action: the text
|
|
12
|
+
/** A setting or an action: the text on the left, the value and the control on the right */
|
|
13
13
|
function Row({ title, description, value, action }) {
|
|
14
14
|
const { tc } = useTranslation();
|
|
15
15
|
return /* @__PURE__ */ jsxs("li", {
|
|
@@ -38,7 +38,7 @@ function Row({ title, description, value, action }) {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* The settings of a wide page: one row for each value that the user changes
|
|
41
|
-
* or for each action, with the control always visible
|
|
41
|
+
* or for each action, with the control always visible on the right. Put it
|
|
42
42
|
* in a Page.Group. For facts to read, use InfoList. For a list of items,
|
|
43
43
|
* use CardList.
|
|
44
44
|
*/
|
|
@@ -45,7 +45,7 @@ export type RowAction = {
|
|
|
45
45
|
openWithArrows?: never;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
* The drag handle
|
|
48
|
+
* The drag handle on the left of the row: the handle that the library listens
|
|
49
49
|
* to, or a disabled handle with the reason in a tooltip
|
|
50
50
|
*/
|
|
51
51
|
export type RowDragHandle =
|
|
@@ -61,7 +61,7 @@ export type RowDragHandle =
|
|
|
61
61
|
};
|
|
62
62
|
export type RowDrag = {
|
|
63
63
|
/**
|
|
64
|
-
* The element that the library moves. It has a position,
|
|
64
|
+
* The element that the library moves. It has a position, so the drop
|
|
65
65
|
* indicator can be in it.
|
|
66
66
|
*/
|
|
67
67
|
wrapperRef?: Ref<HTMLDivElement>;
|
|
@@ -91,7 +91,7 @@ type RowBaseProps<R> = {
|
|
|
91
91
|
/**
|
|
92
92
|
* The text of the row is subtle and its images fade, but the user can
|
|
93
93
|
* still open it. Use it for an element that is off (for example a
|
|
94
|
-
* deactivated user), with a Pill that
|
|
94
|
+
* deactivated user), with a Pill that says it.
|
|
95
95
|
* @default false
|
|
96
96
|
*/
|
|
97
97
|
muted?: boolean;
|
|
@@ -99,7 +99,7 @@ type RowBaseProps<R> = {
|
|
|
99
99
|
/** The element of the row, without the handle */
|
|
100
100
|
rowRef?: Ref<HTMLDivElement>;
|
|
101
101
|
/**
|
|
102
|
-
* The actions of the row (see `
|
|
102
|
+
* The actions of the row (see `Actions`): their keys work while the
|
|
103
103
|
* pointer or the focus is in the row, and a menu in the row runs them.
|
|
104
104
|
*/
|
|
105
105
|
actions?: readonly Action[];
|
|
@@ -117,7 +117,7 @@ type RowBaseProps<R> = {
|
|
|
117
117
|
* device with no hover. A click in them never opens the row.
|
|
118
118
|
*/
|
|
119
119
|
trailing?: ReactNode;
|
|
120
|
-
/** Cells
|
|
120
|
+
/** Cells instead of the cells of the columns. Use <Table.Cell>. */
|
|
121
121
|
children?: ReactNode;
|
|
122
122
|
};
|
|
123
123
|
export type RowProps<R = any> = RowBaseProps<R> & RowAction;
|
|
@@ -18,7 +18,7 @@ export type TableProps<R = any> = {
|
|
|
18
18
|
layout: TableLayout;
|
|
19
19
|
onLayoutChange: (layout: TableLayout) => void;
|
|
20
20
|
/**
|
|
21
|
-
* The order of the rows: `useClientSort` or a hook of
|
|
21
|
+
* The order of the rows: `useClientSort` or a hook of yours gives it.
|
|
22
22
|
* Without it, the user cannot sort from the header.
|
|
23
23
|
*/
|
|
24
24
|
sort?: TableSortState;
|
|
@@ -30,13 +30,13 @@ export type TableProps<R = any> = {
|
|
|
30
30
|
/**
|
|
31
31
|
* The width in pixels of a column at the end of each row, outside the columns
|
|
32
32
|
* of the layout and with no label: the controls of the row (see `trailing` of
|
|
33
|
-
* <Table.Row>). The header keeps the same space empty,
|
|
33
|
+
* <Table.Row>). The header keeps the same space empty, so the button of the
|
|
34
34
|
* columns menu sits over it.
|
|
35
35
|
*/
|
|
36
36
|
trailingWidth?: number;
|
|
37
37
|
/**
|
|
38
38
|
* The rows have a drag handle at their left. Set it with the `reorder` of
|
|
39
|
-
* <Table.Body>, or for rows that a library of
|
|
39
|
+
* <Table.Body>, or for rows that a library of yours moves (a tree).
|
|
40
40
|
*/
|
|
41
41
|
reorderable?: boolean;
|
|
42
42
|
/**
|
|
@@ -7,7 +7,7 @@ export type TableRowExpandable = {
|
|
|
7
7
|
/** Runs when the user clicks the toggle */
|
|
8
8
|
onToggle: () => void;
|
|
9
9
|
/**
|
|
10
|
-
* The child rows load: a spinner
|
|
10
|
+
* The child rows load: a spinner replaces the chevron, and the
|
|
11
11
|
* toggle does nothing
|
|
12
12
|
*/
|
|
13
13
|
busy?: boolean;
|
|
@@ -19,7 +19,7 @@ export type TableRowExpandable = {
|
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* The toggle column of a tree row. A row without child rows keeps the space
|
|
22
|
-
* of the toggle,
|
|
22
|
+
* of the toggle, so the contents of the rows align.
|
|
23
23
|
*/
|
|
24
24
|
export declare function TreeToggle({ expandable, nested, labelledBy, }: {
|
|
25
25
|
expandable: TableRowExpandable | undefined;
|
|
@@ -6,12 +6,13 @@ import { DisclosureChevron, DisclosureChevronPlaceholder } from "../../navigatio
|
|
|
6
6
|
import "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
//#region ../ui-public/src/lists/Table/TreeToggle.tsx
|
|
9
|
-
function
|
|
9
|
+
function stopRowClick(event) {
|
|
10
10
|
event.stopPropagation();
|
|
11
|
+
event.preventDefault();
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* The toggle column of a tree row. A row without child rows keeps the space
|
|
14
|
-
* of the toggle,
|
|
15
|
+
* of the toggle, so the contents of the rows align.
|
|
15
16
|
*/
|
|
16
17
|
function TreeToggle({ expandable, nested, labelledBy }) {
|
|
17
18
|
if (!expandable) return /* @__PURE__ */ jsx(TreeToggleSlot, { children: nested ? /* @__PURE__ */ jsx(Generic.DashIcon, { className: "Table__toggle__dash" }) : /* @__PURE__ */ jsx(DisclosureChevronPlaceholder, {}) });
|
|
@@ -25,9 +26,9 @@ function TreeToggle({ expandable, nested, labelledBy }) {
|
|
|
25
26
|
expandable: { open },
|
|
26
27
|
disabled: hasReason ? "focusable" : Boolean(disabled),
|
|
27
28
|
"aria-busy": busy || void 0,
|
|
28
|
-
onClickCapture: disabled ?
|
|
29
|
+
onClickCapture: disabled ? stopRowClick : void 0,
|
|
29
30
|
onClick: (event) => {
|
|
30
|
-
|
|
31
|
+
stopRowClick(event);
|
|
31
32
|
if (!busy) onToggle();
|
|
32
33
|
},
|
|
33
34
|
children: busy ? /* @__PURE__ */ jsx(Spinner_default, {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
export type LinkCellProps = {
|
|
3
3
|
/** The path of the link */
|
|
4
4
|
to: string;
|
|
5
|
-
/** The text of the link: a string,
|
|
5
|
+
/** The text of the link: a string, so the title can show it */
|
|
6
6
|
children: string;
|
|
7
7
|
};
|
|
8
8
|
/** A link in a cell. The title shows the full text when the column cuts it. */
|
|
@@ -13,7 +13,7 @@ export type TreeRowActionProps = {
|
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* The content of a `TreeRow` as a button, for example "Load more". The
|
|
16
|
-
* button starts in the column of the handle,
|
|
16
|
+
* button starts in the column of the handle, so a click there also runs
|
|
17
17
|
* it. Give it to a row with no `expandable` and no `drag.handle`. In a
|
|
18
18
|
* SortableTree, the button is a tree item: the arrow keys move the focus to
|
|
19
19
|
* it, and Enter or Space runs it.
|
|
@@ -6,7 +6,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
//#region ../ui-public/src/lists/TreeRow/Action.tsx
|
|
7
7
|
/**
|
|
8
8
|
* The content of a `TreeRow` as a button, for example "Load more". The
|
|
9
|
-
* button starts in the column of the handle,
|
|
9
|
+
* button starts in the column of the handle, so a click there also runs
|
|
10
10
|
* it. Give it to a row with no `expandable` and no `drag.handle`. In a
|
|
11
11
|
* SortableTree, the button is a tree item: the arrow keys move the focus to
|
|
12
12
|
* it, and Enter or Space runs it.
|
|
@@ -6,7 +6,7 @@ export type TreeRowLinkProps = Omit<LinkProps, 'className' | 'children'> & {
|
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* The content of a `TreeRow` as a link, for example the link that opens a
|
|
9
|
-
* record. Give it the `provided.treeItemProps` of SortableTree,
|
|
9
|
+
* record. Give it the `provided.treeItemProps` of SortableTree, so the
|
|
10
10
|
* arrow keys move the focus between the rows.
|
|
11
11
|
*/
|
|
12
12
|
export default function TreeRowLink({ children, ...props }: TreeRowLinkProps): React.JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
4
4
|
//#region ../ui-public/src/lists/TreeRow/Link.tsx
|
|
5
5
|
/**
|
|
6
6
|
* The content of a `TreeRow` as a link, for example the link that opens a
|
|
7
|
-
* record. Give it the `provided.treeItemProps` of SortableTree,
|
|
7
|
+
* record. Give it the `provided.treeItemProps` of SortableTree, so the
|
|
8
8
|
* arrow keys move the focus between the rows.
|
|
9
9
|
*/
|
|
10
10
|
function TreeRowLink({ children, ...props }) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import type { BoxSize, UploadPreviewPadding } from '../content/UploadPreview/fit.js';
|
|
3
|
+
import { type UploadFieldValue, type UploadPreviewUpload } from '../content/UploadPreview/upload.js';
|
|
2
4
|
import { type MediaCardCaption, type MediaCardProps } from './MediaCard.js';
|
|
3
5
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
4
6
|
/** The upload of the asset, while it is in progress */
|
|
@@ -15,7 +17,10 @@ export type UploadCardProgress = {
|
|
|
15
17
|
*/
|
|
16
18
|
onCancel?: (event: React.MouseEvent) => void;
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
type CardProps = DistributiveOmit<MediaCardProps, 'caption' | 'captionAction' | 'children'>;
|
|
21
|
+
/** Mode "preview": you give the preview and the caption of the asset. */
|
|
22
|
+
export type UploadCardPreviewModeProps = CardProps & {
|
|
23
|
+
upload?: never;
|
|
19
24
|
/** The preview of the asset, an `UploadPreview` */
|
|
20
25
|
children: ReactNode;
|
|
21
26
|
/**
|
|
@@ -25,12 +30,56 @@ export type UploadCardProps = DistributiveOmit<MediaCardProps, 'caption' | 'capt
|
|
|
25
30
|
caption?: MediaCardCaption;
|
|
26
31
|
/**
|
|
27
32
|
* The asset uploads. The caption shows in the subtle ink. Without a
|
|
28
|
-
* caption, the caption
|
|
33
|
+
* caption, the caption shows the percent or the analysis.
|
|
29
34
|
*/
|
|
30
35
|
progress?: UploadCardProgress;
|
|
31
36
|
/** The antivirus found a threat in the file: the card shows a badge. */
|
|
32
37
|
threatDetected?: boolean;
|
|
33
38
|
};
|
|
39
|
+
export type { UploadFieldValue } from '../content/UploadPreview/upload.js';
|
|
40
|
+
/**
|
|
41
|
+
* Mode "upload": the card shows an asset of the Media Area, as DatoCMS
|
|
42
|
+
* shows it, with its preview, its caption and the antivirus badge. A sound
|
|
43
|
+
* file gets a play action.
|
|
44
|
+
*/
|
|
45
|
+
export type UploadCardUploadModeProps = CardProps & {
|
|
46
|
+
/**
|
|
47
|
+
* The asset as `ctx` gives it, or its ID. An ID loads through the
|
|
48
|
+
* provider of the host: `Canvas` mounts it. `null` is an asset that does
|
|
49
|
+
* not exist: the preview shows a blank file icon.
|
|
50
|
+
*/
|
|
51
|
+
upload: string | UploadPreviewUpload | null;
|
|
52
|
+
/**
|
|
53
|
+
* The locale of the default metadata of the asset, for the caption, for
|
|
54
|
+
* example the locale of the field. When it has no value, the caption uses
|
|
55
|
+
* the main locale of the project, which the provider of the host gives.
|
|
56
|
+
*/
|
|
57
|
+
preferredLocale?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The value of the field that holds the asset. Its title and alternate
|
|
60
|
+
* text come before the default metadata of the asset, and its
|
|
61
|
+
* `poster_time` gives the frame of a video.
|
|
62
|
+
*/
|
|
63
|
+
fieldValue?: UploadFieldValue;
|
|
64
|
+
/**
|
|
65
|
+
* The text below the preview. Without it, the card computes it with
|
|
66
|
+
* `uploadCardCaption`. `null` shows no caption.
|
|
67
|
+
*/
|
|
68
|
+
caption?: MediaCardCaption | null;
|
|
69
|
+
/** The size of the preview, in px. Without it, the CSS gives the size. */
|
|
70
|
+
box?: BoxSize;
|
|
71
|
+
/** The space around the asset in the preview, as in `UploadPreview`. */
|
|
72
|
+
padding?: UploadPreviewPadding;
|
|
73
|
+
/** The preview is a link. */
|
|
74
|
+
link?: {
|
|
75
|
+
href: string;
|
|
76
|
+
target?: string;
|
|
77
|
+
};
|
|
78
|
+
children?: never;
|
|
79
|
+
progress?: never;
|
|
80
|
+
threatDetected?: never;
|
|
81
|
+
};
|
|
82
|
+
export type UploadCardProps = UploadCardPreviewModeProps | UploadCardUploadModeProps;
|
|
34
83
|
/** The metadata of an asset that give its caption */
|
|
35
84
|
export type UploadCaptionMetadata = {
|
|
36
85
|
/** The title of the asset in the record */
|
|
@@ -51,9 +100,23 @@ export type UploadCaptionMetadata = {
|
|
|
51
100
|
* or no `defaultTitle`.
|
|
52
101
|
*/
|
|
53
102
|
export declare function uploadCaption({ title, alt, defaultTitle, defaultAlt, filename, }: UploadCaptionMetadata): MediaCardCaption;
|
|
103
|
+
/**
|
|
104
|
+
* The caption of an asset in a card, as the gallery field of DatoCMS shows
|
|
105
|
+
* it: the metadata of the value of the field, then the default metadata of
|
|
106
|
+
* the asset in `preferredLocale`, then in `mainLocale`. A sound file falls
|
|
107
|
+
* back to its file name. `UploadCard` takes `mainLocale` from the provider
|
|
108
|
+
* of the host. Give it when you call this function outside a `Canvas`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function uploadCardCaption(upload: UploadPreviewUpload, { preferredLocale, mainLocale, fieldValue, }?: {
|
|
111
|
+
preferredLocale?: string;
|
|
112
|
+
/** The main locale of the project: the first of `ctx.site.attributes.locales` */
|
|
113
|
+
mainLocale?: string;
|
|
114
|
+
fieldValue?: UploadFieldValue;
|
|
115
|
+
}): MediaCardCaption;
|
|
54
116
|
/**
|
|
55
117
|
* The card of an asset: a `MediaCard` with the preview of the asset, its
|
|
56
|
-
* caption, the progress of its upload and the antivirus badge.
|
|
118
|
+
* caption, the progress of its upload and the antivirus badge. With
|
|
119
|
+
* `upload`, the card gets them from an asset of the Media Area.
|
|
57
120
|
*/
|
|
58
121
|
declare const UploadCard: React.ForwardRefExoticComponent<UploadCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
59
122
|
export default UploadCard;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Generic, Status } from "../../icons/index.js";
|
|
2
2
|
import { useTranslation } from "../i18n.js";
|
|
3
|
+
import { useLoadedUpload, useUploadMainLocale } from "../content/UploadPreview/presentation.js";
|
|
3
4
|
import Button from "../actions/Button.js";
|
|
4
5
|
import MediaCard from "./MediaCard.js";
|
|
5
|
-
import {
|
|
6
|
+
import { useAudioPlayback } from "../content/UploadPreview/audio.js";
|
|
7
|
+
import { uploadDefaultMetadata } from "../content/UploadPreview/upload.js";
|
|
8
|
+
import { UploadAssetPreview } from "../content/UploadPreview/asset.js";
|
|
9
|
+
import { forwardRef, useMemo } from "react";
|
|
6
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
11
|
//#region ../ui-public/src/lists/UploadCard.tsx
|
|
8
12
|
/**
|
|
@@ -20,11 +24,7 @@ function uploadCaption({ title, alt, defaultTitle, defaultAlt, filename }) {
|
|
|
20
24
|
function hasCheckbox(props) {
|
|
21
25
|
return !!props.selection?.checkbox;
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
* The card of an asset: a `MediaCard` with the preview of the asset, its
|
|
25
|
-
* caption, the progress of its upload and the antivirus badge.
|
|
26
|
-
*/
|
|
27
|
-
var UploadCard = forwardRef(function UploadCard({ children, caption, progress, threatDetected, ...mediaCardProps }, ref) {
|
|
27
|
+
var PreviewModeCard = forwardRef(function PreviewModeCard({ children, caption, progress, threatDetected, upload: _, ...mediaCardProps }, ref) {
|
|
28
28
|
const { tm } = useTranslation();
|
|
29
29
|
const progressText = progress ? progress.percent < 100 ? {
|
|
30
30
|
id: "imageMetadata.uploadInProgress",
|
|
@@ -62,5 +62,114 @@ var UploadCard = forwardRef(function UploadCard({ children, caption, progress, t
|
|
|
62
62
|
}), children]
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
+
/**
|
|
66
|
+
* The caption of an asset in a card, as the gallery field of DatoCMS shows
|
|
67
|
+
* it: the metadata of the value of the field, then the default metadata of
|
|
68
|
+
* the asset in `preferredLocale`, then in `mainLocale`. A sound file falls
|
|
69
|
+
* back to its file name. `UploadCard` takes `mainLocale` from the provider
|
|
70
|
+
* of the host. Give it when you call this function outside a `Canvas`.
|
|
71
|
+
*/
|
|
72
|
+
function uploadCardCaption(upload, { preferredLocale, mainLocale, fieldValue } = {}) {
|
|
73
|
+
const locales = [preferredLocale, mainLocale].filter((locale) => !!locale);
|
|
74
|
+
const defaults = uploadDefaultMetadata(upload, locales);
|
|
75
|
+
return uploadCaption({
|
|
76
|
+
title: fieldValue?.title,
|
|
77
|
+
alt: fieldValue?.alt,
|
|
78
|
+
defaultTitle: defaults.title,
|
|
79
|
+
defaultAlt: defaults.alt,
|
|
80
|
+
filename: upload.attributes.mime_type?.startsWith("audio/") ? upload.attributes.filename : null
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function useActionsWithPlay(url, { actions, options, compact }) {
|
|
84
|
+
const playback = useAudioPlayback(url);
|
|
85
|
+
const { isPlaying, toggle } = playback;
|
|
86
|
+
return useMemo(() => {
|
|
87
|
+
if (!url) return {
|
|
88
|
+
playback: void 0,
|
|
89
|
+
actions,
|
|
90
|
+
options
|
|
91
|
+
};
|
|
92
|
+
const play = {
|
|
93
|
+
id: "play",
|
|
94
|
+
icon: isPlaying ? Status.PauseIcon : Status.PlayIcon,
|
|
95
|
+
label: { id: isPlaying ? "audioPlayer.pause" : "audioPlayer.play" },
|
|
96
|
+
onClick: (e) => {
|
|
97
|
+
e?.stopPropagation();
|
|
98
|
+
toggle();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return compact ? {
|
|
102
|
+
playback,
|
|
103
|
+
actions,
|
|
104
|
+
options: [play, ...options ?? []]
|
|
105
|
+
} : {
|
|
106
|
+
playback,
|
|
107
|
+
actions: [play, ...actions ?? []],
|
|
108
|
+
options
|
|
109
|
+
};
|
|
110
|
+
}, [
|
|
111
|
+
url,
|
|
112
|
+
playback,
|
|
113
|
+
isPlaying,
|
|
114
|
+
toggle,
|
|
115
|
+
actions,
|
|
116
|
+
options,
|
|
117
|
+
compact
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
var UploadModeCard = forwardRef(function UploadModeCard({ upload: uploadOrId, preferredLocale, fieldValue, caption, box, padding, link, ...mediaCardProps }, ref) {
|
|
121
|
+
const upload = useLoadedUpload(uploadOrId);
|
|
122
|
+
const mainLocale = useUploadMainLocale();
|
|
123
|
+
const attributes = upload?.attributes;
|
|
124
|
+
const { playback, actions, options } = useActionsWithPlay(attributes?.mime_type?.startsWith("audio/") && attributes.url ? attributes.url : null, mediaCardProps);
|
|
125
|
+
const cardCaption = caption === null ? void 0 : caption ?? (upload ? uploadCardCaption(upload, {
|
|
126
|
+
preferredLocale,
|
|
127
|
+
mainLocale,
|
|
128
|
+
fieldValue
|
|
129
|
+
}) : upload === null && typeof uploadOrId === "string" ? {
|
|
130
|
+
text: {
|
|
131
|
+
id: "uploadCard.fallbackTitle",
|
|
132
|
+
values: { id: uploadOrId }
|
|
133
|
+
},
|
|
134
|
+
muted: true
|
|
135
|
+
} : upload === void 0 ? {
|
|
136
|
+
text: { id: "uploadCard.loading" },
|
|
137
|
+
muted: true
|
|
138
|
+
} : void 0);
|
|
139
|
+
const cardProps = {
|
|
140
|
+
...mediaCardProps,
|
|
141
|
+
actions,
|
|
142
|
+
options
|
|
143
|
+
};
|
|
144
|
+
return /* @__PURE__ */ jsx(PreviewModeCard, {
|
|
145
|
+
...cardProps,
|
|
146
|
+
ref,
|
|
147
|
+
caption: cardCaption,
|
|
148
|
+
threatDetected: upload?.meta?.antivirus?.status === "infected",
|
|
149
|
+
children: /* @__PURE__ */ jsx(UploadAssetPreview, {
|
|
150
|
+
upload,
|
|
151
|
+
box,
|
|
152
|
+
padding,
|
|
153
|
+
link,
|
|
154
|
+
posterTime: fieldValue?.poster_time ?? void 0,
|
|
155
|
+
audioPlayback: playback
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* The card of an asset: a `MediaCard` with the preview of the asset, its
|
|
161
|
+
* caption, the progress of its upload and the antivirus badge. With
|
|
162
|
+
* `upload`, the card gets them from an asset of the Media Area.
|
|
163
|
+
*/
|
|
164
|
+
var UploadCard = forwardRef(function UploadCard(props, ref) {
|
|
165
|
+
if (props.upload !== void 0) return /* @__PURE__ */ jsx(UploadModeCard, {
|
|
166
|
+
...props,
|
|
167
|
+
ref
|
|
168
|
+
});
|
|
169
|
+
return /* @__PURE__ */ jsx(PreviewModeCard, {
|
|
170
|
+
...props,
|
|
171
|
+
ref
|
|
172
|
+
});
|
|
173
|
+
});
|
|
65
174
|
//#endregion
|
|
66
|
-
export { UploadCard as default, uploadCaption };
|
|
175
|
+
export { UploadCard as default, uploadCaption, uploadCardCaption };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type Message, type TextMessage } from '../Message.js';
|
|
3
|
+
/**
|
|
4
|
+
* A person as the API gives it, and as `ctx` gives it to a plugin (for
|
|
5
|
+
* example `ctx.currentUser`, `ctx.loadUsers()`): a collaborator, an account,
|
|
6
|
+
* an organization, an SSO user, an API token or an invitation. The row reads
|
|
7
|
+
* only these fields.
|
|
8
|
+
*/
|
|
9
|
+
export type UserRowEntity = {
|
|
10
|
+
type: 'user';
|
|
11
|
+
attributes: {
|
|
12
|
+
full_name?: string | null;
|
|
13
|
+
email: string;
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
type: 'account';
|
|
17
|
+
attributes: {
|
|
18
|
+
first_name?: string | null;
|
|
19
|
+
last_name?: string | null;
|
|
20
|
+
email: string;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
type: 'organization';
|
|
24
|
+
attributes: {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
type: 'sso_user';
|
|
29
|
+
attributes: {
|
|
30
|
+
first_name?: string | null;
|
|
31
|
+
last_name?: string | null;
|
|
32
|
+
username: string;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
type: 'access_token';
|
|
36
|
+
attributes: {
|
|
37
|
+
name?: string | null;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
type: 'site_invitation';
|
|
41
|
+
attributes: {
|
|
42
|
+
email: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** The data of a person that the row shows */
|
|
46
|
+
export type UserRowPresentation = {
|
|
47
|
+
/** The name. Without it, the email is the title. */
|
|
48
|
+
name: string | null | undefined;
|
|
49
|
+
/** The email. It gives the Gravatar image and the color of the initials. */
|
|
50
|
+
email: string | null | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The URL of the image of the avatar. Without it, the avatar is the
|
|
53
|
+
* Gravatar image of the email, and the initials of the name when the
|
|
54
|
+
* email has no Gravatar image.
|
|
55
|
+
*/
|
|
56
|
+
imageUrl?: string | null;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The name and the email of a person, as DatoCMS shows them. The name falls
|
|
60
|
+
* back to the email. It is null only for an API token without a name: show
|
|
61
|
+
* the kind (`userKindLabel`) in its place.
|
|
62
|
+
*/
|
|
63
|
+
export declare function userPresentation(user: UserRowEntity): {
|
|
64
|
+
name: string | null;
|
|
65
|
+
email: string | null;
|
|
66
|
+
};
|
|
67
|
+
/** The name of the kind of a person, for example "SSO user" */
|
|
68
|
+
export declare function userKindLabel(type: UserRowEntity['type']): TextMessage;
|
|
69
|
+
type Content =
|
|
70
|
+
/** The person as the API gives it */
|
|
71
|
+
{
|
|
72
|
+
/** The person. The row reads its name and its email. */
|
|
73
|
+
user: UserRowEntity;
|
|
74
|
+
/**
|
|
75
|
+
* Shows the kind of the person after the name, for example "SSO
|
|
76
|
+
* user". Use it when the list or the menu mixes people of different
|
|
77
|
+
* kinds.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
showKind?: boolean;
|
|
81
|
+
presentation?: never;
|
|
82
|
+
kind?: never;
|
|
83
|
+
}
|
|
84
|
+
/** The data of the person, already resolved */
|
|
85
|
+
| {
|
|
86
|
+
/** The name, the email and the image of the person */
|
|
87
|
+
presentation: UserRowPresentation;
|
|
88
|
+
/**
|
|
89
|
+
* The kind of person, after the name in the subtle ink. For example
|
|
90
|
+
* "SSO user", "API token" or "Invitation".
|
|
91
|
+
*/
|
|
92
|
+
kind?: Message;
|
|
93
|
+
user?: never;
|
|
94
|
+
showKind?: never;
|
|
95
|
+
};
|
|
96
|
+
type Layout = {
|
|
97
|
+
/**
|
|
98
|
+
* "row" shows the email below the name, with an avatar of 32px: a row
|
|
99
|
+
* of a list, an option of a menu.
|
|
100
|
+
*/
|
|
101
|
+
layout: 'row';
|
|
102
|
+
/**
|
|
103
|
+
* The line below the name, in place of the email. Write the email in
|
|
104
|
+
* it when the row needs it.
|
|
105
|
+
*/
|
|
106
|
+
children?: ReactNode;
|
|
107
|
+
} | {
|
|
108
|
+
/**
|
|
109
|
+
* "inline" shows the name on one line, with an avatar of 20px: a
|
|
110
|
+
* chip, the value of a select, a cell of a table, a person in a text.
|
|
111
|
+
*/
|
|
112
|
+
layout: 'inline';
|
|
113
|
+
children?: never;
|
|
114
|
+
};
|
|
115
|
+
export type UserRowProps = Content & Layout;
|
|
116
|
+
/**
|
|
117
|
+
* A person in a row: the avatar, the name, the email and the kind. It
|
|
118
|
+
* shows only the content: the container gives the surface, the hover and
|
|
119
|
+
* the click.
|
|
120
|
+
*/
|
|
121
|
+
declare function UserRow(props: UserRowProps): React.JSX.Element;
|
|
122
|
+
export default UserRow;
|