@uniformdev/canvas-react 19.178.2-alpha.25 → 19.179.2-alpha.22
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/index.d.mts +201 -101
- package/dist/index.d.ts +201 -101
- package/dist/index.esm.js +43 -55
- package/dist/index.js +45 -64
- package/dist/index.mjs +43 -55
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -110,36 +110,64 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
110
110
|
connectedData?: {
|
|
111
111
|
pointer: string;
|
|
112
112
|
syntax: "jptr";
|
|
113
|
-
failureAction?: "
|
|
114
|
-
failureLogLevel?: "
|
|
115
|
-
failureDefault?: string
|
|
116
|
-
}
|
|
113
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
114
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
115
|
+
failureDefault?: string;
|
|
116
|
+
};
|
|
117
117
|
locales?: {
|
|
118
118
|
[key: string]: unknown;
|
|
119
|
-
}
|
|
119
|
+
};
|
|
120
|
+
conditions?: {
|
|
121
|
+
when: {
|
|
122
|
+
op?: "&" | "|";
|
|
123
|
+
clauses: ({
|
|
124
|
+
rule: string;
|
|
125
|
+
source?: string;
|
|
126
|
+
op: string;
|
|
127
|
+
value: string | string[];
|
|
128
|
+
} | any)[];
|
|
129
|
+
};
|
|
130
|
+
value: unknown;
|
|
131
|
+
id: number;
|
|
132
|
+
}[];
|
|
133
|
+
localesConditions?: {
|
|
134
|
+
[key: string]: {
|
|
135
|
+
when: {
|
|
136
|
+
op?: "&" | "|";
|
|
137
|
+
clauses: ({
|
|
138
|
+
rule: string;
|
|
139
|
+
source?: string;
|
|
140
|
+
op: string;
|
|
141
|
+
value: string | string[];
|
|
142
|
+
} | any)[];
|
|
143
|
+
};
|
|
144
|
+
value: unknown;
|
|
145
|
+
id: number;
|
|
146
|
+
}[];
|
|
147
|
+
};
|
|
120
148
|
};
|
|
121
|
-
}
|
|
122
|
-
variant?: string
|
|
149
|
+
};
|
|
150
|
+
variant?: string;
|
|
123
151
|
projectMapNodes?: {
|
|
124
152
|
id: string;
|
|
125
153
|
path: string;
|
|
126
154
|
projectMapId: string;
|
|
127
155
|
data?: {
|
|
128
|
-
isSearchHit?: boolean
|
|
156
|
+
isSearchHit?: boolean;
|
|
129
157
|
queryStrings?: {
|
|
130
158
|
name: string;
|
|
131
|
-
value?: string
|
|
132
|
-
helpText?: string
|
|
133
|
-
}[]
|
|
134
|
-
previewValue?: string
|
|
135
|
-
}
|
|
159
|
+
value?: string;
|
|
160
|
+
helpText?: string;
|
|
161
|
+
}[];
|
|
162
|
+
previewValue?: string;
|
|
163
|
+
};
|
|
136
164
|
locales?: {
|
|
137
165
|
[key: string]: {
|
|
138
166
|
path: string;
|
|
139
167
|
inherited: boolean;
|
|
140
168
|
};
|
|
141
|
-
}
|
|
142
|
-
}[]
|
|
169
|
+
};
|
|
170
|
+
}[];
|
|
143
171
|
slots?: {
|
|
144
172
|
[key: string]: {
|
|
145
173
|
type: string;
|
|
@@ -150,44 +178,74 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
150
178
|
connectedData?: {
|
|
151
179
|
pointer: string;
|
|
152
180
|
syntax: "jptr";
|
|
153
|
-
failureAction?: "
|
|
154
|
-
failureLogLevel?: "
|
|
155
|
-
failureDefault?: string
|
|
156
|
-
}
|
|
181
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
182
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
183
|
+
failureDefault?: string;
|
|
184
|
+
};
|
|
157
185
|
locales?: {
|
|
158
186
|
[key: string]: unknown;
|
|
159
|
-
}
|
|
187
|
+
};
|
|
188
|
+
conditions?: {
|
|
189
|
+
when: {
|
|
190
|
+
op?: "&" | "|";
|
|
191
|
+
clauses: ({
|
|
192
|
+
rule: string;
|
|
193
|
+
source?: string;
|
|
194
|
+
op: string;
|
|
195
|
+
value: string | string[];
|
|
196
|
+
} | any)[];
|
|
197
|
+
};
|
|
198
|
+
value: unknown;
|
|
199
|
+
id: number;
|
|
200
|
+
}[];
|
|
201
|
+
localesConditions?: {
|
|
202
|
+
[key: string]: {
|
|
203
|
+
when: {
|
|
204
|
+
op?: "&" | "|";
|
|
205
|
+
clauses: ({
|
|
206
|
+
rule: string;
|
|
207
|
+
source?: string;
|
|
208
|
+
op: string;
|
|
209
|
+
value: string | string[];
|
|
210
|
+
} | any)[];
|
|
211
|
+
};
|
|
212
|
+
value: unknown;
|
|
213
|
+
id: number;
|
|
214
|
+
}[];
|
|
215
|
+
};
|
|
160
216
|
};
|
|
161
|
-
}
|
|
162
|
-
variant?: string
|
|
217
|
+
};
|
|
218
|
+
variant?: string;
|
|
163
219
|
slots?: {
|
|
164
220
|
[key: string]: any[];
|
|
165
|
-
}
|
|
166
|
-
_id?: string
|
|
167
|
-
_pattern?: string
|
|
221
|
+
};
|
|
222
|
+
_id?: string;
|
|
223
|
+
_pattern?: string;
|
|
168
224
|
_dataResources?: {
|
|
169
225
|
[key: string]: {
|
|
170
226
|
type: string;
|
|
171
|
-
isPatternParameter?: boolean
|
|
172
|
-
ignorePatternParameterDefault?: boolean
|
|
173
|
-
optionalPatternParameter?: boolean
|
|
227
|
+
isPatternParameter?: boolean;
|
|
228
|
+
ignorePatternParameterDefault?: boolean;
|
|
229
|
+
optionalPatternParameter?: boolean;
|
|
230
|
+
dataSourceVariant?: "unpublished";
|
|
174
231
|
variables?: {
|
|
175
232
|
[key: string]: string;
|
|
176
|
-
}
|
|
233
|
+
};
|
|
177
234
|
};
|
|
178
|
-
}
|
|
235
|
+
};
|
|
179
236
|
_patternDataResources?: {
|
|
180
237
|
[key: string]: {
|
|
181
238
|
type: string;
|
|
182
|
-
isPatternParameter?: boolean
|
|
183
|
-
ignorePatternParameterDefault?: boolean
|
|
184
|
-
optionalPatternParameter?: boolean
|
|
239
|
+
isPatternParameter?: boolean;
|
|
240
|
+
ignorePatternParameterDefault?: boolean;
|
|
241
|
+
optionalPatternParameter?: boolean;
|
|
242
|
+
dataSourceVariant?: "unpublished";
|
|
185
243
|
variables?: {
|
|
186
244
|
[key: string]: string;
|
|
187
|
-
}
|
|
245
|
+
};
|
|
188
246
|
};
|
|
189
|
-
}
|
|
190
|
-
_patternError?: "NOTFOUND" | "CYCLIC"
|
|
247
|
+
};
|
|
248
|
+
_patternError?: "NOTFOUND" | "CYCLIC";
|
|
191
249
|
_overrides?: {
|
|
192
250
|
[key: string]: {
|
|
193
251
|
parameters?: {
|
|
@@ -197,62 +255,92 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
197
255
|
connectedData?: {
|
|
198
256
|
pointer: string;
|
|
199
257
|
syntax: "jptr";
|
|
200
|
-
failureAction?: "
|
|
201
|
-
failureLogLevel?: "
|
|
202
|
-
failureDefault?: string
|
|
203
|
-
}
|
|
258
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
259
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
260
|
+
failureDefault?: string;
|
|
261
|
+
};
|
|
204
262
|
locales?: {
|
|
205
263
|
[key: string]: unknown;
|
|
206
|
-
}
|
|
264
|
+
};
|
|
265
|
+
conditions?: {
|
|
266
|
+
when: {
|
|
267
|
+
op?: "&" | "|";
|
|
268
|
+
clauses: ({
|
|
269
|
+
rule: string;
|
|
270
|
+
source?: string;
|
|
271
|
+
op: string;
|
|
272
|
+
value: string | string[];
|
|
273
|
+
} | any)[];
|
|
274
|
+
};
|
|
275
|
+
value: unknown;
|
|
276
|
+
id: number;
|
|
277
|
+
}[];
|
|
278
|
+
localesConditions?: {
|
|
279
|
+
[key: string]: {
|
|
280
|
+
when: {
|
|
281
|
+
op?: "&" | "|";
|
|
282
|
+
clauses: ({
|
|
283
|
+
rule: string;
|
|
284
|
+
source?: string;
|
|
285
|
+
op: string;
|
|
286
|
+
value: string | string[];
|
|
287
|
+
} | any)[];
|
|
288
|
+
};
|
|
289
|
+
value: unknown;
|
|
290
|
+
id: number;
|
|
291
|
+
}[];
|
|
292
|
+
};
|
|
207
293
|
};
|
|
208
|
-
}
|
|
294
|
+
};
|
|
209
295
|
slots?: {
|
|
210
296
|
[key: string]: any[];
|
|
211
|
-
}
|
|
212
|
-
variant?: string
|
|
297
|
+
};
|
|
298
|
+
variant?: string;
|
|
213
299
|
};
|
|
214
|
-
}
|
|
300
|
+
};
|
|
215
301
|
_overridability?: {
|
|
216
302
|
parameters?: {
|
|
217
303
|
[key: string]: "yes" | "no";
|
|
218
|
-
}
|
|
219
|
-
variants?: boolean
|
|
220
|
-
hideLockedParameters?: boolean
|
|
221
|
-
}
|
|
222
|
-
_locales?: string[]
|
|
304
|
+
};
|
|
305
|
+
variants?: boolean;
|
|
306
|
+
hideLockedParameters?: boolean;
|
|
307
|
+
};
|
|
308
|
+
_locales?: string[];
|
|
223
309
|
}[];
|
|
224
|
-
}
|
|
310
|
+
};
|
|
225
311
|
_id: string;
|
|
226
|
-
_slug?: string | null
|
|
312
|
+
_slug?: string | null;
|
|
227
313
|
_name: string;
|
|
228
|
-
_author?: string
|
|
229
|
-
_authorSubject?: string
|
|
230
|
-
_creator?: string
|
|
231
|
-
_creatorSubject?: string
|
|
232
|
-
_pattern?: string
|
|
314
|
+
_author?: string;
|
|
315
|
+
_authorSubject?: string;
|
|
316
|
+
_creator?: string;
|
|
317
|
+
_creatorSubject?: string;
|
|
318
|
+
_pattern?: string;
|
|
233
319
|
_patternDataResources?: {
|
|
234
320
|
[key: string]: {
|
|
235
321
|
type: string;
|
|
236
|
-
isPatternParameter?: boolean
|
|
237
|
-
ignorePatternParameterDefault?: boolean
|
|
238
|
-
optionalPatternParameter?: boolean
|
|
322
|
+
isPatternParameter?: boolean;
|
|
323
|
+
ignorePatternParameterDefault?: boolean;
|
|
324
|
+
optionalPatternParameter?: boolean;
|
|
325
|
+
dataSourceVariant?: "unpublished";
|
|
239
326
|
variables?: {
|
|
240
327
|
[key: string]: string;
|
|
241
|
-
}
|
|
328
|
+
};
|
|
242
329
|
};
|
|
243
|
-
}
|
|
330
|
+
};
|
|
244
331
|
_dataResources?: {
|
|
245
332
|
[key: string]: {
|
|
246
333
|
type: string;
|
|
247
|
-
isPatternParameter?: boolean
|
|
248
|
-
ignorePatternParameterDefault?: boolean
|
|
249
|
-
optionalPatternParameter?: boolean
|
|
334
|
+
isPatternParameter?: boolean;
|
|
335
|
+
ignorePatternParameterDefault?: boolean;
|
|
336
|
+
optionalPatternParameter?: boolean;
|
|
337
|
+
dataSourceVariant?: "unpublished";
|
|
250
338
|
variables?: {
|
|
251
339
|
[key: string]: string;
|
|
252
|
-
}
|
|
340
|
+
};
|
|
253
341
|
};
|
|
254
|
-
}
|
|
255
|
-
_patternError?: "NOTFOUND" | "CYCLIC"
|
|
342
|
+
};
|
|
343
|
+
_patternError?: "NOTFOUND" | "CYCLIC";
|
|
256
344
|
_overrides?: {
|
|
257
345
|
[key: string]: {
|
|
258
346
|
parameters?: {
|
|
@@ -262,29 +350,57 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
262
350
|
connectedData?: {
|
|
263
351
|
pointer: string;
|
|
264
352
|
syntax: "jptr";
|
|
265
|
-
failureAction?: "
|
|
266
|
-
failureLogLevel?: "
|
|
267
|
-
failureDefault?: string
|
|
268
|
-
}
|
|
353
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
354
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
355
|
+
failureDefault?: string;
|
|
356
|
+
};
|
|
269
357
|
locales?: {
|
|
270
358
|
[key: string]: unknown;
|
|
271
|
-
}
|
|
359
|
+
};
|
|
360
|
+
conditions?: {
|
|
361
|
+
when: {
|
|
362
|
+
op?: "&" | "|";
|
|
363
|
+
clauses: ({
|
|
364
|
+
rule: string;
|
|
365
|
+
source?: string;
|
|
366
|
+
op: string;
|
|
367
|
+
value: string | string[];
|
|
368
|
+
} | any)[];
|
|
369
|
+
};
|
|
370
|
+
value: unknown;
|
|
371
|
+
id: number;
|
|
372
|
+
}[];
|
|
373
|
+
localesConditions?: {
|
|
374
|
+
[key: string]: {
|
|
375
|
+
when: {
|
|
376
|
+
op?: "&" | "|";
|
|
377
|
+
clauses: ({
|
|
378
|
+
rule: string;
|
|
379
|
+
source?: string;
|
|
380
|
+
op: string;
|
|
381
|
+
value: string | string[];
|
|
382
|
+
} | any)[];
|
|
383
|
+
};
|
|
384
|
+
value: unknown;
|
|
385
|
+
id: number;
|
|
386
|
+
}[];
|
|
387
|
+
};
|
|
272
388
|
};
|
|
273
|
-
}
|
|
389
|
+
};
|
|
274
390
|
slots?: {
|
|
275
391
|
[key: string]: any[];
|
|
276
|
-
}
|
|
277
|
-
variant?: string
|
|
392
|
+
};
|
|
393
|
+
variant?: string;
|
|
278
394
|
};
|
|
279
|
-
}
|
|
395
|
+
};
|
|
280
396
|
_overridability?: {
|
|
281
397
|
parameters?: {
|
|
282
398
|
[key: string]: "yes" | "no";
|
|
283
|
-
}
|
|
284
|
-
variants?: boolean
|
|
285
|
-
hideLockedParameters?: boolean
|
|
286
|
-
}
|
|
287
|
-
_locales?: string[]
|
|
399
|
+
};
|
|
400
|
+
variants?: boolean;
|
|
401
|
+
hideLockedParameters?: boolean;
|
|
402
|
+
};
|
|
403
|
+
_locales?: string[];
|
|
288
404
|
} | undefined;
|
|
289
405
|
isContextualEditing: boolean;
|
|
290
406
|
};
|
|
@@ -357,14 +473,6 @@ type UniformRichTextProps = {
|
|
|
357
473
|
* for rendering a rich text node
|
|
358
474
|
*/
|
|
359
475
|
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
360
|
-
/**
|
|
361
|
-
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
362
|
-
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
363
|
-
* @default undefined
|
|
364
|
-
*/
|
|
365
|
-
placeholder?: string | ((parameter: {
|
|
366
|
-
id: string;
|
|
367
|
-
}) => string | undefined);
|
|
368
476
|
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
369
477
|
/**
|
|
370
478
|
* Adds rendering support for Uniform Rich Text parameters
|
|
@@ -374,22 +482,14 @@ declare const UniformRichText: React$1.ForwardRefExoticComponent<{
|
|
|
374
482
|
* The name of the HTML tag to render.
|
|
375
483
|
* @default "div"
|
|
376
484
|
*/
|
|
377
|
-
as?: React$1.ElementType
|
|
485
|
+
as?: React$1.ElementType;
|
|
378
486
|
/** The ID of the parameter. */
|
|
379
487
|
parameterId: string;
|
|
380
488
|
/**
|
|
381
489
|
* A function which can provide a custom react component
|
|
382
490
|
* for rendering a rich text node
|
|
383
491
|
*/
|
|
384
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver
|
|
385
|
-
/**
|
|
386
|
-
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
387
|
-
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
388
|
-
* @default undefined
|
|
389
|
-
*/
|
|
390
|
-
placeholder?: string | ((parameter: {
|
|
391
|
-
id: string;
|
|
392
|
-
}) => string | undefined) | undefined;
|
|
492
|
+
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
393
493
|
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & React$1.RefAttributes<unknown>>;
|
|
394
494
|
|
|
395
495
|
type UniformRichTextNodeProps = {
|
|
@@ -497,7 +597,7 @@ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContext
|
|
|
497
597
|
declare const componentStore: ComponentStore;
|
|
498
598
|
declare const registerUniformComponent: ({ type, variantId, component, }: {
|
|
499
599
|
type: string;
|
|
500
|
-
variantId?: string
|
|
600
|
+
variantId?: string;
|
|
501
601
|
component: React.ComponentType<ComponentProps<any>>;
|
|
502
602
|
}) => void;
|
|
503
603
|
declare const componentStoreResolver: RenderComponentResolver;
|
package/dist/index.esm.js
CHANGED
|
@@ -234,7 +234,11 @@ var PureContextualEditingComponentWrapper = ({
|
|
|
234
234
|
import React4, { createContext, useContext } from "react";
|
|
235
235
|
|
|
236
236
|
// src/hooks/useClientConditionsComposition.ts
|
|
237
|
-
import {
|
|
237
|
+
import {
|
|
238
|
+
evaluateWalkTreeNodeVisibility,
|
|
239
|
+
evaluateWalkTreePropertyCriteria,
|
|
240
|
+
walkNodeTree
|
|
241
|
+
} from "@uniformdev/canvas";
|
|
238
242
|
import { produce } from "immer";
|
|
239
243
|
import { useMemo as useMemo2 } from "react";
|
|
240
244
|
|
|
@@ -261,7 +265,8 @@ function useClientConditionsComposition(data) {
|
|
|
261
265
|
try {
|
|
262
266
|
return produce(data, (draft) => {
|
|
263
267
|
walkNodeTree(draft, (context) => {
|
|
264
|
-
|
|
268
|
+
evaluateWalkTreeNodeVisibility({ context, rules, showIndeterminate: false });
|
|
269
|
+
evaluateWalkTreePropertyCriteria({ node: context.node, rules, keepIndeterminate: false });
|
|
265
270
|
});
|
|
266
271
|
});
|
|
267
272
|
} catch (e) {
|
|
@@ -690,12 +695,15 @@ import {
|
|
|
690
695
|
ATTRIBUTE_PARAMETER_ID,
|
|
691
696
|
ATTRIBUTE_PARAMETER_TYPE
|
|
692
697
|
} from "@uniformdev/canvas";
|
|
693
|
-
import {
|
|
694
|
-
|
|
698
|
+
import {
|
|
699
|
+
isRichTextValue,
|
|
700
|
+
isRichTextValueConsideredEmpty
|
|
701
|
+
} from "@uniformdev/richtext";
|
|
702
|
+
import React18, { useMemo as useMemo5 } from "react";
|
|
695
703
|
|
|
696
704
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
697
705
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
698
|
-
import
|
|
706
|
+
import React17 from "react";
|
|
699
707
|
|
|
700
708
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
701
709
|
import React9 from "react";
|
|
@@ -749,28 +757,19 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
749
757
|
);
|
|
750
758
|
};
|
|
751
759
|
|
|
752
|
-
// src/components/UniformRichText/nodes/TableCellRichTextNode.tsx
|
|
753
|
-
import { getRichTextTagFromTableCellHeaderState } from "@uniformdev/richtext";
|
|
754
|
-
import React15 from "react";
|
|
755
|
-
var TableCellRichTextNode = ({ children, node }) => {
|
|
756
|
-
const { headerState } = node;
|
|
757
|
-
const TableCellTag = getRichTextTagFromTableCellHeaderState(headerState);
|
|
758
|
-
return /* @__PURE__ */ React15.createElement(TableCellTag, null, children);
|
|
759
|
-
};
|
|
760
|
-
|
|
761
760
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
762
|
-
import
|
|
761
|
+
import React15 from "react";
|
|
763
762
|
var TabRichTextNode = () => {
|
|
764
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, " ");
|
|
765
764
|
};
|
|
766
765
|
|
|
767
766
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
768
767
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
769
|
-
import
|
|
768
|
+
import React16 from "react";
|
|
770
769
|
var TextRichTextNode = ({ node }) => {
|
|
771
770
|
const { text, format } = node;
|
|
772
771
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
773
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React16.createElement(Tag, null, children), text) : text);
|
|
774
773
|
};
|
|
775
774
|
|
|
776
775
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -784,8 +783,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
784
783
|
if (!NodeRenderer) {
|
|
785
784
|
return null;
|
|
786
785
|
}
|
|
787
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
788
|
-
return /* @__PURE__ */
|
|
786
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React17.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
787
|
+
return /* @__PURE__ */ React17.createElement(NodeRenderer, { node }, children);
|
|
789
788
|
}
|
|
790
789
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
791
790
|
["heading", HeadingRichTextNode],
|
|
@@ -794,59 +793,48 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
794
793
|
["list", ListRichTextNode],
|
|
795
794
|
["listitem", ListItemRichTextNode],
|
|
796
795
|
["paragraph", ParagraphRichTextNode],
|
|
797
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
796
|
+
["quote", ({ children }) => /* @__PURE__ */ React17.createElement("blockquote", null, children)],
|
|
798
797
|
[
|
|
799
798
|
"code",
|
|
800
|
-
({ children }) => /* @__PURE__ */
|
|
799
|
+
({ children }) => /* @__PURE__ */ React17.createElement("pre", null, /* @__PURE__ */ React17.createElement("code", null, children))
|
|
801
800
|
],
|
|
802
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
801
|
+
["root", ({ children }) => /* @__PURE__ */ React17.createElement(React17.Fragment, null, children)],
|
|
803
802
|
["text", TextRichTextNode],
|
|
804
|
-
["tab", TabRichTextNode]
|
|
805
|
-
[
|
|
806
|
-
"table",
|
|
807
|
-
({ children }) => /* @__PURE__ */ React18.createElement("table", null, /* @__PURE__ */ React18.createElement("tbody", null, children))
|
|
808
|
-
],
|
|
809
|
-
["tablerow", ({ children }) => /* @__PURE__ */ React18.createElement("tr", null, children)],
|
|
810
|
-
["tablecell", TableCellRichTextNode]
|
|
803
|
+
["tab", TabRichTextNode]
|
|
811
804
|
]);
|
|
812
805
|
var resolveRichTextDefaultRenderer = (node) => {
|
|
813
806
|
return rendererMap.get(node.type);
|
|
814
807
|
};
|
|
815
808
|
|
|
816
809
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
817
|
-
var UniformRichText =
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
827
|
-
const value = parameter.value;
|
|
828
|
-
if (!value || !isRichTextValue(value)) return null;
|
|
829
|
-
if (!isContextualEditing && isRichTextValueConsideredEmpty(value)) return null;
|
|
830
|
-
return Tag === null ? /* @__PURE__ */ React19.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React19.createElement(
|
|
810
|
+
var UniformRichText = React18.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
811
|
+
const { data: componentData } = useUniformCurrentComponent();
|
|
812
|
+
const parameter = useMemo5(() => {
|
|
813
|
+
var _a;
|
|
814
|
+
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
815
|
+
}, [componentData, parameterId]);
|
|
816
|
+
const value = useMemo5(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
817
|
+
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value)) return null;
|
|
818
|
+
return Tag === null ? /* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React18.createElement(
|
|
831
819
|
Tag,
|
|
832
820
|
{
|
|
833
821
|
ref,
|
|
834
822
|
...props,
|
|
835
|
-
...
|
|
823
|
+
...{
|
|
836
824
|
[ATTRIBUTE_COMPONENT_ID]: componentData == null ? void 0 : componentData._id,
|
|
837
825
|
[ATTRIBUTE_PARAMETER_ID]: parameterId,
|
|
838
826
|
[ATTRIBUTE_PARAMETER_TYPE]: "richText"
|
|
839
|
-
}
|
|
827
|
+
}
|
|
840
828
|
},
|
|
841
|
-
|
|
829
|
+
/* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
|
|
842
830
|
);
|
|
843
831
|
});
|
|
844
832
|
|
|
845
833
|
// src/components/UniformText.tsx
|
|
846
|
-
import
|
|
834
|
+
import React20, { useState as useState2 } from "react";
|
|
847
835
|
|
|
848
836
|
// src/components/PureUniformText.tsx
|
|
849
|
-
import
|
|
837
|
+
import React19 from "react";
|
|
850
838
|
var PureUniformText = ({
|
|
851
839
|
as: Tag = "span",
|
|
852
840
|
parameterId,
|
|
@@ -865,10 +853,10 @@ var PureUniformText = ({
|
|
|
865
853
|
return null;
|
|
866
854
|
}
|
|
867
855
|
if (!isContextualEditing) {
|
|
868
|
-
return /* @__PURE__ */
|
|
856
|
+
return /* @__PURE__ */ React19.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
869
857
|
}
|
|
870
858
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
871
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ React19.createElement(
|
|
872
860
|
Tag,
|
|
873
861
|
{
|
|
874
862
|
...props,
|
|
@@ -906,7 +894,7 @@ var UniformText = ({
|
|
|
906
894
|
}
|
|
907
895
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
908
896
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
909
|
-
return /* @__PURE__ */
|
|
897
|
+
return /* @__PURE__ */ React20.createElement(
|
|
910
898
|
PureUniformText,
|
|
911
899
|
{
|
|
912
900
|
...props,
|
|
@@ -984,7 +972,7 @@ import {
|
|
|
984
972
|
createCanvasChannel as createCanvasChannel2,
|
|
985
973
|
isUpdateContextualEditingStateInternalMessage
|
|
986
974
|
} from "@uniformdev/canvas";
|
|
987
|
-
import { useEffect as useEffect3, useMemo as
|
|
975
|
+
import { useEffect as useEffect3, useMemo as useMemo6, useState as useState3 } from "react";
|
|
988
976
|
var useUniformContextualEditingState = ({
|
|
989
977
|
global = false
|
|
990
978
|
} = {}) => {
|
|
@@ -994,7 +982,7 @@ var useUniformContextualEditingState = ({
|
|
|
994
982
|
const [previewMode, setPreviewMode] = useState3(
|
|
995
983
|
isContextualEditing ? "editor" : void 0
|
|
996
984
|
);
|
|
997
|
-
const channel =
|
|
985
|
+
const channel = useMemo6(() => {
|
|
998
986
|
if (!isContextualEditing) {
|
|
999
987
|
return;
|
|
1000
988
|
}
|
|
@@ -1028,7 +1016,7 @@ var useUniformContextualEditingState = ({
|
|
|
1028
1016
|
unsubscribe();
|
|
1029
1017
|
};
|
|
1030
1018
|
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
1031
|
-
return
|
|
1019
|
+
return useMemo6(
|
|
1032
1020
|
() => ({
|
|
1033
1021
|
isContextualEditing,
|
|
1034
1022
|
selectedComponentReference,
|