@nascentdigital/funnel-editor 4.5.2 → 4.5.4
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/EditorApp.js +1 -1
- package/dist/core/components/ColorModeToggle.d.ts +2 -2
- package/dist/core/components/feedback/Note.d.ts +3 -1
- package/dist/core/components/feedback/Note.js +6 -3
- package/dist/core/components/fields/BooleanField.d.ts +3 -1
- package/dist/core/components/fields/BooleanField.js +2 -2
- package/dist/core/components/fields/DateField.d.ts +3 -1
- package/dist/core/components/fields/DateField.js +2 -2
- package/dist/core/components/fields/EnumField.d.ts +3 -1
- package/dist/core/components/fields/EnumField.js +4 -4
- package/dist/core/components/fields/FieldEditor.d.ts +3 -1
- package/dist/core/components/fields/FieldEditor.js +7 -7
- package/dist/core/components/fields/FieldHeader.d.ts +3 -1
- package/dist/core/components/fields/FieldHeader.js +18 -5
- package/dist/core/components/fields/FieldLayout.d.ts +3 -1
- package/dist/core/components/fields/FieldLayout.js +17 -4
- package/dist/core/components/fields/FieldSize.d.ts +1 -0
- package/dist/core/components/fields/FieldSize.js +2 -0
- package/dist/core/components/fields/FieldsPanel.js +5 -4
- package/dist/core/components/fields/RichTextEditor.d.ts +2 -3
- package/dist/core/components/fields/RichTextEditor.js +13 -10
- package/dist/core/components/fields/RichTextField.d.ts +1 -2
- package/dist/core/components/fields/RichTextField.js +4 -16
- package/dist/core/components/fields/TextField.d.ts +3 -2
- package/dist/core/components/fields/TextField.js +8 -7
- package/dist/core/components/fields/TimestampField.d.ts +3 -1
- package/dist/core/components/fields/TimestampField.js +2 -2
- package/dist/core/components/fields/collection/CollectionPicker.js +3 -4
- package/dist/core/components/fields/index.d.ts +2 -0
- package/dist/core/components/fields/index.js +2 -0
- package/dist/core/components/fields/page/PagePicker.js +2 -3
- package/dist/core/components/fields/richtext/Theme.d.ts +1 -2
- package/dist/core/components/fields/richtext/Theme.js +2 -2
- package/dist/core/components/interaction/Animate.d.ts +1 -1
- package/dist/core/components/interaction/Animate.js +12 -2
- package/dist/core/components/interaction/Button.js +3 -3
- package/dist/core/components/interaction/Combobox.d.ts +8 -1
- package/dist/core/components/interaction/Combobox.js +39 -12
- package/dist/core/components/interaction/IconButton.d.ts +2 -2
- package/dist/core/components/interaction/IconButton.js +2 -1
- package/dist/core/components/interaction/QuickEditor.d.ts +11 -0
- package/dist/core/components/interaction/QuickEditor.js +33 -0
- package/dist/core/components/interaction/QuickInput.js +1 -1
- package/dist/core/components/interaction/QuickPicker.js +5 -3
- package/dist/core/components/interaction/SegmentedButton.d.ts +3 -1
- package/dist/core/components/interaction/SegmentedButton.js +4 -1
- package/dist/core/components/interaction/SideSheet.d.ts +5 -5
- package/dist/core/components/interaction/SideSheet.js +15 -43
- package/dist/core/components/interaction/centersheet/CenterSheet.js +1 -1
- package/dist/core/components/interaction/centersheet/CenterSheetContainer.js +1 -1
- package/dist/core/components/interaction/index.d.ts +1 -0
- package/dist/core/components/interaction/index.js +1 -0
- package/dist/core/components/visuals/Icon.d.ts +2 -2
- package/dist/core/components/visuals/Icon.js +5 -0
- package/dist/core/domain/BlockConfiguration.d.ts +16 -1
- package/dist/core/domain/BlockConfiguration.js +109 -5
- package/dist/page/components/config/BlockConfig.js +1 -1
- package/dist/page/components/config/BlockConfigEditor.d.ts +1 -1
- package/dist/page/components/config/BlockConfigEditor.js +40 -13
- package/dist/page/components/config/BlockPreview.js +23 -17
- package/dist/page/components/config/LegacyBlockConfigEditor.js +1 -9
- package/dist/page/components/config/ListPanelEditor.d.ts +4 -2
- package/dist/page/components/config/ListPanelEditor.js +52 -2
- package/dist/page/components/config/MessagePanelEditor.d.ts +4 -2
- package/dist/page/components/config/MessagePanelEditor.js +6 -2
- package/dist/page/components/config/VisualPanelEditor.d.ts +4 -2
- package/dist/page/components/config/VisualPanelEditor.js +65 -2
- package/dist/styles/index.css +367 -193
- package/dist/styles/tailwind.js +11 -16
- package/package.json +2 -2
|
@@ -6,11 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CollectionPicker = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
9
|
-
const client_1 = require("@nascentdigital/funnel-ui/client");
|
|
10
9
|
const classnames_1 = __importDefault(require("classnames"));
|
|
11
10
|
const framer_motion_1 = require("framer-motion");
|
|
12
11
|
const react_1 = require("react");
|
|
13
|
-
const
|
|
12
|
+
const client_1 = require("../../../client");
|
|
14
13
|
const hooks_1 = require("../../../hooks");
|
|
15
14
|
const feedback_1 = require("../../feedback");
|
|
16
15
|
const interaction_1 = require("../../interaction");
|
|
@@ -29,7 +28,7 @@ exports.CollectionPicker = (0, react_1.forwardRef)(function CollectionPicker({ l
|
|
|
29
28
|
const [tagTooltip, setTagTooltip] = (0, react_1.useState)();
|
|
30
29
|
const [fetching, setFetching] = (0, react_1.useState)(false);
|
|
31
30
|
const [error, setError] = (0, react_1.useState)();
|
|
32
|
-
const editorApi = (0,
|
|
31
|
+
const editorApi = (0, client_1.useEditorApi)();
|
|
33
32
|
const siteCollections = (0, hooks_1.useCollections)();
|
|
34
33
|
const collectionStore = (0, hooks_1.useCollectionStore)();
|
|
35
34
|
// export service
|
|
@@ -174,7 +173,7 @@ exports.CollectionPicker = (0, react_1.forwardRef)(function CollectionPicker({ l
|
|
|
174
173
|
deferral.resolve(result !== null && result !== void 0 ? result : undefined);
|
|
175
174
|
};
|
|
176
175
|
// render
|
|
177
|
-
return ((0, jsx_runtime_1.jsxs)(interaction_1.Picker, { className: "flex", open: deferral && result === undefined, disableDismiss: fetching, onClose: onCancel, onClosed: onPickerClosed, children: [(0, jsx_runtime_1.jsxs)("section", { className: "shrink-0 w-[206px] flex flex-col gap-l8 p-l8 bg-modal-background", children: [(0, jsx_runtime_1.jsx)("h1", { className: "heading-md text-content-primary", children: "Select Collection" }), (0, jsx_runtime_1.jsx)(interaction_1.ChipFilters, { title: "Site Collections", options: collectionGroups, selectedOptions: collectionGroup && [collectionGroup], onToggle: (collectionGroup, selected) => selected && setCollectionGroup(collectionGroup), renderLabel: collectionGroup => collectionGroup.template.name, disabled: fetching })] }), (0, jsx_runtime_1.jsxs)("section", { className: "flex-1 flex flex-col", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l8 overflow-y-scroll", children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", initial: false, children: renderPicker({ language, error, collectionGroups, collectionGroup, collections, tagOptions, tagFilters, onPick, setTagTooltip, fetching }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-center p-l8 border-t border-solid border-border-l1", children: (0, jsx_runtime_1.jsx)(interaction_1.Button, { variant: "secondary", size: "sm", onClick: onCancel, disabled: fetching, children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(
|
|
176
|
+
return ((0, jsx_runtime_1.jsxs)(interaction_1.Picker, { className: "flex", open: deferral && result === undefined, disableDismiss: fetching, onClose: onCancel, onClosed: onPickerClosed, children: [(0, jsx_runtime_1.jsxs)("section", { className: "shrink-0 w-[206px] flex flex-col gap-l8 p-l8 bg-modal-background", children: [(0, jsx_runtime_1.jsx)("h1", { className: "heading-md text-content-primary", children: "Select Collection" }), (0, jsx_runtime_1.jsx)(interaction_1.ChipFilters, { title: "Site Collections", options: collectionGroups, selectedOptions: collectionGroup && [collectionGroup], onToggle: (collectionGroup, selected) => selected && setCollectionGroup(collectionGroup), renderLabel: collectionGroup => collectionGroup.template.name, disabled: fetching })] }), (0, jsx_runtime_1.jsxs)("section", { className: "flex-1 flex flex-col", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l8 overflow-y-scroll", children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", initial: false, children: renderPicker({ language, error, collectionGroups, collectionGroup, collections, tagOptions, tagFilters, onPick, setTagTooltip, fetching }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-center p-l8 border-t border-solid border-border-l1", children: (0, jsx_runtime_1.jsx)(interaction_1.Button, { variant: "secondary", size: "sm", onClick: onCancel, disabled: fetching, children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(interaction_1.Popup, { className: (0, classnames_1.default)('max-w-[200px] bg-surface2 rounded-md p-l5', 'border border-solid border-border-l1 shadow-tooltip', 'flex flex-wrap items-center gap-l4'), open: !!tagTooltip, anchor: tagTooltip === null || tagTooltip === void 0 ? void 0 : tagTooltip.anchor, anchorOffset: 4, placement: "top", disableOverlay: true, onClose: () => setTagTooltip(undefined), children: tagTooltip === null || tagTooltip === void 0 ? void 0 : tagTooltip.tags.map(tag => (0, jsx_runtime_1.jsx)(feedback_1.Badge, { variant: "outlinedTiny", status: "draft", label: tag.name }, tag.data)) })] })] }));
|
|
178
177
|
});
|
|
179
178
|
function renderPicker({ language, schema, error, collectionGroups, collectionGroup, collections, tagOptions, tagFilters, onPick, setTagTooltip, fetching }) {
|
|
180
179
|
// show error if we have one
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from './asset/AssetPreview';
|
|
1
2
|
export * from './DateField';
|
|
2
3
|
export * from './FieldEditor';
|
|
3
4
|
export * from './FieldErrorController';
|
|
5
|
+
export * from './FieldSize';
|
|
4
6
|
export * from './FieldsPanel';
|
|
5
7
|
export * from './RichTextEditor';
|
|
6
8
|
export * from './RichTextField';
|
|
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./asset/AssetPreview"), exports);
|
|
17
18
|
__exportStar(require("./DateField"), exports);
|
|
18
19
|
__exportStar(require("./FieldEditor"), exports);
|
|
19
20
|
__exportStar(require("./FieldErrorController"), exports);
|
|
21
|
+
__exportStar(require("./FieldSize"), exports);
|
|
20
22
|
__exportStar(require("./FieldsPanel"), exports);
|
|
21
23
|
__exportStar(require("./RichTextEditor"), exports);
|
|
22
24
|
__exportStar(require("./RichTextField"), exports);
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.PagePicker = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
9
|
-
const client_1 = require("@nascentdigital/funnel-ui/client");
|
|
10
9
|
const classnames_1 = __importDefault(require("classnames"));
|
|
11
10
|
const framer_motion_1 = require("framer-motion");
|
|
12
11
|
const react_1 = require("react");
|
|
@@ -206,7 +205,7 @@ exports.PagePicker = (0, react_1.forwardRef)(function PagePicker({ language }, r
|
|
|
206
205
|
? 'Primary'
|
|
207
206
|
: filter.template.name }), tagOptions === null || tagOptions === void 0 ? void 0 : tagOptions.map(({ group, tags: groupTags }) => (0, jsx_runtime_1.jsx)(interaction_1.ChipFilters, { title: group.name, multiselect: true, options: groupTags.values().toArray(), selectedOptions: tagFilters.filter(tag => groupTags.has(tag)), onToggle: (tag, selected) => setTagFilters(tags => selected
|
|
208
207
|
? [...tags, tag]
|
|
209
|
-
: tags.filter(t => t !== tag)), onToggleAll: () => setTagFilters(tags => tags.filter(tag => !groupTags.has(tag))), renderLabel: tag => tag.name }, group.id))] }), (0, jsx_runtime_1.jsxs)("section", { className: "flex-1 flex flex-col", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l8 overflow-y-scroll", children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", initial: false, children: renderPicker({ site, language, disabledIds, error, pageFilters, pageFilter, tagOptions, tagFilters, pagesSchema, pages, onPick, setTagTooltip }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-center p-l8 border-t border-solid border-border-l1", children: (0, jsx_runtime_1.jsx)(interaction_1.Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(
|
|
208
|
+
: tags.filter(t => t !== tag)), onToggleAll: () => setTagFilters(tags => tags.filter(tag => !groupTags.has(tag))), renderLabel: tag => tag.name }, group.id))] }), (0, jsx_runtime_1.jsxs)("section", { className: "flex-1 flex flex-col", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 p-l8 overflow-y-scroll", children: (0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", initial: false, children: renderPicker({ site, language, disabledIds, error, pageFilters, pageFilter, tagOptions, tagFilters, pagesSchema, pages, onPick, setTagTooltip }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-center p-l8 border-t border-solid border-border-l1", children: (0, jsx_runtime_1.jsx)(interaction_1.Button, { variant: "secondary", size: "sm", onClick: onCancel, children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(interaction_1.Popup, { className: (0, classnames_1.default)('max-w-[200px] bg-surface2 rounded-md p-l5', 'border border-solid border-border-l1 shadow-tooltip', 'flex flex-wrap items-center gap-l4'), open: !!tagTooltip, anchor: tagTooltip === null || tagTooltip === void 0 ? void 0 : tagTooltip.anchor, anchorOffset: 4, placement: "top", disableOverlay: true, onClose: () => setTagTooltip(undefined), children: tagTooltip === null || tagTooltip === void 0 ? void 0 : tagTooltip.tags.map(tag => (0, jsx_runtime_1.jsx)(feedback_1.Badge, { variant: "outlinedTiny", status: "draft", label: tag.name }, tag.data)) })] })] }));
|
|
210
209
|
});
|
|
211
210
|
function renderPicker({ site, language, disabledIds, error, pageFilters, pageFilter, tagOptions, tagFilters, pagesSchema, pages, onPick, setTagTooltip }) {
|
|
212
211
|
// show error if we have one
|
|
@@ -265,7 +264,7 @@ function renderPageRef({ language, template, disabledIds, ref, onPick, setTagToo
|
|
|
265
264
|
const visibleTags = tags.slice(0, Math.min(tags.length, 2));
|
|
266
265
|
const tooltipTags = tags.length > 2
|
|
267
266
|
? tags.slice(2)
|
|
268
|
-
: [];
|
|
267
|
+
: [...Object.values(funnel_core_1.Schema.AssetField.Tags.image.tags)];
|
|
269
268
|
const disabled = !ref || ref.language !== language || disabledIds.includes(ref.id);
|
|
270
269
|
// helpers
|
|
271
270
|
const onClick = () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Schema } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { EditorThemeClasses } from 'lexical';
|
|
3
|
-
import { RichTextEditor } from '../RichTextEditor';
|
|
4
3
|
export declare const listClassname: string;
|
|
5
4
|
export declare const listItemClassname: string;
|
|
6
|
-
export declare function getTheme(variant:
|
|
5
|
+
export declare function getTheme(variant: Schema.RichTextField.Semantics, options: Schema.RichTextField.Capabilities.Options): EditorThemeClasses;
|
|
@@ -24,8 +24,8 @@ function getTheme(variant, options) {
|
|
|
24
24
|
},
|
|
25
25
|
// text
|
|
26
26
|
paragraph: (0, classnames_1.default)('block min-h-body-sm last:mb-0', {
|
|
27
|
-
'mb-l5': variant === 'area',
|
|
28
|
-
'mb-l8': variant === 'editor',
|
|
27
|
+
'mb-l5': variant === 'area' || variant === 'mini-editor',
|
|
28
|
+
'mb-l8': variant === 'full-editor',
|
|
29
29
|
}),
|
|
30
30
|
quote: 'block pl-l6 mb-l8 last:mb-0 border-l-3 border-solid border-border-l1',
|
|
31
31
|
text: {
|
|
@@ -18,8 +18,18 @@ function Animate({ className, present = false, layout = false, effect = 'fade',
|
|
|
18
18
|
Animate.Variants = {
|
|
19
19
|
fade: {
|
|
20
20
|
initial: { opacity: 0, transition: { when: 'beforeChildren' } },
|
|
21
|
-
animate: { opacity: 1, transition: { ease: "easeIn", when: 'beforeChildren' } },
|
|
22
|
-
exit: { opacity: 0, transition: { ease: "easeOut", when: 'afterChildren' } }
|
|
21
|
+
animate: { opacity: 1, transition: { duration: 0.4, ease: "easeIn", when: 'beforeChildren' } },
|
|
22
|
+
exit: { opacity: 0, transition: { duration: 0.3, ease: "easeOut", when: 'afterChildren' } }
|
|
23
|
+
},
|
|
24
|
+
slideFromLeft: {
|
|
25
|
+
initial: { x: '100%', transition: { when: 'beforeChildren' } },
|
|
26
|
+
animate: { x: 0, transition: { duration: 0.3, ease: "easeIn", when: 'beforeChildren' } },
|
|
27
|
+
exit: { x: '100%', transition: { duration: 0.3, ease: "easeOut", when: 'afterChildren' } }
|
|
28
|
+
},
|
|
29
|
+
slideFromBottom: {
|
|
30
|
+
initial: { y: '100%', transition: { when: 'beforeChildren' } },
|
|
31
|
+
animate: { y: 0, transition: { duration: 0.3, ease: "easeIn", when: 'beforeChildren' } },
|
|
32
|
+
exit: { y: '100%', transition: { duration: 0.3, ease: "easeOut", when: 'afterChildren' } }
|
|
23
33
|
}
|
|
24
34
|
};
|
|
25
35
|
})(Animate || (exports.Animate = Animate = {}));
|
|
@@ -26,9 +26,9 @@ exports.Button = (0, react_1.forwardRef)(function Button(_a, ref) {
|
|
|
26
26
|
var { className, variant = 'primary', size = 'md', iconLeft, iconRight, loading = false, disabled = false, children } = _a, props = __rest(_a, ["className", "variant", "size", "iconLeft", "iconRight", "loading", "disabled", "children"]);
|
|
27
27
|
// render
|
|
28
28
|
return ((0, jsx_runtime_1.jsxs)("button", Object.assign({ ref: ref, className: (0, classnames_1.default)(className, getButtonClassnames({ variant, size, loading, disabled })), type: "button", disabled: disabled || loading }, props, { children: [loading &&
|
|
29
|
-
(0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "sm" }), iconLeft && !loading &&
|
|
30
|
-
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: iconLeft, size: size
|
|
31
|
-
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: iconRight, size: size
|
|
29
|
+
(0, jsx_runtime_1.jsx)(Loader_1.Loader, { size: "sm" }), iconLeft && !loading &&
|
|
30
|
+
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: iconLeft, size: size }), children, iconRight &&
|
|
31
|
+
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: iconRight, size: size })] })));
|
|
32
32
|
});
|
|
33
33
|
function getButtonClassnames({ variant, size, loading, disabled }) {
|
|
34
34
|
return (0, classnames_1.default)('button', {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Callback, Transform } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { FieldSize } from '../fields';
|
|
3
4
|
import { Icon } from '../visuals';
|
|
4
|
-
export declare function Combobox<TOptionId extends string>({ id: externalId, className, maxRows, rowHeight, disabled, options, noSelectionText, selectedOption: selectedOptionId, onSelect, renderSelection: renderSelectionRaw, renderOption, }: Combobox.Props<TOptionId>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function Combobox<TOptionId extends string>({ id: externalId, className, size, maxRows, rowHeight: rowHeightRaw, disabled, options, noSelectionText, selectedOption: selectedOptionId, onSelect, renderSelection: renderSelectionRaw, renderOption, }: Combobox.Props<TOptionId>): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
export declare namespace Combobox {
|
|
6
7
|
type Props<TOptionId extends string> = {
|
|
7
8
|
id?: string;
|
|
8
9
|
className?: string;
|
|
10
|
+
size?: FieldSize;
|
|
9
11
|
maxRows?: number;
|
|
10
12
|
rowHeight?: number;
|
|
11
13
|
disabled?: boolean;
|
|
@@ -16,6 +18,10 @@ export declare namespace Combobox {
|
|
|
16
18
|
renderSelection?: Transform<Option<TOptionId> | undefined, ReactNode>;
|
|
17
19
|
renderOption?: Transform<RenderOptionArgs<TOptionId>, ReactNode>;
|
|
18
20
|
};
|
|
21
|
+
type RenderSelectionArgs<TOptionId extends string> = {
|
|
22
|
+
option?: Option<TOptionId>;
|
|
23
|
+
size: FieldSize;
|
|
24
|
+
};
|
|
19
25
|
type Option<TOptionId extends string = string> = Option.Standard<TOptionId> | Option.WithIcon<TOptionId>;
|
|
20
26
|
namespace Option {
|
|
21
27
|
type Standard<TOptionId extends string> = {
|
|
@@ -30,6 +36,7 @@ export declare namespace Combobox {
|
|
|
30
36
|
type RenderOptionArgs<TOptionId extends string = string> = {
|
|
31
37
|
option: Option<TOptionId>;
|
|
32
38
|
selected: boolean;
|
|
39
|
+
size: FieldSize;
|
|
33
40
|
};
|
|
34
41
|
interface Service {
|
|
35
42
|
}
|
|
@@ -12,7 +12,7 @@ const react_1 = require("react");
|
|
|
12
12
|
const visuals_1 = require("../visuals");
|
|
13
13
|
const Popup_1 = require("./Popup");
|
|
14
14
|
// component
|
|
15
|
-
function Combobox({ id: externalId, className, maxRows = 6, rowHeight
|
|
15
|
+
function Combobox({ id: externalId, className, size = 'md', maxRows = 6, rowHeight: rowHeightRaw, disabled = false, options, noSelectionText = 'Make a selection', selectedOption: selectedOptionId, onSelect = funnel_core_1.Fn.NoOp, renderSelection: renderSelectionRaw, renderOption = onRenderOption, }) {
|
|
16
16
|
// bind state
|
|
17
17
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
18
18
|
const buttonRef = (0, react_1.useRef)(null);
|
|
@@ -24,7 +24,19 @@ function Combobox({ id: externalId, className, maxRows = 6, rowHeight = 36, disa
|
|
|
24
24
|
&& options.find(option => option.id === selectedOptionId);
|
|
25
25
|
const renderSelection = (0, react_1.useMemo)(() => renderSelectionRaw
|
|
26
26
|
? renderSelectionRaw :
|
|
27
|
-
(option) => onRenderSelection(option, noSelectionText), [renderSelectionRaw, noSelectionText]);
|
|
27
|
+
(option) => onRenderSelection({ option, size }, noSelectionText), [renderSelectionRaw, size, noSelectionText]);
|
|
28
|
+
const rowHeight = rowHeightRaw
|
|
29
|
+
? rowHeightRaw
|
|
30
|
+
: size === 'md'
|
|
31
|
+
? 36
|
|
32
|
+
: size === 'sm'
|
|
33
|
+
? 32
|
|
34
|
+
: 24;
|
|
35
|
+
const rowPaddingY = size === 'md'
|
|
36
|
+
? 8
|
|
37
|
+
: size === 'sm'
|
|
38
|
+
? 6
|
|
39
|
+
: 3;
|
|
28
40
|
// helpers
|
|
29
41
|
const onOpen = (e) => {
|
|
30
42
|
// stop propagation
|
|
@@ -47,21 +59,30 @@ function Combobox({ id: externalId, className, maxRows = 6, rowHeight = 36, disa
|
|
|
47
59
|
setOpen(false);
|
|
48
60
|
};
|
|
49
61
|
// render
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, id: id, className: (0, classnames_1.default)(className, '
|
|
62
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, id: id, className: (0, classnames_1.default)(className, 'flex items-center justify-between gap-l5 px-l5', 'bg-surface1 border border-solid border-border-l1 rounded-full select-none appearance-none', 'disabled:opacity-disabled', {
|
|
63
|
+
'min-w-[200px] h-40': size === 'md',
|
|
64
|
+
'min-w-[180px] h-32': size === 'sm',
|
|
65
|
+
'min-w-[120px] h-24': size === 'xs',
|
|
51
66
|
'pointer-events-none': open
|
|
52
|
-
}), type: "button", disabled: disabled, role: "combobox", "aria-expanded": open, "aria-controls": popupId, "aria-owns": popupId, onClick: onOpen, onKeyDown: client_1.OnKey.enter(onOpen), children: [renderSelection(selectedOption), (0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "text-content-primary", variant: "ChevronDown" })] }), (0, jsx_runtime_1.jsx)(Popup_1.Popup, { open: open, anchor: button, anchorOffset: 2, placement: "bottom", onClose: onOptionsClose, children: (0, jsx_runtime_1.jsx)("div", { id: popupId, className: (0, classnames_1.default)('flex flex-col
|
|
67
|
+
}), type: "button", disabled: disabled, role: "combobox", "aria-expanded": open, "aria-controls": popupId, "aria-owns": popupId, onClick: onOpen, onKeyDown: client_1.OnKey.enter(onOpen), children: [renderSelection(selectedOption), (0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "text-content-primary", variant: "ChevronDown" })] }), (0, jsx_runtime_1.jsx)(Popup_1.Popup, { open: open, anchor: button, anchorOffset: 2, placement: "bottom", onClose: onOptionsClose, children: (0, jsx_runtime_1.jsx)("div", { id: popupId, className: (0, classnames_1.default)('flex flex-col bg-surface2 shadow-popup overflow-y-scroll', {
|
|
68
|
+
'py-l4 rounded-lg': size === 'md',
|
|
69
|
+
'py-l3 rounded-md': size !== 'md'
|
|
70
|
+
}), style: {
|
|
53
71
|
minWidth: button ? `${button.offsetWidth}px` : 'auto',
|
|
54
|
-
maxHeight: maxRows * rowHeight +
|
|
72
|
+
maxHeight: maxRows * rowHeight + (rowPaddingY * 2)
|
|
55
73
|
}, role: "listbox", children: options.map((option, index) => {
|
|
56
74
|
// render
|
|
57
75
|
const optionKey = getOptionId(id, option);
|
|
58
76
|
const selected = option.id === selectedOptionId;
|
|
59
|
-
return ((0, jsx_runtime_1.jsx)("button", { id: optionKey, style: { height: `${rowHeight}px` }, role: "option", "aria-selected": selected, autoFocus: (index === 0 && !selected) || (index === 1 && options[0].id === selectedOptionId), disabled: selected, onClick: e => onOptionSelect(e, option), onKeyDown: client_1.OnKey.enter(e => onOptionSelect(e, option)), children: (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('h-full flex items-center justify-between
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)("button", { id: optionKey, style: { height: `${rowHeight}px` }, role: "option", "aria-selected": selected, autoFocus: (index === 0 && !selected) || (index === 1 && options[0].id === selectedOptionId), disabled: selected, onClick: e => onOptionSelect(e, option), onKeyDown: client_1.OnKey.enter(e => onOptionSelect(e, option)), children: (0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('h-full flex items-center justify-between appearance-none select-none outline-none interpolate', {
|
|
78
|
+
'gap-l4 px-l6': size === 'md',
|
|
79
|
+
'gap-l3 px-l5': size === 'sm',
|
|
80
|
+
'gap-l2 px-l4': size === 'xs',
|
|
60
81
|
'text-content-link-highlight': selected,
|
|
61
82
|
'text-content-primary hover:bg-ix-util-hover/tint1 active:bg-ix-util-press/tint2': !selected && !disabled,
|
|
62
83
|
'focus-visible:bg-interactive focus-visible:border-border-l1': !selected && !disabled,
|
|
63
84
|
'text-ix-disabled-content': disabled
|
|
64
|
-
}), children: renderOption({ option, selected }) }) }, optionKey));
|
|
85
|
+
}), children: renderOption({ option, selected, size }) }) }, optionKey));
|
|
65
86
|
}) }) })] }));
|
|
66
87
|
}
|
|
67
88
|
// extension
|
|
@@ -79,16 +100,22 @@ function Combobox({ id: externalId, className, maxRows = 6, rowHeight = 36, disa
|
|
|
79
100
|
function getOptionId(comboboxId, option) {
|
|
80
101
|
return `${comboboxId}::option::${option.id}`;
|
|
81
102
|
}
|
|
82
|
-
function onRenderSelection(option, noSelectionText) {
|
|
103
|
+
function onRenderSelection({ option, size }, noSelectionText) {
|
|
83
104
|
var _a;
|
|
84
|
-
return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('inline-block
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('inline-block', {
|
|
106
|
+
'body-sm': size === 'md',
|
|
107
|
+
'label-sm': size === 'sm',
|
|
108
|
+
'label-xs': size === 'xs',
|
|
85
109
|
'text-content-primary': !!option,
|
|
86
110
|
'text-ix-disabled-content': !option
|
|
87
111
|
}), children: (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : noSelectionText }));
|
|
88
112
|
}
|
|
89
|
-
function onRenderOption({ option, selected }) {
|
|
90
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('inline-block
|
|
113
|
+
function onRenderOption({ option, selected, size }) {
|
|
114
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)('inline-block', {
|
|
115
|
+
'label-md': size === 'md',
|
|
116
|
+
'label-sm': size === 'sm',
|
|
117
|
+
'label-xs': size === 'xs',
|
|
91
118
|
'label-strong': selected
|
|
92
119
|
}), children: option.label }), selected &&
|
|
93
|
-
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "Check" })] }));
|
|
120
|
+
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { variant: "Check", size: size })] }));
|
|
94
121
|
}
|
|
@@ -3,7 +3,7 @@ import { Icon } from '../visuals';
|
|
|
3
3
|
export declare const IconButton: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
4
4
|
variant?: IconButton.Variant;
|
|
5
5
|
icon: Icon.Variant;
|
|
6
|
-
size?: Extract<Icon.Size, "md" | "sm" | "xs">;
|
|
6
|
+
size?: Extract<Icon.Size, "md" | "sm" | "xs" | "xxs">;
|
|
7
7
|
active?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -11,7 +11,7 @@ export declare namespace IconButton {
|
|
|
11
11
|
type Props = Omit<HTMLAttributes<HTMLButtonElement>, 'children'> & {
|
|
12
12
|
variant?: Variant;
|
|
13
13
|
icon: Icon.Variant;
|
|
14
|
-
size?: Extract<Icon.Size, 'md' | 'sm' | 'xs'>;
|
|
14
|
+
size?: Extract<Icon.Size, 'md' | 'sm' | 'xs' | 'xxs'>;
|
|
15
15
|
active?: boolean;
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
};
|
|
@@ -36,6 +36,7 @@ function getIconButtonClassnames({ variant, size, active, disabled }) {
|
|
|
36
36
|
'iconbutton-disabled': disabled,
|
|
37
37
|
'iconbutton-md': size === 'md',
|
|
38
38
|
'iconbutton-sm': size === 'sm',
|
|
39
|
-
'iconbutton-xs': size === 'xs'
|
|
39
|
+
'iconbutton-xs': size === 'xs',
|
|
40
|
+
'iconbutton-xxs': size === 'xxs'
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Popup } from './Popup';
|
|
3
|
+
export declare function QuickEditor({ className, title, tip, size, open, onClose, children, ...props }: QuickEditor.Props): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare namespace QuickEditor {
|
|
5
|
+
type Props = Popup.Props & {
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
tip?: string;
|
|
8
|
+
size?: Size;
|
|
9
|
+
};
|
|
10
|
+
type Size = 'md' | 'sm';
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.QuickEditor = QuickEditor;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const funnel_ui_1 = require("@nascentdigital/funnel-ui");
|
|
20
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
21
|
+
const feedback_1 = require("../feedback");
|
|
22
|
+
const IconButton_1 = require("./IconButton");
|
|
23
|
+
const Popup_1 = require("./Popup");
|
|
24
|
+
// component
|
|
25
|
+
function QuickEditor(_a) {
|
|
26
|
+
var { className, title, tip, size = 'md', open = false, onClose, children } = _a, props = __rest(_a, ["className", "title", "tip", "size", "open", "onClose", "children"]);
|
|
27
|
+
// render
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(Popup_1.Popup, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'flex flex-col', 'bg-surface1 border-solid border-border-l1 shadow-miniEditor', 'border border-solid border-border-l1 rounded-md overflow-hidden', {
|
|
29
|
+
'w-[320px]': size === 'md',
|
|
30
|
+
'w-[288px]': size === 'sm'
|
|
31
|
+
}), open: open, onClose: onClose, children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-content-primary flex justify-between items-center gap-l8 px-l8 pt-l8 pb-l4", children: [(0, jsx_runtime_1.jsx)("h2", { className: "heading-sm text-pretty", children: title }), (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { className: "shrink-0", icon: "X", size: "xs", onClick: onClose })] }), tip &&
|
|
32
|
+
(0, jsx_runtime_1.jsx)(feedback_1.Note, { className: "mt-l2 mb-l4 mx-l8", variant: "tip", size: size === 'md' ? 'sm' : 'xs', children: (0, jsx_runtime_1.jsx)(funnel_ui_1.Markup, { markdown: `**Tip:** ${tip}` }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 px-l8 pt-l4 pb-l8 overflow-y-scroll", children: children })] })));
|
|
33
|
+
}
|
|
@@ -140,7 +140,7 @@ function renderInput({ field, onKeyDown }) {
|
|
|
140
140
|
const { schema } = field;
|
|
141
141
|
switch (schema.type) {
|
|
142
142
|
case 'text':
|
|
143
|
-
return ((0, jsx_runtime_1.jsx)(TextField_1.TextField, { className: "flex-1", field: field, variant: "minimal",
|
|
143
|
+
return ((0, jsx_runtime_1.jsx)(TextField_1.TextField, { className: "flex-1", field: field, variant: "minimal", size: "sm", autoFocus: true, onKeyDown: onKeyDown }));
|
|
144
144
|
case 'richtext':
|
|
145
145
|
return ((0, jsx_runtime_1.jsx)(fields_1.RichTextField, { className: "flex-1", field: field, minimal: true, autoFocus: true }));
|
|
146
146
|
default:
|
|
@@ -88,12 +88,14 @@ exports.QuickPicker = (0, react_1.forwardRef)(function QuickPicker({ variant, ti
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
// render
|
|
91
|
-
return ((0, jsx_runtime_1.jsxs)(Popup_1.Popup, Object.assign({}, (popupProps !== null && popupProps !== void 0 ? popupProps : {}), { className: (0, classnames_1.default)('glass-overlay w-[
|
|
91
|
+
return ((0, jsx_runtime_1.jsxs)(Popup_1.Popup, Object.assign({}, (popupProps !== null && popupProps !== void 0 ? popupProps : {}), { className: (0, classnames_1.default)('glass-overlay max-w-[380px] flex flex-col gap-l8 pt-l8 interpolate', 'border border-solid border-glass-stroke-l1/tint5 rounded-md', {
|
|
92
92
|
'opacity-none': !opened,
|
|
93
93
|
'opacity-full': opened
|
|
94
94
|
}), animation: "out", open: !!deferral, onOpened: () => setOpened(true), onClose: onClose, onClosed: () => setOpened(false), children: [(0, jsx_runtime_1.jsxs)("section", { className: "px-l8", children: [(0, jsx_runtime_1.jsx)("h3", { className: "heading-sm text-content-primary", children: title }), description &&
|
|
95
95
|
(0, jsx_runtime_1.jsx)("p", { className: "body-sm text-content-secondary", children: description })] }), (0, jsx_runtime_1.jsx)("section", { className: (0, classnames_1.default)({
|
|
96
|
-
'flex flex-wrap
|
|
96
|
+
'flex flex-wrap gap-l5 items-center px-l8 pb-l8 overflow-y-scroll': variant === 'card',
|
|
97
|
+
'w-[288px]': variant === 'card' && items.length < 4,
|
|
98
|
+
'w-[372px] max-h-[213px]': variant === 'card' && items.length >= 4
|
|
97
99
|
}), children: items.map(item => renderCard({
|
|
98
100
|
item,
|
|
99
101
|
content: renderItem(item),
|
|
@@ -102,7 +104,7 @@ exports.QuickPicker = (0, react_1.forwardRef)(function QuickPicker({ variant, ti
|
|
|
102
104
|
})) })] })));
|
|
103
105
|
});
|
|
104
106
|
function renderCard({ item, content, selected, onSelect }) {
|
|
105
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('FieldCard w-[
|
|
107
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('FieldCard w-[72px] h-[55px]', {
|
|
106
108
|
'FieldCard-selected': selected
|
|
107
109
|
}), onClick: () => onSelect(item.id), children: content }, item.id));
|
|
108
110
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Callback } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { FieldSize } from '../fields';
|
|
2
3
|
import { Icon } from '../visuals';
|
|
3
|
-
export declare function SegmentedButton<TOption extends SegmentedButton.OptionType>({ className, options, selected, allowEmpty, multiSelect, autoFocus, disabled, onSelectionChange, onBlur }: SegmentedButton.Props<TOption>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function SegmentedButton<TOption extends SegmentedButton.OptionType>({ className, size, options, selected, allowEmpty, multiSelect, autoFocus, disabled, onSelectionChange, onBlur }: SegmentedButton.Props<TOption>): import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
export declare namespace SegmentedButton {
|
|
5
6
|
type OptionType = string | number;
|
|
6
7
|
type Props<TOption extends OptionType> = {
|
|
7
8
|
className?: string;
|
|
9
|
+
size?: FieldSize;
|
|
8
10
|
options: ReadonlyArray<Option<TOption>>;
|
|
9
11
|
selected?: TOption | ReadonlyArray<TOption>;
|
|
10
12
|
allowEmpty?: boolean;
|
|
@@ -11,7 +11,7 @@ const ms_1 = __importDefault(require("ms"));
|
|
|
11
11
|
const react_1 = require("react");
|
|
12
12
|
const visuals_1 = require("../visuals");
|
|
13
13
|
// component
|
|
14
|
-
function SegmentedButton({ className, options, selected = [], allowEmpty = false, multiSelect = false, autoFocus = false, disabled = false, onSelectionChange, onBlur = funnel_core_1.Fn.NoOp }) {
|
|
14
|
+
function SegmentedButton({ className, size = 'md', options, selected = [], allowEmpty = false, multiSelect = false, autoFocus = false, disabled = false, onSelectionChange, onBlur = funnel_core_1.Fn.NoOp }) {
|
|
15
15
|
// bind ref data
|
|
16
16
|
const blurTimeoutRef = (0, react_1.useRef)(undefined);
|
|
17
17
|
const selectedOptions = Array.isArray(selected)
|
|
@@ -68,6 +68,9 @@ function SegmentedButton({ className, options, selected = [], allowEmpty = false
|
|
|
68
68
|
}), children: options.map(({ id, value, label, icon }) => {
|
|
69
69
|
const active = selectedOptions.includes(value);
|
|
70
70
|
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", disabled: disabled, className: (0, classnames_1.default)('segmented-button', {
|
|
71
|
+
'segmented-button-md': size === 'md',
|
|
72
|
+
'segmented-button-sm': size === 'sm',
|
|
73
|
+
'segmented-button-xs': size === 'xs',
|
|
71
74
|
'segmented-button-selected': active
|
|
72
75
|
}), onClick: () => onSelect(value), onFocus: onSegmentFocus, onBlur: onSegmentBlur, children: [icon &&
|
|
73
76
|
(0, jsx_runtime_1.jsx)(visuals_1.Icon, { className: "segmented-button-icon", variant: icon, size: "nav" }), (0, jsx_runtime_1.jsx)("span", { className: "segmented-button-label", children: label })] }, id));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Callback, Provider, Transform } from '@nascentdigital/funnel-core';
|
|
2
|
-
import { HTMLMotionProps
|
|
2
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
3
3
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
4
|
-
export declare function SideSheet({ className, title,
|
|
4
|
+
export declare function SideSheet({ className, title, size, backdrop, disabled, disableDismiss, disableOverlay, disableSave, canSave, renderSaveLabel, onSave: onSaveRaw, open, onOpened: onOpenedRaw, onClose: onCloseRaw, onClosed: onClosedRaw, onKeyDown: onKeyDownRaw, customActions, children, ...props }: SideSheet.Props): import("react").ReactPortal | null;
|
|
5
5
|
export declare namespace SideSheet {
|
|
6
6
|
type Props = Omit<HTMLMotionProps<'div'>, 'children'> & PropsWithChildren & {
|
|
7
7
|
title: ReactNode;
|
|
8
|
-
|
|
8
|
+
size?: Size;
|
|
9
9
|
backdrop?: Backdrop;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
disableDismiss?: boolean;
|
|
@@ -20,7 +20,7 @@ export declare namespace SideSheet {
|
|
|
20
20
|
onClose?: Callback.Void;
|
|
21
21
|
onClosed?: Callback.Void;
|
|
22
22
|
};
|
|
23
|
-
type
|
|
23
|
+
type Size = 'xs' | 'sm' | 'md' | 'lg';
|
|
24
24
|
type Backdrop = 'none' | 'glass';
|
|
25
|
+
type State = 'editing' | 'validating' | 'saving' | 'error' | 'saved';
|
|
25
26
|
}
|
|
26
|
-
export declare const Animations: Record<'background' | 'slideRight', Variants>;
|
|
@@ -14,22 +14,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Animations = void 0;
|
|
18
17
|
exports.SideSheet = SideSheet;
|
|
19
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
20
19
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
20
|
+
const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
|
|
21
21
|
const classnames_1 = __importDefault(require("classnames"));
|
|
22
22
|
const framer_motion_1 = require("framer-motion");
|
|
23
23
|
const react_1 = require("motion/react");
|
|
24
24
|
const react_2 = require("react");
|
|
25
25
|
const react_dom_1 = require("react-dom");
|
|
26
|
+
const Animate_1 = require("./Animate");
|
|
26
27
|
const Button_1 = require("./Button");
|
|
27
28
|
// component
|
|
28
29
|
function SideSheet(_a) {
|
|
29
|
-
var
|
|
30
|
-
|
|
30
|
+
var _b;
|
|
31
|
+
var { className, title, size = 'md', backdrop = 'none', disabled = false, disableDismiss = false, disableOverlay = false, disableSave = false, canSave = funnel_core_1.Fn.True, renderSaveLabel = onRenderSaveLabel, onSave: onSaveRaw = funnel_core_1.Fn.NoOp, open = false, onOpened: onOpenedRaw = funnel_core_1.Fn.NoOp, onClose: onCloseRaw = funnel_core_1.Fn.NoOp, onClosed: onClosedRaw = funnel_core_1.Fn.NoOp, onKeyDown: onKeyDownRaw, customActions, children } = _a, props = __rest(_a, ["className", "title", "size", "backdrop", "disabled", "disableDismiss", "disableOverlay", "disableSave", "canSave", "renderSaveLabel", "onSave", "open", "onOpened", "onClose", "onClosed", "onKeyDown", "customActions", "children"]);
|
|
32
|
+
// bind state + hooks + refs
|
|
31
33
|
const [state, setState] = (0, react_2.useState)('editing');
|
|
32
34
|
const locked = disabled || state === 'validating' || state === 'saving' || state === 'saved';
|
|
35
|
+
const breakpoint = (_b = (0, hooks_1.useCurrentBreakpoint)()) !== null && _b !== void 0 ? _b : 'xs';
|
|
33
36
|
const id = (0, react_2.useId)();
|
|
34
37
|
const openRef = (0, react_2.useRef)(open);
|
|
35
38
|
openRef.current = open;
|
|
@@ -141,51 +144,20 @@ function SideSheet(_a) {
|
|
|
141
144
|
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: open &&
|
|
142
145
|
(0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { id: id, className: (0, classnames_1.default)('fixed inset-0 z-popup', {
|
|
143
146
|
'pointer-events-none': disableOverlay
|
|
144
|
-
}),
|
|
147
|
+
}), onClick: disableDismiss || locked ? undefined : onBackdropClick, layout: true, children: [backdrop !== 'none' &&
|
|
145
148
|
(0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: (0, classnames_1.default)('fixed inset-0 z-backdrop pointer-events-none', {
|
|
146
149
|
'backdrop-blur-[9px] bg-glass/backdrop will-change-[backdrop-filter]': backdrop === 'glass'
|
|
147
|
-
}) }, "backdrop"), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'fixed right-0 inset-y-0 pointer-events-none', {
|
|
148
|
-
'w-full
|
|
149
|
-
'w-full md:w-
|
|
150
|
-
|
|
150
|
+
}), variants: Animate_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit" }, "backdrop"), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'fixed max-md:inset-x-0 max-md:bottom-0 max-md:top-[40px] md:right-0 md:inset-y-0 z-sheet pointer-events-none', {
|
|
151
|
+
'w-full md:w-[320px]': size === 'xs',
|
|
152
|
+
'w-full md:w-[380px]': size === 'sm',
|
|
153
|
+
'w-full md:w-[480px]': size === 'md',
|
|
154
|
+
'w-full md:w-screen-sm': size === 'lg'
|
|
155
|
+
}), variants: breakpoint === 'xs' || breakpoint === 'sm'
|
|
156
|
+
? Animate_1.Animate.Variants.slideFromBottom
|
|
157
|
+
: Animate_1.Animate.Variants.slideFromLeft, initial: "initial", animate: "animate", exit: "exit", onAnimationComplete: definition => onAnimationComplete(definition), onKeyDown: onKeyDown, tabIndex: -1, children: (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(className, 'w-full h-full max-h-full pointer-events-auto', 'flex flex-col', 'bg-background border-solid border-border-l1', 'max-md:border-t max-md:rounded-tl-md max-md:rounded-tr-md', 'md:border-l md:rounded-tl-md md:rounded-bl-md'), children: [(0, jsx_runtime_1.jsx)("h2", { className: "heading-sm text-content-primary px-l8 pt-l8 pb-l4", children: title }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1 px-l8 pt-l4 pb-l8 overflow-y-scroll", children: children }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('flex justify-end items-center gap-l4 p-l8', 'border-t border-solid border-border-l1'), children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "text", size: "sm", disabled: locked, onClick: onClose, children: "Cancel" }), customActions &&
|
|
151
158
|
(0, jsx_runtime_1.jsx)("div", { className: "flex-1 flex justify-end items-center gap-l4", children: customActions }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "primary", size: "sm", loading: state === 'saving', disabled: disableSave || locked, onClick: onSave, children: renderSaveLabel(state) })] })] }) }))] }, id) }), document.body);
|
|
152
159
|
}
|
|
153
160
|
// helpers
|
|
154
|
-
exports.Animations = {
|
|
155
|
-
background: {
|
|
156
|
-
hidden: {
|
|
157
|
-
opacity: 0
|
|
158
|
-
},
|
|
159
|
-
visible: {
|
|
160
|
-
opacity: 1,
|
|
161
|
-
transition: {
|
|
162
|
-
ease: 'easeIn',
|
|
163
|
-
duration: 0.3,
|
|
164
|
-
when: 'beforeChildren'
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
exit: {
|
|
168
|
-
opacity: 0,
|
|
169
|
-
transition: {
|
|
170
|
-
ease: 'easeIn',
|
|
171
|
-
duration: 0.15,
|
|
172
|
-
bounce: 0,
|
|
173
|
-
when: 'afterChildren'
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
slideRight: {
|
|
178
|
-
initial: {
|
|
179
|
-
x: '100%'
|
|
180
|
-
},
|
|
181
|
-
animate: {
|
|
182
|
-
x: '0'
|
|
183
|
-
},
|
|
184
|
-
exit: {
|
|
185
|
-
x: '100%'
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
161
|
function onRenderSaveLabel(state) {
|
|
190
162
|
switch (state) {
|
|
191
163
|
case 'editing':
|
|
@@ -96,7 +96,7 @@ exports.CenterSheet = (0, react_2.forwardRef)(function CenterSheet({ className,
|
|
|
96
96
|
}
|
|
97
97
|
// render
|
|
98
98
|
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: open &&
|
|
99
|
-
(0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { id: id, className: (0, classnames_1.default)('absolute inset-0 z-popup
|
|
99
|
+
(0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { id: id, className: (0, classnames_1.default)('absolute inset-0 z-popup pointer-events-auto', 'flex flex-col justify-stretch items-center pt-l12 px-l6 md:px-l10 lg:px-l15'), variants: Animations.container, onAnimationComplete: definition => onAnimationComplete(definition), initial: "hidden", animate: "visible", exit: "exit", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0", onClick: onClose }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(className, 'relative h-full w-full max-w-[1000px] max-h-full overflow-hidden', 'text-onSurface bg-background rounded-t-lg shadow-objectEditor'), children: children })] }, id) }), anchor);
|
|
100
100
|
});
|
|
101
101
|
// animations
|
|
102
102
|
var Animations;
|
|
@@ -58,7 +58,7 @@ function CenterSheetContainer({ children }) {
|
|
|
58
58
|
// render
|
|
59
59
|
const { sheets } = context;
|
|
60
60
|
const active = sheets.length > 0;
|
|
61
|
-
return ((0, jsx_runtime_1.jsxs)(CenterSheetContext_1.CenterSheetContext.Provider, { value: context, children: [children, (0, jsx_runtime_1.jsx)("div", { className: "fixed inset-0 pointer-events-none", children: (0, jsx_runtime_1.jsx)("div", { id: anchorId, className: "relative w-full h-full", children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('absolute inset-0 z-backdrop
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)(CenterSheetContext_1.CenterSheetContext.Provider, { value: context, children: [children, (0, jsx_runtime_1.jsx)("div", { className: "fixed inset-0 pointer-events-none", children: (0, jsx_runtime_1.jsx)("div", { id: anchorId, className: "relative w-full h-full", children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('absolute inset-0 z-backdrop interpolate will-change-[backdrop-filter,opacity]', 'backdrop-blur-[9px] bg-glass-fill-l1', {
|
|
62
62
|
'pointer-events-none opacity-none': !active,
|
|
63
63
|
'pointer-events-auto opacity-full': active
|
|
64
64
|
}) }, "backdrop") }) })] }));
|