@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.
Files changed (63) hide show
  1. package/dist/client/fields/EmbeddedVideo/EmbeddedVideo.d.ts +2 -2
  2. package/dist/client/fields/EmbeddedVideo/EmbeddedVideo.js +3 -3
  3. package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.d.ts +3 -3
  4. package/dist/client/fields/EmbeddedVideo/vimeo/VimeoVideo.js +4 -3
  5. package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.d.ts +3 -3
  6. package/dist/client/fields/EmbeddedVideo/youtube/YoutubeVideo.js +4 -3
  7. package/dist/client/fields/LazyVideo.d.ts +5 -1
  8. package/dist/client/fields/LazyVideo.js +6 -4
  9. package/dist/client/hooks/useTouch.js +1 -0
  10. package/dist/client/interaction/paginator/Paginator.js +0 -1
  11. package/dist/server/blocks/Block.d.ts +87 -15
  12. package/dist/server/blocks/Block.js +785 -60
  13. package/dist/server/blocks/MediaLayout.d.ts +26 -10
  14. package/dist/server/blocks/MediaLayout.js +14 -23
  15. package/dist/server/blocks/Message.js +2 -2
  16. package/dist/server/blocks/RelatedPages.js +4 -4
  17. package/dist/server/blocks/index.d.ts +0 -1
  18. package/dist/server/blocks/index.js +0 -1
  19. package/dist/server/fields/Media.d.ts +50 -22
  20. package/dist/server/fields/Media.js +75 -48
  21. package/dist/server/fields/Visual.d.ts +6 -2
  22. package/dist/server/fields/Visual.js +9 -5
  23. package/dist/server/index.d.ts +1 -0
  24. package/dist/server/index.js +1 -0
  25. package/dist/server/layouts/accordion/Accordion.d.ts +21 -0
  26. package/dist/server/layouts/accordion/Accordion.js +66 -0
  27. package/dist/server/layouts/accordion/AccordionContainer.d.ts +5 -0
  28. package/dist/server/layouts/accordion/AccordionContainer.js +18 -0
  29. package/dist/server/layouts/accordion/AccordionContext.d.ts +7 -0
  30. package/dist/server/layouts/accordion/AccordionContext.js +7 -0
  31. package/dist/server/layouts/accordion/AccordionExpander.d.ts +9 -0
  32. package/dist/server/layouts/accordion/AccordionExpander.js +72 -0
  33. package/dist/server/layouts/accordion/AccordionItem.d.ts +8 -0
  34. package/dist/server/layouts/accordion/AccordionItem.js +22 -0
  35. package/dist/server/layouts/accordion/AccordionLayout.d.ts +7 -0
  36. package/dist/server/layouts/accordion/AccordionLayout.js +26 -0
  37. package/dist/server/layouts/accordion/AccordionOptions.d.ts +3 -0
  38. package/dist/server/layouts/accordion/AccordionOptions.js +2 -0
  39. package/dist/server/layouts/accordion/index.d.ts +3 -0
  40. package/dist/server/layouts/accordion/index.js +19 -0
  41. package/dist/server/layouts/accordion/useAccordion.d.ts +1 -0
  42. package/dist/server/layouts/accordion/useAccordion.js +34 -0
  43. package/dist/server/layouts/index.d.ts +2 -1
  44. package/dist/server/layouts/index.js +2 -1
  45. package/dist/server/panels/BlockPanel.d.ts +14 -80
  46. package/dist/server/panels/BlockPanel.js +46 -707
  47. package/dist/server/panels/ListPanel.js +6 -3
  48. package/dist/server/panels/MessagePanel.js +33 -33
  49. package/dist/server/panels/VisualPanel.d.ts +58 -10
  50. package/dist/server/panels/VisualPanel.js +155 -79
  51. package/dist/server/schema/ListPanelLayout.d.ts +1 -0
  52. package/dist/server/schema/ListPanelLayout.js +1 -0
  53. package/dist/styles/blocks/Block-layout.css +81 -80
  54. package/dist/styles/blocks/Editorial.css +2 -2
  55. package/dist/styles/blocks/Form.css +2 -2
  56. package/dist/styles/blocks/MediaLayout.css +1 -1
  57. package/dist/styles/components/container.css +3 -24
  58. package/dist/styles/layouts/Accordion.css +29 -0
  59. package/dist/styles/layouts/_index.css +2 -1
  60. package/dist/styles/panels/VisualPanel.css +2 -1
  61. package/package.json +2 -2
  62. package/dist/server/blocks/Editorial.d.ts +0 -33
  63. package/dist/server/blocks/Editorial.js +0 -80
@@ -1,18 +1,34 @@
1
1
  import { Schema } from '@nascentdigital/funnel-core';
2
- import { ComponentProps, JSXElementConstructor } from 'react';
3
- import { EmbeddedVideo } from '../../client/refs';
2
+ import { ComponentProps } from 'react';
3
+ import { Media } from '../fields';
4
4
  import { Block } from './Block';
