@nascentdigital/funnel-ui 4.6.7 → 5.0.2
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/client/fields/EmbeddedVideo/EmbeddedVideo.d.ts +2 -2
- package/dist/client/fields/EmbeddedVideo/EmbeddedVideo.js +3 -3
- package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.d.ts +3 -3
- package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.js +4 -3
- package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.d.ts +3 -3
- package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.js +4 -3
- package/dist/client/fields/LazyVideo.d.ts +5 -1
- package/dist/client/fields/LazyVideo.js +6 -4
- package/dist/client/hooks/useTouch.js +1 -0
- package/dist/client/interaction/paginator/Paginator.js +0 -1
- package/dist/server/blocks/Block.d.ts +87 -15
- package/dist/server/blocks/Block.js +785 -60
- package/dist/server/blocks/MediaLayout.d.ts +26 -10
- package/dist/server/blocks/MediaLayout.js +14 -23
- package/dist/server/blocks/Message.js +2 -2
- package/dist/server/blocks/RelatedPages.js +4 -4
- package/dist/server/blocks/index.d.ts +0 -1
- package/dist/server/blocks/index.js +0 -1
- package/dist/server/fields/Media.d.ts +50 -22
- package/dist/server/fields/Media.js +75 -48
- package/dist/server/fields/Visual.d.ts +6 -2
- package/dist/server/fields/Visual.js +9 -5
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/layouts/accordion/Accordion.d.ts +21 -0
- package/dist/server/layouts/accordion/Accordion.js +66 -0
- package/dist/server/layouts/accordion/AccordionContainer.d.ts +5 -0
- package/dist/server/layouts/accordion/AccordionContainer.js +18 -0
- package/dist/server/layouts/accordion/AccordionContext.d.ts +7 -0
- package/dist/server/layouts/accordion/AccordionContext.js +7 -0
- package/dist/server/layouts/accordion/AccordionExpander.d.ts +9 -0
- package/dist/server/layouts/accordion/AccordionExpander.js +72 -0
- package/dist/server/layouts/accordion/AccordionItem.d.ts +8 -0
- package/dist/server/layouts/accordion/AccordionItem.js +22 -0
- package/dist/server/layouts/accordion/AccordionLayout.d.ts +7 -0
- package/dist/server/layouts/accordion/AccordionLayout.js +26 -0
- package/dist/server/layouts/accordion/AccordionOptions.d.ts +3 -0
- package/dist/server/layouts/accordion/AccordionOptions.js +2 -0
- package/dist/server/layouts/accordion/index.d.ts +3 -0
- package/dist/server/layouts/accordion/index.js +19 -0
- package/dist/server/layouts/accordion/useAccordion.d.ts +1 -0
- package/dist/server/layouts/accordion/useAccordion.js +34 -0
- package/dist/server/layouts/index.d.ts +2 -1
- package/dist/server/layouts/index.js +2 -1
- package/dist/server/panels/BlockPanel.d.ts +14 -80
- package/dist/server/panels/BlockPanel.js +46 -707
- package/dist/server/panels/ListPanel.js +6 -3
- package/dist/server/panels/MessagePanel.js +33 -33
- package/dist/server/panels/VisualPanel.d.ts +58 -10
- package/dist/server/panels/VisualPanel.js +155 -79
- package/dist/server/schema/ListPanelLayout.d.ts +1 -0
- package/dist/server/schema/ListPanelLayout.js +1 -0
- package/dist/styles/blocks/Block-layout.css +81 -80
- package/dist/styles/blocks/Editorial.css +2 -2
- package/dist/styles/blocks/Form.css +2 -2
- package/dist/styles/blocks/MediaLayout.css +1 -1
- package/dist/styles/components/container.css +3 -24
- package/dist/styles/layouts/Accordion.css +29 -0
- package/dist/styles/layouts/_index.css +2 -1
- package/dist/styles/panels/VisualPanel.css +2 -1
- package/package.json +2 -2
- package/dist/server/blocks/Editorial.d.ts +0 -33
- package/dist/server/blocks/Editorial.js +0 -80
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import { Schema } from '@nascentdigital/funnel-core';
|
|
2
|
-
import { ComponentProps
|
|
3
|
-
import {
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { Media } from '../fields';
|
|
4
4
|
import { Block } from './Block';
|
|
5
|
-
export declare function MediaLayout({
|
|
5
|
+
export declare function MediaLayout({ ...props }: MediaLayout.Props): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare namespace MediaLayout {
|
|
7
7
|
const Component: import("react").FunctionComponent<Block.Create.Result.ComponentProps<"_nd-mediaLayout", true, undefined, Schema.ListField<{
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
media: Schema.CollectionField<Schema.Collection<{
|
|
9
|
+
image: Schema.AssetField<Schema.AssetField.LinkedValue.Image>;
|
|
10
|
+
mobileImage: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Image>>;
|
|
11
|
+
}> | Schema.Collection<{
|
|
12
|
+
video: Schema.ObjectField<{
|
|
13
|
+
type: Schema.EnumField<Schema.EnumField.Options<Media.Video.Source.Type>>;
|
|
14
|
+
local: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Video>>;
|
|
15
|
+
remote: Schema.Optional<Schema.EmbeddedVideoField>;
|
|
16
|
+
}>;
|
|
17
|
+
cover: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Image>>;
|
|
18
|
+
}>>;
|
|
10
19
|
}>, Schema.Block.Config, any>>, schema: Block.Create.Result.Schema<"_nd-mediaLayout", true, undefined, Schema.ListField<{
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
media: Schema.CollectionField<Schema.Collection<{
|
|
21
|
+
image: Schema.AssetField<Schema.AssetField.LinkedValue.Image>;
|
|
22
|
+
mobileImage: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Image>>;
|
|
23
|
+
}> | Schema.Collection<{
|
|
24
|
+
video: Schema.ObjectField<{
|
|
25
|
+
type: Schema.EnumField<Schema.EnumField.Options<Media.Video.Source.Type>>;
|
|
26
|
+
local: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Video>>;
|
|
27
|
+
remote: Schema.Optional<Schema.EmbeddedVideoField>;
|
|
28
|
+
}>;
|
|
29
|
+
cover: Schema.Optional<Schema.AssetField<Schema.AssetField.LinkedValue.Image>>;
|
|
30
|
+
}>>;
|
|
13
31
|
}>, Schema.Block.Config>;
|
|
14
32
|
type Model = Schema.Block.LinkedData<typeof schema>;
|
|
15
|
-
type Props = Omit<ComponentProps<typeof Component>, 'children'
|
|
16
|
-
EmbeddedVideoElement?: JSXElementConstructor<EmbeddedVideo.Props>;
|
|
17
|
-
};
|
|
33
|
+
type Props = Omit<ComponentProps<typeof Component>, 'children'>;
|
|
18
34
|
}
|
|
@@ -14,19 +14,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.MediaLayout = MediaLayout;
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
17
|
-
const refs_1 = require("../../client/refs");
|
|
18
17
|
const fields_1 = require("../fields");
|
|
19
|
-
const panels_1 = require("../panels");
|
|
20
18
|
const Block_1 = require("./Block");
|
|
21
19
|
// block
|
|
22
20
|
function MediaLayout(_a) {
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)(MediaLayout.Component, Object.assign({}, props, { children: ({ item }) => (0, jsx_runtime_1.jsx)("div", { className: "nd-MediaLayout-itemWrap", children: funnel_core_1.Schema.EmbeddedVideoField.Value.filter(item.value)
|
|
26
|
-
?
|
|
27
|
-
(0, jsx_runtime_1.jsx)(EmbeddedVideoElement, { className: "nd-MediaLayout-item", video: item.value })
|
|
28
|
-
:
|
|
29
|
-
(0, jsx_runtime_1.jsx)(fields_1.Visual, { className: "nd-MediaLayout-item", visual: item.value }) }) })));
|
|
21
|
+
var props = __rest(_a, []);
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(MediaLayout.Component, Object.assign({}, props));
|
|
30
23
|
}
|
|
31
24
|
// extension
|
|
32
25
|
(function (MediaLayout) {
|
|
@@ -38,19 +31,17 @@ function MediaLayout(_a) {
|
|
|
38
31
|
version: 1,
|
|
39
32
|
className: 'nd-MediaLayout',
|
|
40
33
|
message: true,
|
|
41
|
-
list:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
max: 20
|
|
54
|
-
})
|
|
34
|
+
list: {
|
|
35
|
+
schema: funnel_core_1.Schema.Field.list({
|
|
36
|
+
name: 'Assets',
|
|
37
|
+
description: 'Add one or more assets and then configure the layout.',
|
|
38
|
+
itemTypes: {
|
|
39
|
+
media: fields_1.Media.schema
|
|
40
|
+
},
|
|
41
|
+
min: 1,
|
|
42
|
+
max: 20
|
|
43
|
+
}),
|
|
44
|
+
renderItem: ({ item }) => ((0, jsx_runtime_1.jsx)("div", { className: "nd-MediaLayout-itemWrap", children: (0, jsx_runtime_1.jsx)(fields_1.Media, { className: "nd-MediaLayout-item", media: item.value }) }))
|
|
45
|
+
}
|
|
55
46
|
}), MediaLayout.Component = _a.Component, MediaLayout.schema = _a.schema;
|
|
56
47
|
})(MediaLayout || (exports.MediaLayout = MediaLayout = {}));
|
|
@@ -19,14 +19,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
19
19
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
20
20
|
const classnames_1 = __importDefault(require("classnames"));
|
|
21
21
|
const Block_1 = require("./Block");
|
|
22
|
-
//
|
|
22
|
+
// block
|
|
23
23
|
function Message(_a) {
|
|
24
24
|
var _b;
|
|
25
25
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
26
26
|
// extract variant
|
|
27
27
|
const variant = funnel_core_1.Schema.EnumField.Value.fromData((_b = props.model) === null || _b === void 0 ? void 0 : _b.config.variant);
|
|
28
28
|
// render
|
|
29
|
-
return (0, jsx_runtime_1.jsx)(Message.Component, Object.assign({ className: (0, classnames_1.default)(className, 'nd-Message', Message.Variant.getClassName(variant)) }, props));
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(Message.Component, Object.assign({ className: (0, classnames_1.default)(className, 'nd-Message', Message.Variant.getClassName(variant)) }, props)));
|
|
30
30
|
}
|
|
31
31
|
// extension
|
|
32
32
|
(function (Message) {
|
|
@@ -39,7 +39,7 @@ function RelatedPages(_a) {
|
|
|
39
39
|
const ctas = ctasRaw === null || ctasRaw === void 0 ? void 0 : ctasRaw.value;
|
|
40
40
|
const pages = (_e = (_d = listRaw === null || listRaw === void 0 ? void 0 : listRaw.value) === null || _d === void 0 ? void 0 : _d.pages) !== null && _e !== void 0 ? _e : [];
|
|
41
41
|
// panel layout
|
|
42
|
-
const layout =
|
|
42
|
+
const layout = Block_1.Block.getLayout({
|
|
43
43
|
args: { fields, config },
|
|
44
44
|
messageKey: 'message',
|
|
45
45
|
listKey: 'list'
|
|
@@ -69,7 +69,7 @@ function RelatedPages(_a) {
|
|
|
69
69
|
size
|
|
70
70
|
}) });
|
|
71
71
|
}
|
|
72
|
-
const configSchema =
|
|
72
|
+
const configSchema = Block_1.Block.getConfigSchema({
|
|
73
73
|
fields: fieldsSchema({ pageType: 'any', size: 0 }),
|
|
74
74
|
messageKey: 'message',
|
|
75
75
|
listKey: 'list'
|
|
@@ -81,12 +81,12 @@ function RelatedPages(_a) {
|
|
|
81
81
|
version: 1,
|
|
82
82
|
fields: fieldsSchema(args),
|
|
83
83
|
config: configSchema,
|
|
84
|
-
getConfig: args =>
|
|
84
|
+
getConfig: args => Block_1.Block.getConfig({
|
|
85
85
|
args,
|
|
86
86
|
messageKey: 'message',
|
|
87
87
|
listKey: 'list'
|
|
88
88
|
}),
|
|
89
|
-
getLayout: args =>
|
|
89
|
+
getLayout: args => Block_1.Block.getLayout({
|
|
90
90
|
args,
|
|
91
91
|
messageKey: 'message',
|
|
92
92
|
listKey: 'list'
|
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Block"), exports);
|
|
18
|
-
__exportStar(require("./Editorial"), exports);
|
|
19
18
|
__exportStar(require("./Form"), exports);
|
|
20
19
|
__exportStar(require("./FormMessage"), exports);
|
|
21
20
|
__exportStar(require("./MediaLayout"), exports);
|
|
@@ -3,49 +3,77 @@ import { Visual } from './Visual';
|
|
|
3
3
|
export declare function Media({ className, media, ...props }: Media.Props): import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
export declare namespace Media {
|
|
5
5
|
namespace Image {
|
|
6
|
-
const
|
|
6
|
+
const collection: SchemaCore.Collection<{
|
|
7
7
|
image: SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>;
|
|
8
8
|
mobileImage: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
|
|
9
9
|
}>;
|
|
10
|
-
type
|
|
11
|
-
type Value = SchemaCore.Collection.
|
|
10
|
+
type Collection = typeof collection;
|
|
11
|
+
type Value = SchemaCore.Collection.Data<Collection>;
|
|
12
|
+
type LinkedValue = SchemaCore.Collection.LinkedData<Collection>;
|
|
12
13
|
}
|
|
13
14
|
namespace Video {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
namespace Source {
|
|
16
|
+
type Type = 'local' | 'remote';
|
|
17
|
+
const schema: SchemaCore.ObjectField<{
|
|
18
|
+
type: SchemaCore.EnumField<SchemaCore.EnumField.Options<Type>>;
|
|
19
|
+
local: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Video>>;
|
|
20
|
+
remote: SchemaCore.Optional<SchemaCore.EmbeddedVideoField>;
|
|
21
|
+
}>;
|
|
22
|
+
type Schema = typeof schema;
|
|
23
|
+
type Value = SchemaCore.Field.Value<Schema>;
|
|
24
|
+
type LinkedValue = SchemaCore.Field.LinkedValue<Schema>;
|
|
25
|
+
type LocalSchema = SchemaCore.Optional.InnerType<Schema['content']['local']>;
|
|
26
|
+
type RemoteSchema = SchemaCore.Optional.InnerType<Schema['content']['remote']>;
|
|
27
|
+
}
|
|
28
|
+
const collection: SchemaCore.Collection<{
|
|
29
|
+
video: SchemaCore.ObjectField<{
|
|
30
|
+
type: SchemaCore.EnumField<SchemaCore.EnumField.Options<Source.Type>>;
|
|
31
|
+
local: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Video>>;
|
|
32
|
+
remote: SchemaCore.Optional<SchemaCore.EmbeddedVideoField>;
|
|
33
|
+
}>;
|
|
16
34
|
cover: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
|
|
17
35
|
}>;
|
|
18
|
-
type
|
|
19
|
-
type Value = SchemaCore.Collection.
|
|
20
|
-
|
|
21
|
-
namespace StreamingVideo {
|
|
22
|
-
const schema: SchemaCore.Collection<{
|
|
23
|
-
video: SchemaCore.EmbeddedVideoField;
|
|
24
|
-
cover: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
|
|
25
|
-
}>;
|
|
26
|
-
type Schema = typeof schema;
|
|
27
|
-
type Value = SchemaCore.Collection.LinkedData<Schema>;
|
|
36
|
+
type Collection = typeof collection;
|
|
37
|
+
type Value = SchemaCore.Collection.Data<Collection>;
|
|
38
|
+
type LinkedValue = SchemaCore.Collection.LinkedData<Collection>;
|
|
28
39
|
}
|
|
29
40
|
const schema: SchemaCore.CollectionField<SchemaCore.Collection<{
|
|
30
41
|
image: SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>;
|
|
31
42
|
mobileImage: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
|
|
32
43
|
}> | SchemaCore.Collection<{
|
|
33
|
-
video: SchemaCore.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
video: SchemaCore.ObjectField<{
|
|
45
|
+
type: SchemaCore.EnumField<SchemaCore.EnumField.Options<Video.Source.Type>>;
|
|
46
|
+
local: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Video>>;
|
|
47
|
+
remote: SchemaCore.Optional<SchemaCore.EmbeddedVideoField>;
|
|
48
|
+
}>;
|
|
37
49
|
cover: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
|
|
38
50
|
}>>;
|
|
39
51
|
type Schema = typeof schema;
|
|
40
|
-
|
|
52
|
+
namespace Schema {
|
|
53
|
+
function filter(value: SchemaCore.CollectionField): value is Media.Schema;
|
|
54
|
+
}
|
|
55
|
+
type Collection = Image.Collection | Video.Collection;
|
|
56
|
+
type Data = SchemaCore.Field.Data<Schema>;
|
|
57
|
+
type Value = Data['value'];
|
|
41
58
|
namespace Value {
|
|
59
|
+
function filter(value: any): value is Value;
|
|
42
60
|
function isImage(value: Value): value is Image.Value;
|
|
43
61
|
function isVideo(value: Value): value is Video.Value;
|
|
44
|
-
|
|
62
|
+
}
|
|
63
|
+
type LinkedData = SchemaCore.Field.LinkedData<Schema>;
|
|
64
|
+
type LinkedValue = LinkedData['value'];
|
|
65
|
+
namespace LinkedValue {
|
|
66
|
+
function filter(value: any): value is LinkedValue;
|
|
67
|
+
function isImage(value: LinkedValue): value is Image.LinkedValue;
|
|
68
|
+
function isVideo(value: LinkedValue): value is Video.LinkedValue;
|
|
45
69
|
}
|
|
46
70
|
type Props = {
|
|
47
71
|
className?: string;
|
|
48
|
-
media?:
|
|
72
|
+
media?: LinkedValue;
|
|
49
73
|
loading?: Visual.Loading;
|
|
74
|
+
controls?: boolean;
|
|
75
|
+
autoPlay?: boolean;
|
|
76
|
+
loop?: boolean;
|
|
77
|
+
mute?: boolean;
|
|
50
78
|
};
|
|
51
79
|
}
|
|
@@ -18,7 +18,6 @@ exports.Media = Media;
|
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
20
20
|
const classnames_1 = __importDefault(require("classnames"));
|
|
21
|
-
const refs_1 = require("../../client/refs");
|
|
22
21
|
const Visual_1 = require("./Visual");
|
|
23
22
|
// component
|
|
24
23
|
function Media(_a) {
|
|
@@ -30,20 +29,16 @@ function Media(_a) {
|
|
|
30
29
|
// or render image
|
|
31
30
|
let mediaClassName = undefined;
|
|
32
31
|
let content;
|
|
33
|
-
if (Media.
|
|
32
|
+
if (Media.LinkedValue.isImage(media)) {
|
|
34
33
|
mediaClassName = 'nd-Media-image';
|
|
35
34
|
content = renderImage(Object.assign({ media }, props));
|
|
36
35
|
}
|
|
37
36
|
// or render video
|
|
38
|
-
else if (Media.
|
|
37
|
+
else if (Media.LinkedValue.isVideo(media)) {
|
|
38
|
+
// handle streaming video
|
|
39
39
|
mediaClassName = 'nd-Media-video';
|
|
40
40
|
content = renderVideo(Object.assign({ media }, props));
|
|
41
41
|
}
|
|
42
|
-
// or render streaming video
|
|
43
|
-
else if (Media.Value.isStreamingVideo(media)) {
|
|
44
|
-
mediaClassName = 'nd-Media-streamingVideo';
|
|
45
|
-
content = renderStreamingVideo(Object.assign({ media }, props));
|
|
46
|
-
}
|
|
47
42
|
// or indicate error
|
|
48
43
|
else {
|
|
49
44
|
content = null;
|
|
@@ -56,69 +51,106 @@ function Media(_a) {
|
|
|
56
51
|
// media types
|
|
57
52
|
let Image;
|
|
58
53
|
(function (Image) {
|
|
59
|
-
//
|
|
60
|
-
Image.
|
|
54
|
+
// collection
|
|
55
|
+
Image.collection = funnel_core_1.Schema.Collection.create({
|
|
61
56
|
type: '_nd-Media-image',
|
|
62
57
|
name: 'Image',
|
|
63
58
|
description: 'Image content for your website',
|
|
64
59
|
version: 1,
|
|
65
60
|
fields: {
|
|
66
|
-
image: funnel_core_1.Schema.Field.image({ name: 'Primary' }),
|
|
67
|
-
mobileImage: funnel_core_1.Schema.Field.image({ name: 'Mobile
|
|
61
|
+
image: funnel_core_1.Schema.Field.image({ name: 'Primary Image' }),
|
|
62
|
+
mobileImage: funnel_core_1.Schema.Field.image({ name: 'Mobile Image' }).optional()
|
|
68
63
|
}
|
|
69
64
|
});
|
|
70
65
|
})(Image = Media.Image || (Media.Image = {}));
|
|
71
66
|
let Video;
|
|
72
67
|
(function (Video) {
|
|
68
|
+
// source
|
|
69
|
+
let Source;
|
|
70
|
+
(function (Source) {
|
|
71
|
+
// schema
|
|
72
|
+
Source.schema = funnel_core_1.Schema.Field.object({
|
|
73
|
+
name: 'Video Source',
|
|
74
|
+
description: 'Represents local/remote video source',
|
|
75
|
+
preview: { title: 'type' },
|
|
76
|
+
content: {
|
|
77
|
+
type: funnel_core_1.Schema.Field.enumeration({
|
|
78
|
+
name: 'Type',
|
|
79
|
+
options: {
|
|
80
|
+
local: { name: 'Local' },
|
|
81
|
+
remote: { name: 'Remote' }
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
local: funnel_core_1.Schema.Field.video({ name: 'Local Video' }).optional(),
|
|
85
|
+
remote: funnel_core_1.Schema.Field.embeddedVideo({ name: 'Remote Video' }).optional()
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
})(Source = Video.Source || (Video.Source = {}));
|
|
73
89
|
// schema
|
|
74
|
-
Video.
|
|
90
|
+
Video.collection = funnel_core_1.Schema.Collection.create({
|
|
75
91
|
type: '_nd-Media-video',
|
|
76
|
-
name: '
|
|
92
|
+
name: 'Video',
|
|
77
93
|
description: 'Small, decorative background video content',
|
|
78
94
|
version: 1,
|
|
79
95
|
fields: {
|
|
80
|
-
video:
|
|
96
|
+
video: Source.schema,
|
|
81
97
|
cover: funnel_core_1.Schema.Field.image({ name: 'Cover' }).optional()
|
|
82
98
|
}
|
|
83
99
|
});
|
|
84
100
|
})(Video = Media.Video || (Media.Video = {}));
|
|
85
|
-
let StreamingVideo;
|
|
86
|
-
(function (StreamingVideo) {
|
|
87
|
-
// schema
|
|
88
|
-
StreamingVideo.schema = funnel_core_1.Schema.Collection.create({
|
|
89
|
-
type: '_nd-Media-streamingVideo',
|
|
90
|
-
name: 'Remote Video',
|
|
91
|
-
description: 'Remove streaming video content (Youtube and Vimeo)',
|
|
92
|
-
version: 1,
|
|
93
|
-
fields: {
|
|
94
|
-
video: funnel_core_1.Schema.Field.embeddedVideo({ name: 'Video' }),
|
|
95
|
-
cover: funnel_core_1.Schema.Field.image({ name: 'Cover' }).optional()
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
})(StreamingVideo = Media.StreamingVideo || (Media.StreamingVideo = {}));
|
|
99
101
|
// schema
|
|
100
102
|
Media.schema = funnel_core_1.Schema.Field.collection({
|
|
101
103
|
name: 'Media',
|
|
102
104
|
description: 'Image, video, or streaming video content',
|
|
103
|
-
hint: 'Add and configure
|
|
104
|
-
collections: [Image.
|
|
105
|
+
hint: 'Add and configure an image or video',
|
|
106
|
+
collections: [Image.collection, Video.collection]
|
|
105
107
|
});
|
|
108
|
+
let Schema;
|
|
109
|
+
(function (Schema) {
|
|
110
|
+
function filter(value) {
|
|
111
|
+
return value.type === 'collection'
|
|
112
|
+
&& value.collections.every(schema => schema.type === Image.collection.type || schema.type === Video.collection.type);
|
|
113
|
+
}
|
|
114
|
+
Schema.filter = filter;
|
|
115
|
+
})(Schema = Media.Schema || (Media.Schema = {}));
|
|
106
116
|
let Value;
|
|
107
117
|
(function (Value) {
|
|
108
118
|
// helpers
|
|
119
|
+
function filter(value) {
|
|
120
|
+
return !!value
|
|
121
|
+
&& typeof value === 'object' && !Array.isArray(value)
|
|
122
|
+
&& 'type' in value && typeof value.type === 'string'
|
|
123
|
+
&& (value.type === Image.collection.type || value.type === Video.collection.type);
|
|
124
|
+
}
|
|
125
|
+
Value.filter = filter;
|
|
109
126
|
function isImage(value) {
|
|
110
|
-
return value.type === Image.
|
|
127
|
+
return value.type === Image.collection.type;
|
|
111
128
|
}
|
|
112
129
|
Value.isImage = isImage;
|
|
113
130
|
function isVideo(value) {
|
|
114
|
-
return value.type === Video.
|
|
131
|
+
return value.type === Video.collection.type;
|
|
115
132
|
}
|
|
116
133
|
Value.isVideo = isVideo;
|
|
117
|
-
function isStreamingVideo(value) {
|
|
118
|
-
return value.type === StreamingVideo.schema.type;
|
|
119
|
-
}
|
|
120
|
-
Value.isStreamingVideo = isStreamingVideo;
|
|
121
134
|
})(Value = Media.Value || (Media.Value = {}));
|
|
135
|
+
let LinkedValue;
|
|
136
|
+
(function (LinkedValue) {
|
|
137
|
+
// helpers
|
|
138
|
+
function filter(value) {
|
|
139
|
+
return !!value
|
|
140
|
+
&& typeof value === 'object' && !Array.isArray(value)
|
|
141
|
+
&& 'type' in value && typeof value.type === 'string'
|
|
142
|
+
&& (value.type === Image.collection.type || value.type === Video.collection.type);
|
|
143
|
+
}
|
|
144
|
+
LinkedValue.filter = filter;
|
|
145
|
+
function isImage(value) {
|
|
146
|
+
return value.type === Image.collection.type;
|
|
147
|
+
}
|
|
148
|
+
LinkedValue.isImage = isImage;
|
|
149
|
+
function isVideo(value) {
|
|
150
|
+
return value.type === Video.collection.type;
|
|
151
|
+
}
|
|
152
|
+
LinkedValue.isVideo = isVideo;
|
|
153
|
+
})(LinkedValue = Media.LinkedValue || (Media.LinkedValue = {}));
|
|
122
154
|
})(Media || (exports.Media = Media = {}));
|
|
123
155
|
function renderImage({ media, loading }) {
|
|
124
156
|
// bind props
|
|
@@ -129,19 +161,14 @@ function renderImage({ media, loading }) {
|
|
|
129
161
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Visual_1.Visual, { className: "nd-Media-image-desktop", visual: image, loading: loading }), mobileImage &&
|
|
130
162
|
(0, jsx_runtime_1.jsx)(Visual_1.Visual, { className: "nd-Media-image-mobile", visual: mobileImage, loading: loading })] }));
|
|
131
163
|
}
|
|
132
|
-
function renderVideo({ media, loading }) {
|
|
133
|
-
|
|
134
|
-
const { video: videoRaw, cover: coverRaw } = media.fields;
|
|
135
|
-
const video = videoRaw === null || videoRaw === void 0 ? void 0 : videoRaw.value;
|
|
136
|
-
const cover = coverRaw === null || coverRaw === void 0 ? void 0 : coverRaw.value;
|
|
137
|
-
// render
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)(Visual_1.Visual, { className: "nd-Media-video-player", visual: video, loading: loading, cover: cover }));
|
|
139
|
-
}
|
|
140
|
-
function renderStreamingVideo({ media, loading }) {
|
|
164
|
+
function renderVideo({ media, loading, controls, autoPlay, loop, mute }) {
|
|
165
|
+
var _a, _b, _c, _d;
|
|
141
166
|
// bind props
|
|
142
167
|
const { video: videoRaw, cover: coverRaw } = media.fields;
|
|
143
|
-
const video = videoRaw === null || videoRaw === void 0 ? void 0 : videoRaw.value;
|
|
168
|
+
const { value: video } = (_d = (_b = (_a = videoRaw === null || videoRaw === void 0 ? void 0 : videoRaw.value) === null || _a === void 0 ? void 0 : _a.local) !== null && _b !== void 0 ? _b : (_c = videoRaw === null || videoRaw === void 0 ? void 0 : videoRaw.value) === null || _c === void 0 ? void 0 : _c.remote) !== null && _d !== void 0 ? _d : {};
|
|
144
169
|
const cover = coverRaw === null || coverRaw === void 0 ? void 0 : coverRaw.value;
|
|
145
170
|
// render
|
|
146
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
171
|
+
return ((0, jsx_runtime_1.jsx)(Visual_1.Visual, { className: (0, classnames_1.default)('nd-Media-video-player', {
|
|
172
|
+
'': media.type === ''
|
|
173
|
+
}), visual: video, loading: loading, cover: cover, controls: controls, autoPlay: autoPlay, loop: loop, muted: mute }));
|
|
147
174
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Schema } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { HTMLAttributes } from 'react';
|
|
3
|
-
export declare function Visual({ className, visual, cover, loading, ...props }: Visual.Props): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare function Visual({ className, visual, cover, loading, controls, autoPlay, loop, muted, ...props }: Visual.Props): import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
export declare namespace Visual {
|
|
5
5
|
const schema: Schema.AssetField<Schema.AssetField.LinkedValue.Visual>;
|
|
6
6
|
type Props = Omit<HTMLAttributes<HTMLImageElement> & HTMLAttributes<HTMLVideoElement>, 'children'> & {
|
|
7
|
-
visual?: Model;
|
|
7
|
+
visual?: Model | Schema.EmbeddedVideoField.Value;
|
|
8
8
|
cover?: Schema.AssetField.LinkedValue.Image;
|
|
9
9
|
loading?: Loading;
|
|
10
|
+
controls?: boolean;
|
|
11
|
+
autoPlay?: boolean;
|
|
12
|
+
loop?: boolean;
|
|
13
|
+
muted?: boolean;
|
|
10
14
|
};
|
|
11
15
|
type Model = Schema.Field.LinkedValue<typeof schema>;
|
|
12
16
|
type Loading = 'eager' | 'lazy';
|
|
@@ -22,18 +22,22 @@ const image_1 = __importDefault(require("next/image"));
|
|
|
22
22
|
const refs_1 = require("../../client/refs");
|
|
23
23
|
// component
|
|
24
24
|
function Visual(_a) {
|
|
25
|
-
var { className, visual, cover, loading = 'lazy' } = _a, props = __rest(_a, ["className", "visual", "cover", "loading"]);
|
|
25
|
+
var { className, visual, cover, loading = 'lazy', controls = true, autoPlay = false, loop = false, muted = false } = _a, props = __rest(_a, ["className", "visual", "cover", "loading", "controls", "autoPlay", "loop", "muted"]);
|
|
26
26
|
// skip if not set
|
|
27
27
|
if (!visual) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
+
// handle embedded videos
|
|
31
|
+
else if (funnel_core_1.Schema.EmbeddedVideoField.Value.filter(visual)) {
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(refs_1.EmbeddedVideo, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-video'), video: visual, controls: controls, autoPlay: autoPlay, muted: muted }));
|
|
33
|
+
}
|
|
30
34
|
// or error if not a visual
|
|
31
35
|
else if (!funnel_core_1.Schema.AssetField.LinkedValue.Visual.filter(visual)) {
|
|
32
36
|
return ((0, jsx_runtime_1.jsx)("span", { children: "Invalid media!" }));
|
|
33
37
|
}
|
|
34
38
|
// or render image
|
|
35
39
|
else if (funnel_core_1.Schema.AssetField.LinkedValue.Image.filter(visual)) {
|
|
36
|
-
const { url, description = '', metadata: {
|
|
40
|
+
const { url, description = '', metadata: { dimensions } = {} } = visual !== null && visual !== void 0 ? visual : {};
|
|
37
41
|
const { width, height } = dimensions !== null && dimensions !== void 0 ? dimensions : {};
|
|
38
42
|
return ((0, jsx_runtime_1.jsx)(image_1.default, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-image'), src: url, alt: description !== null && description !== void 0 ? description : '', width: dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, height: dimensions === null || dimensions === void 0 ? void 0 : dimensions.height, loading: loading, draggable: false, style: {
|
|
39
43
|
'--_nd-visual-native-width': width ? `${width}` : '1',
|
|
@@ -42,16 +46,16 @@ function Visual(_a) {
|
|
|
42
46
|
}
|
|
43
47
|
// or render lazy
|
|
44
48
|
else if (loading === 'eager') {
|
|
45
|
-
const { type, url, metadata: {
|
|
49
|
+
const { type, url, metadata: { dimensions } = {} } = visual !== null && visual !== void 0 ? visual : {};
|
|
46
50
|
const { width, height } = dimensions !== null && dimensions !== void 0 ? dimensions : {};
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)("video", Object.assign({}, props, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-video'), autoPlay:
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)("video", Object.assign({}, props, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-video'), controls: controls, autoPlay: autoPlay, muted: muted, loop: loop, playsInline: true, poster: cover === null || cover === void 0 ? void 0 : cover.url, style: {
|
|
48
52
|
'--_nd-visual-native-width': width ? `${width}` : '1',
|
|
49
53
|
'--_nd-visual-native-height': height ? `${height}` : '1'
|
|
50
54
|
}, children: (0, jsx_runtime_1.jsx)("source", { src: url, type: type }) })));
|
|
51
55
|
}
|
|
52
56
|
// or render image
|
|
53
57
|
else {
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(refs_1.LazyVideo, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-video'), video: visual, poster: cover === null || cover === void 0 ? void 0 : cover.url })));
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(refs_1.LazyVideo, Object.assign({}, props, { className: (0, classnames_1.default)(className, 'nd-Visual nd-Visual-video'), controls: controls, autoPlay: autoPlay, muted: muted, loop: loop, video: visual, poster: cover === null || cover === void 0 ? void 0 : cover.url })));
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
// extension
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./atomic"), exports);
|
|
|
18
18
|
__exportStar(require("./blocks"), exports);
|
|
19
19
|
__exportStar(require("./data"), exports);
|
|
20
20
|
__exportStar(require("./fields"), exports);
|
|
21
|
+
__exportStar(require("./layouts"), exports);
|
|
21
22
|
__exportStar(require("./panels"), exports);
|
|
22
23
|
__exportStar(require("./schema"), exports);
|
|
23
24
|
__exportStar(require("./sections"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
|
+
import { AccordionOptions } from './AccordionOptions';
|
|
3
|
+
export declare class Accordion {
|
|
4
|
+
private readonly _expanded$;
|
|
5
|
+
private readonly _focused$;
|
|
6
|
+
readonly multiExpand: boolean;
|
|
7
|
+
constructor({ multiExpand }?: Accordion.ConstructorArgs);
|
|
8
|
+
get expanded$(): import("rxjs").Observable<readonly Accordion.Id[]>;
|
|
9
|
+
get expanded(): readonly Accordion.Id[];
|
|
10
|
+
get focused$(): import("rxjs").Observable<Accordion.Id | undefined>;
|
|
11
|
+
get focused(): Accordion.Id | undefined;
|
|
12
|
+
isExpanded(accordionId: Accordion.Id): boolean;
|
|
13
|
+
onExpand(accordionId: Accordion.Id): void;
|
|
14
|
+
onCollapse(accordionId: Accordion.Id): void;
|
|
15
|
+
onFocus(accordionId: Accordion.Id): void;
|
|
16
|
+
onBlur(accordionId: Accordion.Id): void;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace Accordion {
|
|
19
|
+
type Id = Tagged<string, 'Accordion.Id'>;
|
|
20
|
+
type ConstructorArgs = Partial<AccordionOptions>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Accordion = void 0;
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
// class
|
|
7
|
+
class Accordion {
|
|
8
|
+
constructor({ multiExpand = false } = {}) {
|
|
9
|
+
// initialize instance variables
|
|
10
|
+
this._expanded$ = new rxjs_1.BehaviorSubject([]);
|
|
11
|
+
this._focused$ = new rxjs_1.BehaviorSubject(undefined);
|
|
12
|
+
this.multiExpand = multiExpand;
|
|
13
|
+
}
|
|
14
|
+
get expanded$() {
|
|
15
|
+
return this._expanded$.asObservable();
|
|
16
|
+
}
|
|
17
|
+
get expanded() {
|
|
18
|
+
return this._expanded$.value;
|
|
19
|
+
}
|
|
20
|
+
get focused$() {
|
|
21
|
+
return this._focused$.asObservable();
|
|
22
|
+
}
|
|
23
|
+
get focused() {
|
|
24
|
+
return this._focused$.value;
|
|
25
|
+
}
|
|
26
|
+
isExpanded(accordionId) {
|
|
27
|
+
return this.expanded.includes(accordionId);
|
|
28
|
+
}
|
|
29
|
+
onExpand(accordionId) {
|
|
30
|
+
// skip if already expanded
|
|
31
|
+
const { expanded, multiExpand } = this;
|
|
32
|
+
if (expanded.includes(accordionId)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// add to expanded if multi-expand is enabled
|
|
36
|
+
if (multiExpand) {
|
|
37
|
+
this._expanded$.next([...expanded, accordionId]);
|
|
38
|
+
}
|
|
39
|
+
// otherwise, replace
|
|
40
|
+
else {
|
|
41
|
+
this._expanded$.next([accordionId]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
onCollapse(accordionId) {
|
|
45
|
+
// skip if not expanded
|
|
46
|
+
const { expanded, multiExpand } = this;
|
|
47
|
+
if (!expanded.includes(accordionId)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// update by stripping out id from list
|
|
51
|
+
this._expanded$.next(expanded.filter(id => id !== accordionId));
|
|
52
|
+
}
|
|
53
|
+
onFocus(accordionId) {
|
|
54
|
+
// update if not already focused
|
|
55
|
+
if (this.focused !== accordionId) {
|
|
56
|
+
this._focused$.next(accordionId);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onBlur(accordionId) {
|
|
60
|
+
// update if id was in focus
|
|
61
|
+
if (this.focused === accordionId) {
|
|
62
|
+
this._focused$.next(undefined);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Accordion = Accordion;
|