@makeswift/runtime 0.11.9 → 0.11.10

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 (118) hide show
  1. package/dist/Box.cjs.js +1 -1
  2. package/dist/Box.es.js +1 -1
  3. package/dist/Button.cjs.js +1 -1
  4. package/dist/Button.es.js +1 -1
  5. package/dist/Carousel.cjs.js +1 -1
  6. package/dist/Carousel.es.js +1 -1
  7. package/dist/Countdown.cjs.js +1 -1
  8. package/dist/Countdown.es.js +1 -1
  9. package/dist/Divider.cjs.js +1 -1
  10. package/dist/Divider.es.js +1 -1
  11. package/dist/Embed.cjs.js +1 -1
  12. package/dist/Embed.es.js +1 -1
  13. package/dist/Form.cjs.js +1 -1
  14. package/dist/Form.es.js +1 -1
  15. package/dist/Image.cjs.js +1 -1
  16. package/dist/Image.es.js +1 -1
  17. package/dist/LiveProvider.cjs.js +1 -1
  18. package/dist/LiveProvider.es.js +1 -1
  19. package/dist/Navigation.cjs.js +1 -1
  20. package/dist/Navigation.es.js +1 -1
  21. package/dist/PreviewProvider.cjs.js +1 -1
  22. package/dist/PreviewProvider.es.js +1 -1
  23. package/dist/ReadOnlyText.cjs.js +1 -1
  24. package/dist/ReadOnlyText.es.js +1 -1
  25. package/dist/ReadOnlyTextV2.cjs.js +2 -2
  26. package/dist/ReadOnlyTextV2.es.js +2 -2
  27. package/dist/Root.cjs.js +1 -1
  28. package/dist/Root.es.js +1 -1
  29. package/dist/SocialLinks.cjs.js +109 -51
  30. package/dist/SocialLinks.cjs.js.map +1 -1
  31. package/dist/SocialLinks.es.js +109 -51
  32. package/dist/SocialLinks.es.js.map +1 -1
  33. package/dist/Video.cjs.js +1 -1
  34. package/dist/Video.es.js +1 -1
  35. package/dist/breakpoints.cjs.js +223 -0
  36. package/dist/breakpoints.cjs.js.map +1 -0
  37. package/dist/breakpoints.es.js +206 -0
  38. package/dist/breakpoints.es.js.map +1 -0
  39. package/dist/builder.cjs.js +1 -1
  40. package/dist/builder.es.js +1 -1
  41. package/dist/components.cjs.js +1 -1
  42. package/dist/components.es.js +1 -1
  43. package/dist/control-serialization.cjs.js +1 -1
  44. package/dist/control-serialization.es.js +1 -1
  45. package/dist/controls.cjs.js +1 -1
  46. package/dist/controls.es.js +1 -1
  47. package/dist/index.cjs.js +2 -2
  48. package/dist/index.cjs2.js +1 -1
  49. package/dist/index.cjs8.js +1 -1
  50. package/dist/index.cjs9.js +1 -1
  51. package/dist/index.es.js +2 -2
  52. package/dist/index.es2.js +1 -1
  53. package/dist/index.es8.js +1 -1
  54. package/dist/index.es9.js +1 -1
  55. package/dist/main.cjs.js +1 -1
  56. package/dist/main.es.js +1 -1
  57. package/dist/next.cjs.js +1 -1
  58. package/dist/next.es.js +1 -1
  59. package/dist/prop-controllers.cjs.js +1 -1
  60. package/dist/prop-controllers.es.js +1 -1
  61. package/dist/react-page.cjs.js +192 -6
  62. package/dist/react-page.cjs.js.map +1 -1
  63. package/dist/react-page.es.js +198 -12
  64. package/dist/react-page.es.js.map +1 -1
  65. package/dist/react.cjs.js +1 -1
  66. package/dist/react.es.js +1 -1
  67. package/dist/slate.cjs.js +1 -1
  68. package/dist/slate.es.js +1 -1
  69. package/dist/state/breakpoints.cjs.js +17 -219
  70. package/dist/state/breakpoints.cjs.js.map +1 -1
  71. package/dist/state/breakpoints.es.js +2 -205
  72. package/dist/state/breakpoints.es.js.map +1 -1
  73. package/dist/toText.cjs.js +1 -1
  74. package/dist/toText.es.js +1 -1
  75. package/dist/types/src/components/builtin/SocialLinks/options.d.ts +10 -0
  76. package/dist/types/src/components/builtin/SocialLinks/options.d.ts.map +1 -1
  77. package/dist/types/src/controls/control.d.ts.map +1 -1
  78. package/dist/types/src/controls/rich-text/__tests__/copy.test.d.ts.map +1 -0
  79. package/dist/types/src/controls/rich-text/__tests__/dto.test.d.ts.map +1 -0
  80. package/dist/types/src/controls/rich-text/__tests__/introspection.test.d.ts.map +1 -0
  81. package/dist/types/src/controls/rich-text-v2/__tests__/copy.test.d.ts.map +1 -0
  82. package/dist/types/src/controls/rich-text-v2/__tests__/fixtures/rearranged.d.ts.map +1 -0
  83. package/dist/types/src/controls/rich-text-v2/__tests__/fixtures/simple.d.ts.map +1 -0
  84. package/dist/types/src/controls/rich-text-v2/__tests__/introspection.test.d.ts.map +1 -0
  85. package/dist/types/src/controls/rich-text-v2/__tests__/translation.test.d.ts.map +1 -0
  86. package/dist/types/src/controls/rich-text-v2/translation.d.ts +1 -1
  87. package/dist/types/src/controls/rich-text-v2/translation.d.ts.map +1 -1
  88. package/dist/types/src/prop-controllers/descriptors.d.ts +1 -1
  89. package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
  90. package/dist/types/src/slate/TypographyPlugin/index.d.ts +4 -1
  91. package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
  92. package/dist/types/src/slate/TypographyPlugin/normalizeSimilarText.d.ts +10 -0
  93. package/dist/types/src/slate/TypographyPlugin/normalizeSimilarText.d.ts.map +1 -0
  94. package/dist/types/src/slate/TypographyPlugin/normalizeTypographyDown.d.ts +29 -0
  95. package/dist/types/src/slate/TypographyPlugin/normalizeTypographyDown.d.ts.map +1 -0
  96. package/dist/types/src/slate/TypographyPlugin/normalizeTypographyUp.d.ts +4 -0
  97. package/dist/types/src/slate/TypographyPlugin/normalizeTypographyUp.d.ts.map +1 -0
  98. package/dist/types/src/slate/types.d.ts +19 -2
  99. package/dist/types/src/slate/types.d.ts.map +1 -1
  100. package/dist/useMediaQuery.cjs.js +1 -1
  101. package/dist/useMediaQuery.es.js +1 -1
  102. package/package.json +1 -1
  103. package/dist/types/src/controls/rich-text/__test__/copy.test.d.ts.map +0 -1
  104. package/dist/types/src/controls/rich-text/__test__/dto.test.d.ts.map +0 -1
  105. package/dist/types/src/controls/rich-text/__test__/introspection.test.d.ts.map +0 -1
  106. package/dist/types/src/controls/rich-text-v2/__test__/copy.test.d.ts.map +0 -1
  107. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/rearranged.d.ts.map +0 -1
  108. package/dist/types/src/controls/rich-text-v2/__test__/fixtures/simple.d.ts.map +0 -1
  109. package/dist/types/src/controls/rich-text-v2/__test__/introspection.test.d.ts.map +0 -1
  110. package/dist/types/src/controls/rich-text-v2/__test__/translation.test.d.ts.map +0 -1
  111. /package/dist/types/src/controls/rich-text/{__test__ → __tests__}/copy.test.d.ts +0 -0
  112. /package/dist/types/src/controls/rich-text/{__test__ → __tests__}/dto.test.d.ts +0 -0
  113. /package/dist/types/src/controls/rich-text/{__test__ → __tests__}/introspection.test.d.ts +0 -0
  114. /package/dist/types/src/controls/rich-text-v2/{__test__ → __tests__}/copy.test.d.ts +0 -0
  115. /package/dist/types/src/controls/rich-text-v2/{__test__ → __tests__}/fixtures/rearranged.d.ts +0 -0
  116. /package/dist/types/src/controls/rich-text-v2/{__test__ → __tests__}/fixtures/simple.d.ts +0 -0
  117. /package/dist/types/src/controls/rich-text-v2/{__test__ → __tests__}/introspection.test.d.ts +0 -0
  118. /package/dist/types/src/controls/rich-text-v2/{__test__ → __tests__}/translation.test.d.ts +0 -0