5
- export declare function MediaLayout({ EmbeddedVideoElement, ...props }: MediaLayout.Props): import("react/jsx-runtime").JSX.Element;
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
- visual: Schema.AssetField<Schema.AssetField.LinkedValue.Visual>;
9
- embedded: Schema.EmbeddedVideoField;
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
- visual: Schema.AssetField<Schema.AssetField.LinkedValue.Visual>;
12
- embedded: Schema.EmbeddedVideoField;
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 { EmbeddedVideoElement = refs_1.EmbeddedVideo } = _a, props = __rest(_a, ["EmbeddedVideoElement"]);
24
- // render
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: funnel_core_1.Schema.Field.list({
42
- name: 'Assets',
43
- description: 'Add one or more assets and then configure the layout.',
44
- itemTypes: {
45
- visual: panels_1.VisualPanel.Fields.visual.unwrap(),
46
- embedded: funnel_core_1.Schema.Field.embeddedVideo({
47
- name: 'Embedded Video',
48
- description: 'A remote streaming video (e.g. YouTube)',
49
- allowMuting: true
50
- })
51
- },
52
- min: 1,
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
- // component
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 = panels_1.BlockPanel.getLayout({
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 = panels_1.BlockPanel.getConfigSchema({
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 => panels_1.BlockPanel.getConfig({
84
+ getConfig: args => Block_1.Block.getConfig({
85
85
  args,
86
86
  messageKey: 'message',
87
87
  listKey: 'list'
88
88
  }),
89
- getLayout: args => panels_1.BlockPanel.getLayout({
89
+ getLayout: args => Block_1.Block.getLayout({
90
90
  args,
91
91
  messageKey: 'message',
92
92
  listKey: 'list'
@@ -1,5 +1,4 @@
1
1
  export * from './Block';
2
- export * from './Editorial';
3
2
  export * from './Form';
4
3
  export * from './FormMessage';
5
4
  export * from './MediaLayout';
@@ -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 schema: SchemaCore.Collection<{
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 Schema = typeof schema;
11
- type Value = SchemaCore.Collection.LinkedData<Schema>;
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
- const schema: SchemaCore.Collection<{
15
- video: SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Video>;
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 Schema = typeof schema;
19
- type Value = SchemaCore.Collection.LinkedData<Schema>;
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.AssetField<SchemaCore.AssetField.LinkedValue.Video>;
34
- cover: SchemaCore.Optional<SchemaCore.AssetField<SchemaCore.AssetField.LinkedValue.Image>>;
35
- }> | SchemaCore.Collection<{
36
- video: SchemaCore.EmbeddedVideoField;
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
- type Value = SchemaCore.Field.LinkedValue<Schema>;
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
- function isStreamingVideo(value: Value): value is StreamingVideo.Value;
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?: Value;
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.Value.isImage(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.Value.isVideo(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
- // schema
60
- Image.schema = funnel_core_1.Schema.Collection.create({
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 Optimized' }).optional()
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.schema = funnel_core_1.Schema.Collection.create({
90
+ Video.collection = funnel_core_1.Schema.Collection.create({
75
91
  type: '_nd-Media-video',
76
- name: 'Background Video',
92
+ name: 'Video',
77
93
  description: 'Small, decorative background video content',
78
94
  version: 1,
79
95
  fields: {
80
- video: funnel_core_1.Schema.Field.video({ name: '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 a local media file or connect to a remote straming video',
104
- collections: [Image.schema, Video.schema, StreamingVideo.schema]
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.schema.type;
127
+ return value.type === Image.collection.type;
111
128
  }
112
129
  Value.isImage = isImage;
113
130
  function isVideo(value) {
114
- return value.type === Video.schema.type;
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
- // bind props
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)(refs_1.EmbeddedVideo, { className: "nd-Media-streamingVideo-player", video: video }));
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: { crop = 'center', dimensions } = {} } = visual !== null && visual !== void 0 ? visual : {};
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: { crop = 'center', dimensions } = {} } = visual !== null && visual !== void 0 ? visual : {};
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: true, muted: true, loop: true, playsInline: true, poster: cover === null || cover === void 0 ? void 0 : cover.url, style: {
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
@@ -2,6 +2,7 @@ export * from './atomic';
2
2
  export * from './blocks';
3
3
  export * from './data';
4
4
  export * from './fields';
5
+ export * from './layouts';
5
6
  export * from './panels';
6
7
  export * from './schema';
7
8
  export * from './sections';
@@ -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;
@@ -0,0 +1,5 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare function AccordionContainer({ children }: AccordionContainer.Props): import("react/jsx-runtime").JSX.Element;
3
+ export declare namespace AccordionContainer {
4
+ type Props = PropsWithChildren;
5
+ }