package/dist/react.cjs.js CHANGED
@@ -9,7 +9,7 @@ require("next/dynamic");
9
9
  require("./react-page.cjs.js");
10
10
  require("redux");
11
11
  require("redux-thunk");
12
- require("./state/breakpoints.cjs.js");
12
+ require("./breakpoints.cjs.js");
13
13
  require("ts-pattern");
14
14
  require("corporate-ipsum");
15
15
  require("slate");
package/dist/react.es.js CHANGED
@@ -7,7 +7,7 @@ import "next/dynamic";
7
7
  import "./react-page.es.js";
8
8
  import "redux";
9
9
  import "redux-thunk";
10
- import "./state/breakpoints.es.js";
10
+ import "./breakpoints.es.js";
11
11
  import "ts-pattern";
12
12
  import "corporate-ipsum";
13
13
  import "slate";
package/dist/slate.cjs.js CHANGED
@@ -9,7 +9,7 @@ require("redux");
9
9
  require("redux-thunk");
10
10
  require("./actions.cjs.js");
11
11
  require("zod");
12
- require("./state/breakpoints.cjs.js");
12
+ require("./breakpoints.cjs.js");
13
13
  require("ts-pattern");
14
14
  require("corporate-ipsum");
15
15
  require("slate");
package/dist/slate.es.js CHANGED
@@ -7,7 +7,7 @@ import "redux";
7
7
  import "redux-thunk";
8
8
  import "./actions.es.js";
9
9
  import "zod";
10
- import "./state/breakpoints.es.js";
10
+ import "./breakpoints.es.js";
11
11
  import "ts-pattern";
12
12
  import "corporate-ipsum";
13
13
  import "slate";
@@ -1,223 +1,21 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
22
- var actions = require("../actions.cjs.js");
3
+ var state_breakpoints = require("../breakpoints.cjs.js");
4
+ require("../actions.cjs.js");
23
5
  require("zod");
24
- const keys = (o) => Object.keys(o);
25
- const coalesce = (...args) => {
26
- let i;
27
- for (i = 0; i < args.length - 1; i += 1) {
28
- if (args[i] != null)
29
- return args[i];
30
- }
31
- return args[i];
32
- };
33
- function shallowMerge(a, b) {
34
- const bKeys = keys(b);
35
- const merged = __spreadValues({}, a);
36
- bKeys.forEach((key) => {
37
- merged[key] = coalesce(merged[key], b[key]);
38
- });
39
- return merged;
40
- }
41
- const DefaultBreakpointID = {
42
- Desktop: "desktop",
43
- Tablet: "tablet",
44
- Mobile: "mobile"
45
- };
46
- const DEFAULT_BREAKPOINTS = [
47
- {
48
- id: DefaultBreakpointID.Desktop,
49
- label: "Desktop",
50
- minWidth: 769
51
- },
52
- {
53
- id: DefaultBreakpointID.Tablet,
54
- label: "Tablet",
55
- minWidth: 576,
56
- maxWidth: 768,
57
- viewportWidth: 760
58
- },
59
- {
60
- id: DefaultBreakpointID.Mobile,
61
- label: "Mobile",
62
- maxWidth: 575,
63
- viewportWidth: 390
64
- }
65
- ];
66
- function getInitialState(breakpoints = DEFAULT_BREAKPOINTS) {
67
- return breakpoints;
68
- }
69
- function reducer(state = getInitialState(), action) {
70
- switch (action.type) {
71
- case actions.ActionTypes.SET_BREAKPOINTS: {
72
- const breakpoints = action.payload.breakpoints;
73
- if (breakpoints.length === 0)
74
- throw new Error("Breakpoints cannot be empty.");
75
- return breakpoints;
76
- }
77
- default:
78
- return state;
79
- }
80
- }
81
- function parseBreakpointsInput(input) {
82
- validateBreakpointsInput(input);
83
- const sorted = Object.entries(input).map(([id, value]) => __spreadProps(__spreadValues({}, value), { id })).sort((a, b) => b.width - a.width);
84
- const transformed = sorted.reduce((prev, curr, index, array) => {
85
- const { width, viewport, id, label } = curr;
86
- const next = array[index + 1];
87
- const breakpoint = __spreadProps(__spreadValues(__spreadValues({
88
- id
89
- }, label && { label }), next && { minWidth: next.width + 1 }), {
90
- maxWidth: width,
91
- viewportWidth: viewport != null ? viewport : width
92
- });
93
- return [...prev, breakpoint];
94
- }, [
95
- { id: DefaultBreakpointID.Desktop, label: "Desktop", minWidth: sorted[0].width + 1 }
96
- ]);
97
- return transformed;
98
- }
99
- function validateBreakpointsInput(input) {
100
- if (DefaultBreakpointID.Desktop in input) {
101
- throw new Error(`Cannot change the base breakpoint. "${DefaultBreakpointID.Desktop}" is reserved as the base breakpoint.`);
102
- }
103
- if (Object.keys(input).length === 0) {
104
- throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`);
105
- }
106
- const sorted = Object.entries(input).map(([id, value]) => __spreadProps(__spreadValues({}, value), { id })).sort((a, b) => b.width - a.width);
107
- sorted.forEach(({ id, width, viewport }, index, array) => {
108
- if (viewport && viewport > width) {
109
- throw new Error(`Error on breakpoint "${id}". Viewport cannot be greater than its width.
110
- "${id}" has a viewport of ${viewport}px and a width of ${width}px.`);
111
- }
112
- const next = array[index + 1];
113
- if (viewport && next && viewport < next.width) {
114
- throw new Error(`Error on breakpoint "${id}". Viewport cannot be smaller than the next breakpoint's width.
115
- "${id}" has a viewport of ${viewport}px and the next breakpoint "${next.id}" has a width of ${next.width}px.`);
116
- }
117
- if (next && width === next.width) {
118
- throw new Error(`Breakpoints cannot have the same width. "${id}" and "${next.id}" have the same width`);
119
- }
120
- });
121
- }
122
- function sortBreakpoints(breakpoints) {
123
- return breakpoints.sort((a, b) => {
124
- var _a, _b;
125
- return ((_a = b == null ? void 0 : b.minWidth) != null ? _a : 0) - ((_b = a == null ? void 0 : a.minWidth) != null ? _b : 0);
126
- });
127
- }
128
- const getBreakpoint = (state, breakpointId) => {
129
- const breakpoint = state.find(({ id }) => id === breakpointId);
130
- if (breakpoint == null)
131
- throw new Error(`Unrecognized breakpoint ID: "${breakpointId}".`);
132
- return breakpoint;
133
- };
134
- const getBaseBreakpoint = (breakpoints) => {
135
- const breakpoint = sortBreakpoints(breakpoints)[0];
136
- if (breakpoint == null)
137
- throw new Error(`Cannot get base breakpoint.`);
138
- return breakpoint;
139
- };
140
- function findBreakpointOverride(breakpoints, values = [], deviceId, strategy = defaultStrategy) {
141
- const value = values.find(({ deviceId: d }) => d === deviceId);
142
- const fallbacks = breakpoints.slice(0, breakpoints.findIndex((d) => d.id === deviceId) + 1).reverse().map((d) => values.find((v) => v.deviceId === d.id)).filter((override) => Boolean(override));
143
- return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
144
- }
145
- function defaultStrategy(value, fallbacks) {
146
- return value || fallbacks[0];
147
- }
148
- function shallowMergeFallbacks(value, fallbacks) {
149
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
150
- deviceId: a.deviceId || b.deviceId,
151
- value: shallowMerge(a.value, b.value)
152
- }));
153
- }
154
- function mergeOrCoalesce(a, b) {
155
- if (typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
156
- return shallowMerge(a, b);
157
- }
158
- return coalesce(a, b);
159
- }
160
- function mergeOrCoalesceFallbacks(value, fallbacks) {
161
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
162
- deviceId: a.deviceId || b.deviceId,
163
- value: mergeOrCoalesce(a.value, b.value)
164
- }));
165
- }
166
- function join(breakpoints, responsiveValues, joinFn, strategy) {
167
- return breakpoints.map(({ id }) => id).map((deviceId) => {
168
- const value = joinFn(responsiveValues.map((responsiveValue) => {
169
- const deviceValue = responsiveValue && findBreakpointOverride(breakpoints, responsiveValue, deviceId, strategy);
170
- return deviceValue == null ? void 0 : deviceValue.value;
171
- }));
172
- if (value == null)
173
- return null;
174
- return { deviceId, value };
175
- }).filter((override) => Boolean(override));
176
- }
177
- const getBreakpointMediaQuery = (breakpoint) => {
178
- const parts = ["@media only screen"];
179
- if (breakpoint.minWidth != null) {
180
- parts.push(`(min-width: ${breakpoint.minWidth}px)`);
181
- }
182
- if (breakpoint.maxWidth != null) {
183
- parts.push(`(max-width: ${breakpoint.maxWidth}px)`);
184
- }
185
- return parts.join(" and ");
186
- };
187
- const getViewportStyle = (state, deviceId) => {
188
- const device = getBreakpoint(state, deviceId);
189
- return device && {
190
- width: device.viewportWidth != null ? device.viewportWidth : "100%",
191
- minWidth: device.minWidth
192
- };
193
- };
194
- function findNextFallback(breakpoints, value, deviceId, activeDeviceId, fallbackStrategy) {
195
- var _a;
196
- const deviceOverride = findBreakpointOverride(breakpoints, value.filter((v) => v.deviceId !== activeDeviceId), deviceId, fallbackStrategy);
197
- return (_a = deviceOverride && getBreakpoint(breakpoints, deviceOverride.deviceId)) != null ? _a : null;
198
- }
199
- const mergeResponsiveValues = (breakpoints, source, override) => {
200
- const devices = [
201
- ...new Set(source.map(({ deviceId }) => deviceId).concat(override.map(({ deviceId }) => deviceId)))
202
- ];
203
- return devices.map((deviceId) => ({
204
- deviceId,
205
- value: __spreadValues(__spreadValues({}, (findBreakpointOverride(breakpoints, source, deviceId) || { value: {} }).value), (findBreakpointOverride(breakpoints, override, deviceId, (v) => v) || { value: {} }).value)
206
- }));
207
- };
208
- exports.DEFAULT_BREAKPOINTS = DEFAULT_BREAKPOINTS;
209
- exports.DefaultBreakpointID = DefaultBreakpointID;
210
- exports.findBreakpointOverride = findBreakpointOverride;
211
- exports.findNextFallback = findNextFallback;
212
- exports.getBaseBreakpoint = getBaseBreakpoint;
213
- exports.getBreakpoint = getBreakpoint;
214
- exports.getBreakpointMediaQuery = getBreakpointMediaQuery;
215
- exports.getInitialState = getInitialState;
216
- exports.getViewportStyle = getViewportStyle;
217
- exports.join = join;
218
- exports.mergeOrCoalesceFallbacks = mergeOrCoalesceFallbacks;
219
- exports.mergeResponsiveValues = mergeResponsiveValues;
220
- exports.parseBreakpointsInput = parseBreakpointsInput;
221
- exports.reducer = reducer;
222
- exports.shallowMergeFallbacks = shallowMergeFallbacks;
6
+ exports.DEFAULT_BREAKPOINTS = state_breakpoints.DEFAULT_BREAKPOINTS;
7
+ exports.DefaultBreakpointID = state_breakpoints.DefaultBreakpointID;
8
+ exports.findBreakpointOverride = state_breakpoints.findBreakpointOverride;
9
+ exports.findNextFallback = state_breakpoints.findNextFallback;
10
+ exports.getBaseBreakpoint = state_breakpoints.getBaseBreakpoint;
11
+ exports.getBreakpoint = state_breakpoints.getBreakpoint;
12
+ exports.getBreakpointMediaQuery = state_breakpoints.getBreakpointMediaQuery;
13
+ exports.getInitialState = state_breakpoints.getInitialState;
14
+ exports.getViewportStyle = state_breakpoints.getViewportStyle;
15
+ exports.join = state_breakpoints.join;
16
+ exports.mergeOrCoalesceFallbacks = state_breakpoints.mergeOrCoalesceFallbacks;
17
+ exports.mergeResponsiveValues = state_breakpoints.mergeResponsiveValues;
18
+ exports.parseBreakpointsInput = state_breakpoints.parseBreakpointsInput;
19
+ exports.reducer = state_breakpoints.reducer;
20
+ exports.shallowMergeFallbacks = state_breakpoints.shallowMergeFallbacks;
223
21
  //# sourceMappingURL=breakpoints.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.cjs.js","sources":["../../src/utils/keys.ts","../../src/utils/coalesce.ts","../../src/utils/shallowMerge.ts","../../src/state/modules/breakpoints.ts"],"sourcesContent":["const keys = <O extends { [key: string]: unknown }>(o: O): (keyof O)[] => Object.keys(o)\n\nexport default keys\n","const coalesce = <T>(...args: Array<T>): T => {\n let i: number\n\n for (i = 0; i < args.length - 1; i += 1) {\n if (args[i] != null) return args[i]\n }\n\n return args[i]\n}\n\nexport default coalesce\n","import keys from './keys'\nimport coalesce from './coalesce'\n\nexport default function shallowMerge<\n A extends Record<string, unknown>,\n B extends Record<string, unknown>,\n>(a: A, b: B): A & B {\n const bKeys = keys(b)\n const merged = { ...a } as A & B\n\n bKeys.forEach(key => {\n // @ts-expect-error: `coalesce` returns `null | undefined` regardless of input guarantees.\n merged[key] = coalesce(merged[key], b[key])\n })\n\n return merged\n}\n","import { Viewport } from 'csstype'\n\nimport {\n ResponsiveValue as PropControllerResponsiveValue,\n DeviceOverride as PropControllerDeviceOverride,\n Device as DeviceId,\n} from '../../prop-controllers'\nimport shallowMerge from '../../utils/shallowMerge'\nimport { Action, ActionTypes } from '../actions'\nimport coalesce from '../../utils/coalesce'\nimport { Data } from '../../controls/types'\n\nexport type DeviceOverride<T> = PropControllerDeviceOverride<T>\nexport type ResponsiveValue<T> = PropControllerResponsiveValue<T>\nexport type BreakpointId = DeviceId\n\nexport type Breakpoint = {\n id: BreakpointId\n label?: string\n viewportWidth?: number\n minWidth?: number\n maxWidth?: number\n}\n\nexport type Breakpoints = Breakpoint[]\n\nexport type State = Breakpoints\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = typeof DefaultBreakpointID[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return breakpoints\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return breakpoints\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width. \n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n\n// Sort breakpoints by minWidth in descending order\nfunction sortBreakpoints(breakpoints: Breakpoints): Breakpoints {\n return breakpoints.sort((a, b) => (b?.minWidth ?? 0) - (a?.minWidth ?? 0))\n}\n\nexport const getBreakpoint = (state: State, breakpointId: Breakpoint['id']): Breakpoint => {\n const breakpoint = state.find(({ id }) => id === breakpointId)\n\n if (breakpoint == null) throw new Error(`Unrecognized breakpoint ID: \"${breakpointId}\".`)\n\n return breakpoint\n}\n\nexport const getBaseBreakpoint = (breakpoints: Breakpoints): Breakpoint => {\n const breakpoint = sortBreakpoints(breakpoints)[0]\n\n if (breakpoint == null) throw new Error(`Cannot get base breakpoint.`)\n\n return breakpoint\n}\n\nexport function findBreakpointOverride<S>(\n breakpoints: Breakpoints,\n values: ResponsiveValue<S> = [],\n deviceId: string,\n strategy: FallbackStrategy<S> = defaultStrategy,\n): DeviceOverride<S> | undefined {\n const value = values.find(({ deviceId: d }) => d === deviceId)\n const fallbacks = breakpoints\n .slice(0, breakpoints.findIndex(d => d.id === deviceId) + 1)\n .reverse()\n .map(d => values.find(v => v.deviceId === d.id))\n .filter((override): override is DeviceOverride<S> => Boolean(override))\n\n return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : undefined\n}\n\nexport type FallbackStrategy<V> = (\n arg0: DeviceOverride<V> | undefined,\n arg1: ResponsiveValue<V>,\n) => DeviceOverride<V> | undefined\n\nfunction defaultStrategy<V>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return value || fallbacks[0]\n}\n\nexport function shallowMergeFallbacks<V extends Record<string, unknown>>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return [value, ...fallbacks]\n .filter((override): override is DeviceOverride<V> => Boolean(override))\n .reduce((a, b) => ({\n deviceId: a.deviceId || b.deviceId,\n value: shallowMerge(a.value, b.value),\n }))\n}\n\nfunction mergeOrCoalesce<A extends Data>(a: A, b: A): A {\n if (\n typeof a === 'object' &&\n a !== null &&\n !Array.isArray(a) &&\n typeof b === 'object' &&\n b !== null &&\n !Array.isArray(b)\n ) {\n return shallowMerge(a, b) as A\n }\n return coalesce(a, b)\n}\n\nexport function mergeOrCoalesceFallbacks<V extends Data>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return [value, ...fallbacks]\n .filter((override): override is DeviceOverride<V> => Boolean(override))\n .reduce((a, b) => ({\n deviceId: a.deviceId || b.deviceId,\n value: mergeOrCoalesce(a.value, b.value),\n }))\n}\n\nexport type ExtractResponsiveValue<T> = T extends ResponsiveValue<infer V> ? V : never\n\nexport function join<V, A extends ReadonlyArray<ResponsiveValue<V> | null | undefined>, R>(\n breakpoints: Breakpoints,\n responsiveValues: A,\n joinFn: (values: { [I in keyof A]: ExtractResponsiveValue<A[I]> | undefined }) => R,\n strategy?: FallbackStrategy<V>,\n): ResponsiveValue<R> {\n return breakpoints\n .map(({ id }) => id)\n .map(deviceId => {\n const value = joinFn(\n responsiveValues.map(responsiveValue => {\n const deviceValue =\n responsiveValue &&\n findBreakpointOverride(breakpoints, responsiveValue, deviceId, strategy)\n\n return deviceValue == null ? undefined : deviceValue.value\n }) as unknown as { [I in keyof A]: ExtractResponsiveValue<A[I] | undefined> },\n )\n\n if (value == null) return null\n\n return { deviceId, value }\n })\n .filter((override): override is NonNullable<typeof override> => Boolean(override))\n}\n\nexport const getBreakpointMediaQuery = (breakpoint: Breakpoint): string => {\n const parts = ['@media only screen']\n\n if (breakpoint.minWidth != null) {\n parts.push(`(min-width: ${breakpoint.minWidth}px)`)\n }\n\n if (breakpoint.maxWidth != null) {\n parts.push(`(max-width: ${breakpoint.maxWidth}px)`)\n }\n\n return parts.join(' and ')\n}\n\nexport const getViewportStyle = (\n state: State,\n deviceId: string,\n): Viewport<string | number> | null | undefined => {\n const device = getBreakpoint(state, deviceId)\n\n return (\n device && {\n width: device.viewportWidth != null ? device.viewportWidth : '100%',\n minWidth: device.minWidth,\n }\n )\n}\n\nexport function findNextFallback<V>(\n breakpoints: Breakpoints,\n value: ResponsiveValue<V>,\n deviceId: BreakpointId,\n activeDeviceId: BreakpointId,\n fallbackStrategy?: FallbackStrategy<V>,\n): Breakpoint | null {\n const deviceOverride = findBreakpointOverride(\n breakpoints,\n value.filter(v => v.deviceId !== activeDeviceId),\n deviceId,\n fallbackStrategy,\n )\n\n return (deviceOverride && getBreakpoint(breakpoints, deviceOverride.deviceId)) ?? null\n}\n\nexport const mergeResponsiveValues = <A>(\n breakpoints: Breakpoints,\n source: DeviceOverride<A>[],\n override: DeviceOverride<A>[],\n): DeviceOverride<A>[] => {\n const devices = [\n ...new Set(\n source.map(({ deviceId }) => deviceId).concat(override.map(({ deviceId }) => deviceId)),\n ),\n ]\n\n return devices.map(deviceId => ({\n deviceId,\n value: {\n ...(findBreakpointOverride(breakpoints, source, deviceId) || { value: {} }).value,\n ...(findBreakpointOverride(breakpoints, override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n"],"names":["ActionTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,OAAO,CAAuC,MAAsB,OAAO,KAAK,CAAC;ACAvF,MAAM,WAAW,IAAO,SAAsB;AACxC,MAAA;AAEJ,OAAK,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG;AACvC,QAAI,KAAK,MAAM;AAAM,aAAO,KAAK;AAAA,EACnC;AAEA,SAAO,KAAK;AACd;ACLA,sBAGE,GAAM,GAAa;AACb,QAAA,QAAQ,KAAK,CAAC;AACd,QAAA,SAAS,mBAAK;AAEpB,QAAM,QAAQ,CAAO,QAAA;AAEnB,WAAO,OAAO,SAAS,OAAO,MAAM,EAAE,IAAI;AAAA,EAAA,CAC3C;AAEM,SAAA;AACT;ACYO,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,yBAAyB,cAAc,qBAA4B;AACjE,SAAA;AACT;AAEwB,iBAAA,QAAe,gBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACRA,QAAAA,YAAY,iBAAiB;AAC1B,YAAA,cAAc,OAAO,QAAQ;AAEnC,UAAI,YAAY,WAAW;AAAS,cAAA,IAAI,MAAM,8BAA8B;AAErE,aAAA;AAAA,IACT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UAAA,KAAK,eAAe,WAAW,aAAa;AAAA,EACpD;AAEI,MAAA,WAAW,YAAY,MAAM;AACzB,UAAA,KAAK,eAAe,WAAW,aAAa;AAAA,EACpD;AAEO,SAAA,MAAM,KAAK,OAAO;AAC3B;AAEa,MAAA,mBAAmB,CAC9B,OACA,aACiD;AAC3C,QAAA,SAAS,cAAc,OAAO,QAAQ;AAE5C,SACE,UAAU;AAAA,IACR,OAAO,OAAO,iBAAiB,OAAO,OAAO,gBAAgB;AAAA,IAC7D,UAAU,OAAO;AAAA,EAAA;AAGvB;AAEO,0BACL,aACA,OACA,UACA,gBACA,kBACmB;;AACb,QAAA,iBAAiB,uBACrB,aACA,MAAM,OAAO,CAAK,MAAA,EAAE,aAAa,cAAc,GAC/C,UACA,gBACF;AAEA,SAA0B,wBAAA,cAAc,aAAa,eAAe,QAAQ,MAAlD,YAAwD;AACpF;AAEO,MAAM,wBAAwB,CACnC,aACA,QACA,aACwB;AACxB,QAAM,UAAU;AAAA,IACd,GAAG,IAAI,IACL,OAAO,IAAI,CAAC,EAAE,eAAe,QAAQ,EAAE,OAAO,SAAS,IAAI,CAAC,EAAE,eAAe,QAAQ,CAAC,CACxF;AAAA,EAAA;AAGK,SAAA,QAAQ,IAAI,CAAa,aAAA;AAAA,IAC9B;AAAA,IACA,OAAO,kCACD,wBAAuB,aAAa,QAAQ,QAAQ,KAAK,EAAE,OAAO,CAAC,EAAA,GAAK,QACxE,wBAAuB,aAAa,UAAU,UAAU,CAAA,MAAK,CAAC,KAAK,EAAE,OAAO,CAAA,EAAM,GAAA;AAAA,EAExF,EAAA;AACJ;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"breakpoints.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -1,207 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { A as ActionTypes } from "../actions.es.js";
1
+ export { e as DEFAULT_BREAKPOINTS, D as DefaultBreakpointID, f as findBreakpointOverride, i as findNextFallback, a as getBaseBreakpoint, b as getBreakpoint, c as getBreakpointMediaQuery, g as getInitialState, h as getViewportStyle, j as join, m as mergeOrCoalesceFallbacks, l as mergeResponsiveValues, p as parseBreakpointsInput, r as reducer, d as shallowMergeFallbacks } from "../breakpoints.es.js";
2
+ import "../actions.es.js";
21
3
  import "zod";
22
- const keys = (o) => Object.keys(o);
23
- const coalesce = (...args) => {
24
- let i;
25
- for (i = 0; i < args.length - 1; i += 1) {
26
- if (args[i] != null)
27
- return args[i];
28
- }
29
- return args[i];
30
- };
31
- function shallowMerge(a, b) {
32
- const bKeys = keys(b);
33
- const merged = __spreadValues({}, a);
34
- bKeys.forEach((key) => {
35
- merged[key] = coalesce(merged[key], b[key]);
36
- });
37
- return merged;
38
- }
39
- const DefaultBreakpointID = {
40
- Desktop: "desktop",
41
- Tablet: "tablet",
42
- Mobile: "mobile"
43
- };
44
- const DEFAULT_BREAKPOINTS = [
45
- {
46
- id: DefaultBreakpointID.Desktop,
47
- label: "Desktop",
48
- minWidth: 769
49
- },
50
- {
51
- id: DefaultBreakpointID.Tablet,
52
- label: "Tablet",
53
- minWidth: 576,
54
- maxWidth: 768,
55
- viewportWidth: 760
56
- },
57
- {
58
- id: DefaultBreakpointID.Mobile,
59
- label: "Mobile",
60
- maxWidth: 575,
61
- viewportWidth: 390
62
- }
63
- ];
64
- function getInitialState(breakpoints = DEFAULT_BREAKPOINTS) {
65
- return breakpoints;
66
- }
67
- function reducer(state = getInitialState(), action) {
68
- switch (action.type) {
69
- case ActionTypes.SET_BREAKPOINTS: {
70
- const breakpoints = action.payload.breakpoints;
71
- if (breakpoints.length === 0)
72
- throw new Error("Breakpoints cannot be empty.");
73
- return breakpoints;
74
- }
75
- default:
76
- return state;
77
- }
78
- }
79
- function parseBreakpointsInput(input) {
80
- validateBreakpointsInput(input);
81
- const sorted = Object.entries(input).map(([id, value]) => __spreadProps(__spreadValues({}, value), { id })).sort((a, b) => b.width - a.width);
82
- const transformed = sorted.reduce((prev, curr, index, array) => {
83
- const { width, viewport, id, label } = curr;
84
- const next = array[index + 1];
85
- const breakpoint = __spreadProps(__spreadValues(__spreadValues({
86
- id
87
- }, label && { label }), next && { minWidth: next.width + 1 }), {
88
- maxWidth: width,
89
- viewportWidth: viewport != null ? viewport : width
90
- });
91
- return [...prev, breakpoint];
92
- }, [
93
- { id: DefaultBreakpointID.Desktop, label: "Desktop", minWidth: sorted[0].width + 1 }
94
- ]);
95
- return transformed;
96
- }
97
- function validateBreakpointsInput(input) {
98
- if (DefaultBreakpointID.Desktop in input) {
99
- throw new Error(`Cannot change the base breakpoint. "${DefaultBreakpointID.Desktop}" is reserved as the base breakpoint.`);
100
- }
101
- if (Object.keys(input).length === 0) {
102
- throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`);
103
- }
104
- const sorted = Object.entries(input).map(([id, value]) => __spreadProps(__spreadValues({}, value), { id })).sort((a, b) => b.width - a.width);
105
- sorted.forEach(({ id, width, viewport }, index, array) => {
106
- if (viewport && viewport > width) {
107
- throw new Error(`Error on breakpoint "${id}". Viewport cannot be greater than its width.
108
- "${id}" has a viewport of ${viewport}px and a width of ${width}px.`);
109
- }
110
- const next = array[index + 1];
111
- if (viewport && next && viewport < next.width) {
112
- throw new Error(`Error on breakpoint "${id}". Viewport cannot be smaller than the next breakpoint's width.
113
- "${id}" has a viewport of ${viewport}px and the next breakpoint "${next.id}" has a width of ${next.width}px.`);
114
- }
115
- if (next && width === next.width) {
116
- throw new Error(`Breakpoints cannot have the same width. "${id}" and "${next.id}" have the same width`);
117
- }
118
- });
119
- }
120
- function sortBreakpoints(breakpoints) {
121
- return breakpoints.sort((a, b) => {
122
- var _a, _b;
123
- return ((_a = b == null ? void 0 : b.minWidth) != null ? _a : 0) - ((_b = a == null ? void 0 : a.minWidth) != null ? _b : 0);
124
- });
125
- }
126
- const getBreakpoint = (state, breakpointId) => {
127
- const breakpoint = state.find(({ id }) => id === breakpointId);
128
- if (breakpoint == null)
129
- throw new Error(`Unrecognized breakpoint ID: "${breakpointId}".`);
130
- return breakpoint;
131
- };
132
- const getBaseBreakpoint = (breakpoints) => {
133
- const breakpoint = sortBreakpoints(breakpoints)[0];
134
- if (breakpoint == null)
135
- throw new Error(`Cannot get base breakpoint.`);
136
- return breakpoint;
137
- };
138
- function findBreakpointOverride(breakpoints, values = [], deviceId, strategy = defaultStrategy) {
139
- const value = values.find(({ deviceId: d }) => d === deviceId);
140
- const fallbacks = breakpoints.slice(0, breakpoints.findIndex((d) => d.id === deviceId) + 1).reverse().map((d) => values.find((v) => v.deviceId === d.id)).filter((override) => Boolean(override));
141
- return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : void 0;
142
- }
143
- function defaultStrategy(value, fallbacks) {
144
- return value || fallbacks[0];
145
- }
146
- function shallowMergeFallbacks(value, fallbacks) {
147
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
148
- deviceId: a.deviceId || b.deviceId,
149
- value: shallowMerge(a.value, b.value)
150
- }));
151
- }
152
- function mergeOrCoalesce(a, b) {
153
- if (typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
154
- return shallowMerge(a, b);
155
- }
156
- return coalesce(a, b);
157
- }
158
- function mergeOrCoalesceFallbacks(value, fallbacks) {
159
- return [value, ...fallbacks].filter((override) => Boolean(override)).reduce((a, b) => ({
160
- deviceId: a.deviceId || b.deviceId,
161
- value: mergeOrCoalesce(a.value, b.value)
162
- }));
163
- }
164
- function join(breakpoints, responsiveValues, joinFn, strategy) {
165
- return breakpoints.map(({ id }) => id).map((deviceId) => {
166
- const value = joinFn(responsiveValues.map((responsiveValue) => {
167
- const deviceValue = responsiveValue && findBreakpointOverride(breakpoints, responsiveValue, deviceId, strategy);
168
- return deviceValue == null ? void 0 : deviceValue.value;
169
- }));
170
- if (value == null)
171
- return null;
172
- return { deviceId, value };
173
- }).filter((override) => Boolean(override));
174
- }
175
- const getBreakpointMediaQuery = (breakpoint) => {
176
- const parts = ["@media only screen"];
177
- if (breakpoint.minWidth != null) {
178
- parts.push(`(min-width: ${breakpoint.minWidth}px)`);
179
- }
180
- if (breakpoint.maxWidth != null) {
181
- parts.push(`(max-width: ${breakpoint.maxWidth}px)`);
182
- }
183
- return parts.join(" and ");
184
- };
185
- const getViewportStyle = (state, deviceId) => {
186
- const device = getBreakpoint(state, deviceId);
187
- return device && {
188
- width: device.viewportWidth != null ? device.viewportWidth : "100%",
189
- minWidth: device.minWidth
190
- };
191
- };
192
- function findNextFallback(breakpoints, value, deviceId, activeDeviceId, fallbackStrategy) {
193
- var _a;
194
- const deviceOverride = findBreakpointOverride(breakpoints, value.filter((v) => v.deviceId !== activeDeviceId), deviceId, fallbackStrategy);
195
- return (_a = deviceOverride && getBreakpoint(breakpoints, deviceOverride.deviceId)) != null ? _a : null;
196
- }
197
- const mergeResponsiveValues = (breakpoints, source, override) => {
198
- const devices = [
199
- ...new Set(source.map(({ deviceId }) => deviceId).concat(override.map(({ deviceId }) => deviceId)))
200
- ];
201
- return devices.map((deviceId) => ({
202
- deviceId,
203
- value: __spreadValues(__spreadValues({}, (findBreakpointOverride(breakpoints, source, deviceId) || { value: {} }).value), (findBreakpointOverride(breakpoints, override, deviceId, (v) => v) || { value: {} }).value)
204
- }));
205
- };
206
- export { DEFAULT_BREAKPOINTS, DefaultBreakpointID, findBreakpointOverride, findNextFallback, getBaseBreakpoint, getBreakpoint, getBreakpointMediaQuery, getInitialState, getViewportStyle, join, mergeOrCoalesceFallbacks, mergeResponsiveValues, parseBreakpointsInput, reducer, shallowMergeFallbacks };
207
4
  //# sourceMappingURL=breakpoints.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.es.js","sources":["../../src/utils/keys.ts","../../src/utils/coalesce.ts","../../src/utils/shallowMerge.ts","../../src/state/modules/breakpoints.ts"],"sourcesContent":["const keys = <O extends { [key: string]: unknown }>(o: O): (keyof O)[] => Object.keys(o)\n\nexport default keys\n","const coalesce = <T>(...args: Array<T>): T => {\n let i: number\n\n for (i = 0; i < args.length - 1; i += 1) {\n if (args[i] != null) return args[i]\n }\n\n return args[i]\n}\n\nexport default coalesce\n","import keys from './keys'\nimport coalesce from './coalesce'\n\nexport default function shallowMerge<\n A extends Record<string, unknown>,\n B extends Record<string, unknown>,\n>(a: A, b: B): A & B {\n const bKeys = keys(b)\n const merged = { ...a } as A & B\n\n bKeys.forEach(key => {\n // @ts-expect-error: `coalesce` returns `null | undefined` regardless of input guarantees.\n merged[key] = coalesce(merged[key], b[key])\n })\n\n return merged\n}\n","import { Viewport } from 'csstype'\n\nimport {\n ResponsiveValue as PropControllerResponsiveValue,\n DeviceOverride as PropControllerDeviceOverride,\n Device as DeviceId,\n} from '../../prop-controllers'\nimport shallowMerge from '../../utils/shallowMerge'\nimport { Action, ActionTypes } from '../actions'\nimport coalesce from '../../utils/coalesce'\nimport { Data } from '../../controls/types'\n\nexport type DeviceOverride<T> = PropControllerDeviceOverride<T>\nexport type ResponsiveValue<T> = PropControllerResponsiveValue<T>\nexport type BreakpointId = DeviceId\n\nexport type Breakpoint = {\n id: BreakpointId\n label?: string\n viewportWidth?: number\n minWidth?: number\n maxWidth?: number\n}\n\nexport type Breakpoints = Breakpoint[]\n\nexport type State = Breakpoints\n\nexport const DefaultBreakpointID = {\n Desktop: 'desktop',\n Tablet: 'tablet',\n Mobile: 'mobile',\n} as const\n\ntype DefaultBreakpointID = typeof DefaultBreakpointID[keyof typeof DefaultBreakpointID]\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = [\n {\n id: DefaultBreakpointID.Desktop,\n label: 'Desktop',\n minWidth: 769,\n },\n {\n id: DefaultBreakpointID.Tablet,\n label: 'Tablet',\n minWidth: 576,\n maxWidth: 768,\n viewportWidth: 760,\n },\n {\n id: DefaultBreakpointID.Mobile,\n label: 'Mobile',\n maxWidth: 575,\n viewportWidth: 390,\n },\n]\n\nexport function getInitialState(breakpoints = DEFAULT_BREAKPOINTS): State {\n return breakpoints\n}\n\nexport function reducer(state: State = getInitialState(), action: Action): State {\n switch (action.type) {\n case ActionTypes.SET_BREAKPOINTS: {\n const breakpoints = action.payload.breakpoints\n\n if (breakpoints.length === 0) throw new Error('Breakpoints cannot be empty.')\n\n return breakpoints\n }\n\n default:\n return state\n }\n}\n\nexport type BreakpointsInput = Record<string, { width: number; label?: string; viewport?: number }>\n\nexport function parseBreakpointsInput(input: BreakpointsInput): Breakpoints {\n validateBreakpointsInput(input)\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n const transformed = sorted.reduce(\n (prev, curr, index, array) => {\n const { width, viewport, id, label } = curr\n const next = array[index + 1]\n\n const breakpoint: Breakpoint = {\n id,\n ...(label && { label }),\n ...(next && { minWidth: next.width + 1 }),\n maxWidth: width,\n viewportWidth: viewport ?? width,\n }\n\n return [...prev, breakpoint]\n },\n [\n { id: DefaultBreakpointID.Desktop, label: 'Desktop', minWidth: sorted[0].width + 1 },\n ] as Breakpoints,\n )\n\n return transformed\n}\n\nfunction validateBreakpointsInput(input: BreakpointsInput) {\n if (DefaultBreakpointID.Desktop in input) {\n throw new Error(\n `Cannot change the base breakpoint. \"${DefaultBreakpointID.Desktop}\" is reserved as the base breakpoint.`,\n )\n }\n\n if (Object.keys(input).length === 0) {\n throw new Error(`Breakpoints cannot be empty. You must provide at least one breakpoint.`)\n }\n\n const sorted = Object.entries(input)\n .map(([id, value]) => ({ ...value, id }))\n .sort((a, b) => b.width - a.width) // Sort by width in descending order\n\n sorted.forEach(({ id, width, viewport }, index, array) => {\n // This is only valid for desktop-first. We need to check the inverse for mobile-first.\n if (viewport && viewport > width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be greater than its width.\n \"${id}\" has a viewport of ${viewport}px and a width of ${width}px.`,\n )\n }\n\n const next = array[index + 1]\n\n if (viewport && next && viewport < next.width) {\n throw new Error(\n `Error on breakpoint \"${id}\". Viewport cannot be smaller than the next breakpoint's width. \n \"${id}\" has a viewport of ${viewport}px and the next breakpoint \"${next.id}\" has a width of ${next.width}px.`,\n )\n }\n\n if (next && width === next.width) {\n throw new Error(\n `Breakpoints cannot have the same width. \"${id}\" and \"${next.id}\" have the same width`,\n )\n }\n })\n}\n\n// Sort breakpoints by minWidth in descending order\nfunction sortBreakpoints(breakpoints: Breakpoints): Breakpoints {\n return breakpoints.sort((a, b) => (b?.minWidth ?? 0) - (a?.minWidth ?? 0))\n}\n\nexport const getBreakpoint = (state: State, breakpointId: Breakpoint['id']): Breakpoint => {\n const breakpoint = state.find(({ id }) => id === breakpointId)\n\n if (breakpoint == null) throw new Error(`Unrecognized breakpoint ID: \"${breakpointId}\".`)\n\n return breakpoint\n}\n\nexport const getBaseBreakpoint = (breakpoints: Breakpoints): Breakpoint => {\n const breakpoint = sortBreakpoints(breakpoints)[0]\n\n if (breakpoint == null) throw new Error(`Cannot get base breakpoint.`)\n\n return breakpoint\n}\n\nexport function findBreakpointOverride<S>(\n breakpoints: Breakpoints,\n values: ResponsiveValue<S> = [],\n deviceId: string,\n strategy: FallbackStrategy<S> = defaultStrategy,\n): DeviceOverride<S> | undefined {\n const value = values.find(({ deviceId: d }) => d === deviceId)\n const fallbacks = breakpoints\n .slice(0, breakpoints.findIndex(d => d.id === deviceId) + 1)\n .reverse()\n .map(d => values.find(v => v.deviceId === d.id))\n .filter((override): override is DeviceOverride<S> => Boolean(override))\n\n return value != null || fallbacks.length > 0 ? strategy(value, fallbacks) : undefined\n}\n\nexport type FallbackStrategy<V> = (\n arg0: DeviceOverride<V> | undefined,\n arg1: ResponsiveValue<V>,\n) => DeviceOverride<V> | undefined\n\nfunction defaultStrategy<V>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return value || fallbacks[0]\n}\n\nexport function shallowMergeFallbacks<V extends Record<string, unknown>>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return [value, ...fallbacks]\n .filter((override): override is DeviceOverride<V> => Boolean(override))\n .reduce((a, b) => ({\n deviceId: a.deviceId || b.deviceId,\n value: shallowMerge(a.value, b.value),\n }))\n}\n\nfunction mergeOrCoalesce<A extends Data>(a: A, b: A): A {\n if (\n typeof a === 'object' &&\n a !== null &&\n !Array.isArray(a) &&\n typeof b === 'object' &&\n b !== null &&\n !Array.isArray(b)\n ) {\n return shallowMerge(a, b) as A\n }\n return coalesce(a, b)\n}\n\nexport function mergeOrCoalesceFallbacks<V extends Data>(\n value: DeviceOverride<V> | undefined,\n fallbacks: ResponsiveValue<V>,\n): DeviceOverride<V> | undefined {\n return [value, ...fallbacks]\n .filter((override): override is DeviceOverride<V> => Boolean(override))\n .reduce((a, b) => ({\n deviceId: a.deviceId || b.deviceId,\n value: mergeOrCoalesce(a.value, b.value),\n }))\n}\n\nexport type ExtractResponsiveValue<T> = T extends ResponsiveValue<infer V> ? V : never\n\nexport function join<V, A extends ReadonlyArray<ResponsiveValue<V> | null | undefined>, R>(\n breakpoints: Breakpoints,\n responsiveValues: A,\n joinFn: (values: { [I in keyof A]: ExtractResponsiveValue<A[I]> | undefined }) => R,\n strategy?: FallbackStrategy<V>,\n): ResponsiveValue<R> {\n return breakpoints\n .map(({ id }) => id)\n .map(deviceId => {\n const value = joinFn(\n responsiveValues.map(responsiveValue => {\n const deviceValue =\n responsiveValue &&\n findBreakpointOverride(breakpoints, responsiveValue, deviceId, strategy)\n\n return deviceValue == null ? undefined : deviceValue.value\n }) as unknown as { [I in keyof A]: ExtractResponsiveValue<A[I] | undefined> },\n )\n\n if (value == null) return null\n\n return { deviceId, value }\n })\n .filter((override): override is NonNullable<typeof override> => Boolean(override))\n}\n\nexport const getBreakpointMediaQuery = (breakpoint: Breakpoint): string => {\n const parts = ['@media only screen']\n\n if (breakpoint.minWidth != null) {\n parts.push(`(min-width: ${breakpoint.minWidth}px)`)\n }\n\n if (breakpoint.maxWidth != null) {\n parts.push(`(max-width: ${breakpoint.maxWidth}px)`)\n }\n\n return parts.join(' and ')\n}\n\nexport const getViewportStyle = (\n state: State,\n deviceId: string,\n): Viewport<string | number> | null | undefined => {\n const device = getBreakpoint(state, deviceId)\n\n return (\n device && {\n width: device.viewportWidth != null ? device.viewportWidth : '100%',\n minWidth: device.minWidth,\n }\n )\n}\n\nexport function findNextFallback<V>(\n breakpoints: Breakpoints,\n value: ResponsiveValue<V>,\n deviceId: BreakpointId,\n activeDeviceId: BreakpointId,\n fallbackStrategy?: FallbackStrategy<V>,\n): Breakpoint | null {\n const deviceOverride = findBreakpointOverride(\n breakpoints,\n value.filter(v => v.deviceId !== activeDeviceId),\n deviceId,\n fallbackStrategy,\n )\n\n return (deviceOverride && getBreakpoint(breakpoints, deviceOverride.deviceId)) ?? null\n}\n\nexport const mergeResponsiveValues = <A>(\n breakpoints: Breakpoints,\n source: DeviceOverride<A>[],\n override: DeviceOverride<A>[],\n): DeviceOverride<A>[] => {\n const devices = [\n ...new Set(\n source.map(({ deviceId }) => deviceId).concat(override.map(({ deviceId }) => deviceId)),\n ),\n ]\n\n return devices.map(deviceId => ({\n deviceId,\n value: {\n ...(findBreakpointOverride(breakpoints, source, deviceId) || { value: {} }).value,\n ...(findBreakpointOverride(breakpoints, override, deviceId, v => v) || { value: {} }).value,\n },\n })) as DeviceOverride<A>[]\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,OAAO,CAAuC,MAAsB,OAAO,KAAK,CAAC;ACAvF,MAAM,WAAW,IAAO,SAAsB;AACxC,MAAA;AAEJ,OAAK,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG;AACvC,QAAI,KAAK,MAAM;AAAM,aAAO,KAAK;AAAA,EACnC;AAEA,SAAO,KAAK;AACd;ACLA,sBAGE,GAAM,GAAa;AACb,QAAA,QAAQ,KAAK,CAAC;AACd,QAAA,SAAS,mBAAK;AAEpB,QAAM,QAAQ,CAAO,QAAA;AAEnB,WAAO,OAAO,SAAS,OAAO,MAAM,EAAE,IAAI;AAAA,EAAA,CAC3C;AAEM,SAAA;AACT;ACYO,MAAM,sBAAsB;AAAA,EACjC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAIO,MAAM,sBAAmC;AAAA,EAC9C;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAAA,EACA;AAAA,IACE,IAAI,oBAAoB;AAAA,IACxB,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AACF;AAEO,yBAAyB,cAAc,qBAA4B;AACjE,SAAA;AACT;AAEwB,iBAAA,QAAe,gBAAgB,GAAG,QAAuB;AAC/E,UAAQ,OAAO;AAAA,SACR,YAAY,iBAAiB;AAC1B,YAAA,cAAc,OAAO,QAAQ;AAEnC,UAAI,YAAY,WAAW;AAAS,cAAA,IAAI,MAAM,8BAA8B;AA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,YAAY,MAAM;AACzB,UAAA,KAAK,eAAe,WAAW,aAAa;AAAA,EACpD;AAEI,MAAA,WAAW,YAAY,MAAM;AACzB,UAAA,KAAK,eAAe,WAAW,aAAa;AAAA,EACpD;AAEO,SAAA,MAAM,KAAK,OAAO;AAC3B;AAEa,MAAA,mBAAmB,CAC9B,OACA,aACiD;AAC3C,QAAA,SAAS,cAAc,OAAO,QAAQ;AAE5C,SACE,UAAU;AAAA,IACR,OAAO,OAAO,iBAAiB,OAAO,OAAO,gBAAgB;AAAA,IAC7D,UAAU,OAAO;AAAA,EAAA;AAGvB;AAEO,0BACL,aACA,OACA,UACA,gBACA,kBACmB;;AACb,QAAA,iBAAiB,uBACrB,aACA,MAAM,OAAO,CAAK,MAAA,EAAE,aAAa,cAAc,GAC/C,UACA,gBACF;AAEA,SAA0B,wBAAA,cAAc,aAAa,eAAe,QAAQ,MAAlD,YAAwD;AACpF;AAEO,MAAM,wBAAwB,CACnC,aACA,QACA,aACwB;AACxB,QAAM,UAAU;AAAA,IACd,GAAG,IAAI,IACL,OAAO,IAAI,CAAC,EAAE,eAAe,QAAQ,EAAE,OAAO,SAAS,IAAI,CAAC,EAAE,eAAe,QAAQ,CAAC,CACxF;AAAA,EAAA;AAGK,SAAA,QAAQ,IAAI,CAAa,aAAA;AAAA,IAC9B;AAAA,IACA,OAAO,kCACD,wBAAuB,aAAa,QAAQ,QAAQ,KAAK,EAAE,OAAO,CAAC,EAAA,GAAK,QACxE,wBAAuB,aAAa,UAAU,UAAU,CAAA,MAAK,CAAC,KAAK,EAAE,OAAO,CAAA,EAAM,GAAA;AAAA,EAExF,EAAA;AACJ;;"}
1
+ {"version":3,"file":"breakpoints.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -9,7 +9,7 @@ require("slate-hyperscript");
9
9
  require("parse5");
10
10
  require("is-hotkey");
11
11
  require("react/jsx-runtime");
12
- require("./state/breakpoints.cjs.js");
12
+ require("./breakpoints.cjs.js");
13
13
  function isText(node) {
14
14
  if (typeof node === "object" && "text" in node)
15
15
  return true;
package/dist/toText.es.js CHANGED
@@ -8,7 +8,7 @@ import "slate-hyperscript";
8
8
  import "parse5";
9
9
  import "is-hotkey";
10
10
  import "react/jsx-runtime";
11
- import "./state/breakpoints.es.js";
11
+ import "./breakpoints.es.js";
12
12
  function isText(node) {
13
13
  if (typeof node === "object" && "text" in node)
14
14
  return true;
@@ -58,6 +58,11 @@ export declare const SocialLinksOptions: readonly [{
58
58
  readonly label: "RSS";
59
59
  readonly icon: import("react/jsx-runtime").JSX.Element;
60
60
  readonly brandColor: "black";
61
+ }, {
62
+ readonly type: "slack";
63
+ readonly label: "Slack";
64
+ readonly icon: import("react/jsx-runtime").JSX.Element;
65
+ readonly brandColor: "#fffc00";
61
66
  }, {
62
67
  readonly type: "snapchat";
63
68
  readonly label: "Snapchat";
@@ -103,6 +108,11 @@ export declare const SocialLinksOptions: readonly [{
103
108
  readonly label: "Vimeo";
104
109
  readonly icon: import("react/jsx-runtime").JSX.Element;
105
110
  readonly brandColor: "#1ab7ea";
111
+ }, {
112
+ readonly type: "X";
113
+ readonly label: "X";
114
+ readonly icon: import("react/jsx-runtime").JSX.Element;
115
+ readonly brandColor: "black";
106
116
  }, {
107
117
  readonly type: "yelp";
108
118
  readonly label: "Yelp";
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../src/components/builtin/SocialLinks/options.tsx"],"names":[],"mappings":"AAwBA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBrB,CAAA"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../src/components/builtin/SocialLinks/options.tsx"],"names":[],"mappings":"AA0BA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;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OAAO,EAAE,YAAY,GACpB,IAAI,CAQN;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CA4BhG;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,wBAAwB,EACpC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,IAAI,EACpB,OAAO,EAAE,4BAA4B,GACpC,IAAI,CAkDN"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.test.d.ts","sourceRoot":"","sources":["../../../../../../src/controls/rich-text/__tests__/copy.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.test.d.ts","sourceRoot":"","sources":["../../../../../../src/controls/rich-text/__tests__/dto.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspection.test.d.ts","sourceRoot":"","sources":["../../../../../../src/controls/rich-text/__tests__/introspection.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.test.d.ts","sourceRoot":"","sources":["../../../../../../src/controls/rich-text-v2/__tests__/copy.test.ts"],"names":[],"mappings":""}