clava 0.0.1 → 0.1.0

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/src/index.ts ADDED
@@ -0,0 +1,692 @@
1
+ import clsx, { type ClassValue as ClsxClassValue } from "clsx";
2
+
3
+ import type {
4
+ Variants,
5
+ ComputedVariants,
6
+ AnyComponent,
7
+ Component,
8
+ StyleProps,
9
+ ClassValue,
10
+ StyleValue,
11
+ StyleClassValue,
12
+ VariantValues,
13
+ Computed,
14
+ ExtendableVariants,
15
+ MergeVariants,
16
+ ModalComponent,
17
+ ComponentResult,
18
+ JSXProps,
19
+ HTMLProps,
20
+ HTMLObjProps,
21
+ OnlyVariantsComponent,
22
+ ComponentProps,
23
+ SplitPropsFunction,
24
+ } from "./types.ts";
25
+
26
+ import {
27
+ htmlObjStyleToStyleValue,
28
+ htmlStyleToStyleValue,
29
+ isHTMLObjStyle,
30
+ jsxStyleToStyleValue,
31
+ styleValueToHTMLObjStyle,
32
+ styleValueToHTMLStyle,
33
+ styleValueToJSXStyle,
34
+ } from "./utils.ts";
35
+
36
+ const MODES = ["jsx", "html", "htmlObj"] as const;
37
+ type Mode = (typeof MODES)[number];
38
+
39
+ export type { ClassValue, StyleValue, StyleClassValue };
40
+
41
+ export type VariantProps<T extends Pick<AnyComponent, "getVariants">> =
42
+ ReturnType<T["getVariants"]>;
43
+
44
+ export interface CVConfig<
45
+ V extends Variants = {},
46
+ CV extends ComputedVariants = {},
47
+ E extends AnyComponent[] = [],
48
+ > {
49
+ extend?: E;
50
+ class?: ClassValue;
51
+ style?: StyleValue;
52
+ variants?: ExtendableVariants<V, E>;
53
+ computedVariants?: CV;
54
+ defaultVariants?: VariantValues<MergeVariants<V, CV, E>>;
55
+ computed?: Computed<MergeVariants<V, CV, E>>;
56
+ }
57
+
58
+ interface CreateParams<M extends Mode> {
59
+ defaultMode?: M;
60
+ transformClass?: (className: string) => string;
61
+ }
62
+
63
+ /**
64
+ * Checks if a value is a style-class object (has style properties, not just a
65
+ * class value).
66
+ */
67
+ function isStyleClassValue(value: unknown): value is StyleClassValue {
68
+ if (typeof value !== "object") return false;
69
+ if (value == null) return false;
70
+ if (Array.isArray(value)) return false;
71
+ return true;
72
+ }
73
+
74
+ /**
75
+ * Converts any style input (string, JSX object, or HTML object) to a
76
+ * normalized StyleValue.
77
+ */
78
+ function normalizeStyle(style: unknown): StyleValue {
79
+ if (typeof style === "string") {
80
+ return htmlStyleToStyleValue(style);
81
+ }
82
+ if (typeof style === "object" && style != null) {
83
+ if (isHTMLObjStyle(style as Record<string, unknown>)) {
84
+ return htmlObjStyleToStyleValue(style as Record<string, string | number>);
85
+ }
86
+ return jsxStyleToStyleValue(style as Record<string, string | number>);
87
+ }
88
+ return {};
89
+ }
90
+
91
+ /**
92
+ * Extracts class and style from a style-class value object.
93
+ */
94
+ function extractStyleClass(value: StyleClassValue): {
95
+ class: ClassValue;
96
+ style: StyleValue;
97
+ } {
98
+ const { class: cls, ...style } = value;
99
+ return { class: cls, style };
100
+ }
101
+
102
+ /**
103
+ * Processes a variant value to extract class and style.
104
+ */
105
+ function processVariantValue(value: unknown): {
106
+ class: ClassValue;
107
+ style: StyleValue;
108
+ } {
109
+ if (isStyleClassValue(value)) {
110
+ return extractStyleClass(value);
111
+ }
112
+ return { class: value as ClassValue, style: {} };
113
+ }
114
+
115
+ /**
116
+ * Gets all variant keys from a component's config, including extended
117
+ * components.
118
+ */
119
+ function collectVariantKeys(
120
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
121
+ ): string[] {
122
+ const keys = new Set<string>();
123
+
124
+ // Collect from extended components
125
+ if (config.extend) {
126
+ for (const ext of config.extend) {
127
+ for (const key of ext.onlyVariants.keys) {
128
+ keys.add(key as string);
129
+ }
130
+ }
131
+ }
132
+
133
+ // Collect from variants
134
+ if (config.variants) {
135
+ for (const key of Object.keys(config.variants)) {
136
+ keys.add(key);
137
+ }
138
+ }
139
+
140
+ // Collect from computedVariants
141
+ if (config.computedVariants) {
142
+ for (const key of Object.keys(config.computedVariants)) {
143
+ keys.add(key);
144
+ }
145
+ }
146
+
147
+ return Array.from(keys);
148
+ }
149
+
150
+ /**
151
+ * Collects default variants from extended components and the current config.
152
+ * Also handles implicit boolean defaults (when only `false` key exists).
153
+ */
154
+ function collectDefaultVariants(
155
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
156
+ ): Record<string, unknown> {
157
+ let defaults: Record<string, unknown> = {};
158
+
159
+ // Collect from extended components
160
+ if (config.extend) {
161
+ for (const ext of config.extend) {
162
+ const extDefaults = ext.getVariants();
163
+ defaults = { ...defaults, ...extDefaults };
164
+ }
165
+ }
166
+
167
+ // Handle implicit boolean defaults from variants
168
+ // If a variant only has a `false` key and no `true` key, default to false
169
+ if (config.variants) {
170
+ for (const [variantName, variantDef] of Object.entries(config.variants)) {
171
+ if (isStyleClassValue(variantDef)) {
172
+ const keys = Object.keys(variantDef);
173
+ const hasFalseOnly = keys.includes("false") && !keys.includes("true");
174
+ if (hasFalseOnly && defaults[variantName] === undefined) {
175
+ defaults[variantName] = false;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ // Override with current config's defaults
182
+ if (config.defaultVariants) {
183
+ defaults = { ...defaults, ...config.defaultVariants };
184
+ }
185
+
186
+ return defaults;
187
+ }
188
+
189
+ /**
190
+ * Resolves variant values by merging defaults with provided props.
191
+ */
192
+ function resolveVariants(
193
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
194
+ props: Record<string, unknown> = {},
195
+ ): Record<string, unknown> {
196
+ const defaults = collectDefaultVariants(config);
197
+ return { ...defaults, ...props };
198
+ }
199
+
200
+ /**
201
+ * Gets the value for a single variant based on the variant definition and the
202
+ * selected value.
203
+ */
204
+ function getVariantResult(
205
+ variantDef: unknown,
206
+ selectedValue: unknown,
207
+ ): { class: ClassValue; style: StyleValue } {
208
+ // Shorthand variant: `disabled: "disabled-class"` means { true: "..." }
209
+ if (!isStyleClassValue(variantDef)) {
210
+ if (selectedValue === true) {
211
+ return processVariantValue(variantDef);
212
+ }
213
+ return { class: null, style: {} };
214
+ }
215
+
216
+ // Object variant: { sm: "...", lg: "..." }
217
+ const key = String(selectedValue);
218
+ const value = (variantDef as Record<string, unknown>)[key];
219
+ if (value === undefined) return { class: null, style: {} };
220
+
221
+ return processVariantValue(value);
222
+ }
223
+
224
+ /**
225
+ * Processes extended components and returns base classes and variant classes separately.
226
+ * Base classes should come before current component's base, variant classes come after.
227
+ * When overrideVariantKeys is provided, those variant keys are excluded from the extended
228
+ * component's result (used when current component's computedVariants overrides them).
229
+ */
230
+ function processExtended(
231
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
232
+ resolvedVariants: Record<string, unknown>,
233
+ overrideVariantKeys: Set<string> = new Set(),
234
+ ): {
235
+ baseClasses: ClassValue[];
236
+ variantClasses: ClassValue[];
237
+ style: StyleValue;
238
+ } {
239
+ const baseClasses: ClassValue[] = [];
240
+ const variantClasses: ClassValue[] = [];
241
+ let style: StyleValue = {};
242
+
243
+ if (config.extend) {
244
+ for (const ext of config.extend) {
245
+ // Filter out variant keys that are being overridden by current component's computedVariants
246
+ const filteredVariants = { ...resolvedVariants };
247
+ for (const key of overrideVariantKeys) {
248
+ delete filteredVariants[key];
249
+ }
250
+
251
+ // Get the result with filtered variants (excluding overridden keys)
252
+ const extResult = ext({ ...filteredVariants });
253
+
254
+ // Only merge style for non-overridden keys
255
+ const extStyle = normalizeStyle(extResult.style);
256
+ style = { ...style, ...extStyle };
257
+
258
+ // Get base class from internal property (no variants)
259
+ const baseClass = ext._baseClass;
260
+ baseClasses.push(baseClass);
261
+
262
+ // Get full class with variants
263
+ const fullClass =
264
+ "className" in extResult ? extResult.className : extResult.class;
265
+
266
+ // Extract variant portion (full class minus base class)
267
+ if (fullClass && baseClass) {
268
+ const baseClassSet = new Set(baseClass.split(" ").filter(Boolean));
269
+ const variantPortion = fullClass
270
+ .split(" ")
271
+ .filter((c: string) => c && !baseClassSet.has(c))
272
+ .join(" ");
273
+ if (variantPortion) {
274
+ variantClasses.push(variantPortion);
275
+ }
276
+ } else if (fullClass && !baseClass) {
277
+ variantClasses.push(fullClass);
278
+ }
279
+ }
280
+ }
281
+
282
+ return { baseClasses, variantClasses, style };
283
+ }
284
+
285
+ /**
286
+ * Processes all variants (not extended) and returns accumulated class and
287
+ * style.
288
+ */
289
+ function processVariants(
290
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
291
+ resolvedVariants: Record<string, unknown>,
292
+ ): { classes: ClassValue[]; style: StyleValue } {
293
+ const classes: ClassValue[] = [];
294
+ let style: StyleValue = {};
295
+
296
+ // Process current component's variants
297
+ if (config.variants) {
298
+ for (const [variantName, variantDef] of Object.entries(config.variants)) {
299
+ const selectedValue = resolvedVariants[variantName];
300
+ if (selectedValue === undefined) continue;
301
+
302
+ const result = getVariantResult(variantDef, selectedValue);
303
+ classes.push(result.class);
304
+ style = { ...style, ...result.style };
305
+ }
306
+ }
307
+
308
+ // Process computedVariants
309
+ if (config.computedVariants) {
310
+ for (const [variantName, computeFn] of Object.entries(
311
+ config.computedVariants,
312
+ )) {
313
+ const selectedValue = resolvedVariants[variantName];
314
+ if (selectedValue === undefined) continue;
315
+
316
+ const computedResult = computeFn(selectedValue);
317
+ const result = processVariantValue(computedResult);
318
+ classes.push(result.class);
319
+ style = { ...style, ...result.style };
320
+ }
321
+ }
322
+
323
+ return { classes, style };
324
+ }
325
+
326
+ /**
327
+ * Processes the computed function if present.
328
+ */
329
+ function processComputed(
330
+ config: CVConfig<Variants, ComputedVariants, AnyComponent[]>,
331
+ resolvedVariants: Record<string, unknown>,
332
+ ): {
333
+ classes: ClassValue[];
334
+ style: StyleValue;
335
+ updatedVariants: Record<string, unknown>;
336
+ } {
337
+ const classes: ClassValue[] = [];
338
+ let style: StyleValue = {};
339
+ let updatedVariants = { ...resolvedVariants };
340
+
341
+ if (config.computed) {
342
+ const context = {
343
+ variants: resolvedVariants,
344
+ setVariants: (newVariants: VariantValues<Record<string, unknown>>) => {
345
+ updatedVariants = { ...updatedVariants, ...newVariants };
346
+ },
347
+ setDefaultVariants: (
348
+ newDefaults: VariantValues<Record<string, unknown>>,
349
+ ) => {
350
+ // Only apply defaults for variants not already set
351
+ for (const [key, value] of Object.entries(newDefaults)) {
352
+ if (resolvedVariants[key] === undefined) {
353
+ updatedVariants[key] = value;
354
+ }
355
+ }
356
+ },
357
+ };
358
+
359
+ const computedResult = config.computed(context);
360
+ if (computedResult != null) {
361
+ const result = processVariantValue(computedResult);
362
+ classes.push(result.class);
363
+ style = { ...style, ...result.style };
364
+ }
365
+ }
366
+
367
+ return { classes, style, updatedVariants };
368
+ }
369
+
370
+ /**
371
+ * Normalizes a key source (array or component) to an object with keys and defaults.
372
+ */
373
+ function normalizeKeySource(source: unknown): {
374
+ keys: string[];
375
+ defaults: Record<string, unknown>;
376
+ } {
377
+ if (Array.isArray(source)) {
378
+ return { keys: source as string[], defaults: {} };
379
+ }
380
+ // Components are functions with keys property, onlyVariants are objects with keys
381
+ if (
382
+ source &&
383
+ (typeof source === "object" || typeof source === "function") &&
384
+ "keys" in source
385
+ ) {
386
+ const keys = [...(source as { keys: string[] }).keys] as string[];
387
+ const defaults =
388
+ "getVariants" in source
389
+ ? (
390
+ source as { getVariants: () => Record<string, unknown> }
391
+ ).getVariants()
392
+ : {};
393
+ return { keys, defaults };
394
+ }
395
+ return { keys: [], defaults: {} };
396
+ }
397
+
398
+ /**
399
+ * Splits props into multiple groups based on key sources.
400
+ */
401
+ function splitPropsImpl(
402
+ selfKeys: string[],
403
+ selfDefaults: Record<string, unknown>,
404
+ props: Record<string, unknown>,
405
+ sources: Array<{ keys: string[]; defaults: Record<string, unknown> }>,
406
+ ): Record<string, unknown>[] {
407
+ const allUsedKeys = new Set<string>(selfKeys);
408
+ const results: Record<string, unknown>[] = [];
409
+
410
+ // Self result with defaults
411
+ const selfResult: Record<string, unknown> = {};
412
+ // First apply defaults
413
+ for (const [key, value] of Object.entries(selfDefaults)) {
414
+ if (selfKeys.includes(key)) {
415
+ selfResult[key] = value;
416
+ }
417
+ }
418
+ // Then override with props
419
+ for (const key of selfKeys) {
420
+ if (key in props) {
421
+ selfResult[key] = props[key];
422
+ }
423
+ }
424
+ results.push(selfResult);
425
+
426
+ // Process each source
427
+ for (const source of sources) {
428
+ const sourceResult: Record<string, unknown> = {};
429
+ // First apply defaults
430
+ for (const [key, value] of Object.entries(source.defaults)) {
431
+ if (source.keys.includes(key)) {
432
+ sourceResult[key] = value;
433
+ }
434
+ }
435
+ // Then override with props
436
+ for (const key of source.keys) {
437
+ allUsedKeys.add(key);
438
+ if (key in props) {
439
+ sourceResult[key] = props[key];
440
+ }
441
+ }
442
+ results.push(sourceResult);
443
+ }
444
+
445
+ // Rest - keys not used by anyone
446
+ const rest: Record<string, unknown> = {};
447
+ for (const [key, value] of Object.entries(props)) {
448
+ if (!allUsedKeys.has(key)) {
449
+ rest[key] = value;
450
+ }
451
+ }
452
+ results.push(rest);
453
+
454
+ return results;
455
+ }
456
+
457
+ /**
458
+ * Splits props into multiple groups based on key sources.
459
+ * Each source gets its own result object containing all its matching keys.
460
+ * The last element is always the "rest" containing keys not claimed by any source.
461
+ *
462
+ * @example
463
+ * ```ts
464
+ * const [buttonProps, inputProps, rest] = splitProps(
465
+ * props,
466
+ * buttonComponent,
467
+ * inputComponent.onlyVariants,
468
+ * );
469
+ * ```
470
+ */
471
+ export const splitProps: SplitPropsFunction = ((
472
+ props: Record<string, unknown>,
473
+ source1: unknown,
474
+ ...sources: unknown[]
475
+ ) => {
476
+ const normalizedSource1 = normalizeKeySource(source1);
477
+ const normalizedSources = sources.map(normalizeKeySource);
478
+ return splitPropsImpl(
479
+ normalizedSource1.keys,
480
+ normalizedSource1.defaults,
481
+ props,
482
+ normalizedSources,
483
+ );
484
+ }) as SplitPropsFunction;
485
+
486
+ export function create<M extends Mode>({
487
+ defaultMode = "jsx" as M,
488
+ transformClass = (className) => className,
489
+ }: CreateParams<M> = {}) {
490
+ const cx = (...classes: ClsxClassValue[]) => transformClass(clsx(...classes));
491
+
492
+ const cv = <
493
+ V extends Variants = {},
494
+ CV extends ComputedVariants = {},
495
+ const E extends AnyComponent[] = [],
496
+ >(
497
+ config: CVConfig<V, CV, E> = {},
498
+ ): Component<V, CV, E, StyleProps[M]> => {
499
+ type MergedVariants = MergeVariants<V, CV, E>;
500
+
501
+ const variantKeys = collectVariantKeys(
502
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
503
+ );
504
+
505
+ const getClassPropertyName = (mode: Mode) =>
506
+ mode === "jsx" ? "className" : "class";
507
+
508
+ const getPropsKeys = (mode: Mode) => [
509
+ getClassPropertyName(mode),
510
+ "style",
511
+ ...variantKeys,
512
+ ];
513
+
514
+ const computeResult = (
515
+ props: ComponentProps<MergedVariants> = {},
516
+ ): { className: string; style: StyleValue } => {
517
+ const allClasses: ClassValue[] = [];
518
+ let allStyle: StyleValue = {};
519
+
520
+ // Extract variant props from input
521
+ const variantProps: Record<string, unknown> = {};
522
+ for (const key of variantKeys) {
523
+ if (key in props) {
524
+ variantProps[key] = (props as Record<string, unknown>)[key];
525
+ }
526
+ }
527
+
528
+ // Resolve variants with defaults
529
+ let resolvedVariants = resolveVariants(
530
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
531
+ variantProps,
532
+ );
533
+
534
+ // Process computed first to potentially update variants
535
+ const computedResult = processComputed(
536
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
537
+ resolvedVariants,
538
+ );
539
+ resolvedVariants = computedResult.updatedVariants;
540
+
541
+ // Collect computedVariants keys that will override extended variants
542
+ const computedVariantKeys = new Set<string>(
543
+ config.computedVariants ? Object.keys(config.computedVariants) : [],
544
+ );
545
+
546
+ // Process extended components (separates base and variant classes)
547
+ const extendedResult = processExtended(
548
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
549
+ resolvedVariants,
550
+ computedVariantKeys,
551
+ );
552
+
553
+ // 1. Extended base classes first
554
+ allClasses.push(...extendedResult.baseClasses);
555
+ allStyle = { ...allStyle, ...extendedResult.style };
556
+
557
+ // 2. Current component's base class
558
+ allClasses.push(config.class);
559
+
560
+ // 3. Add base style
561
+ if (config.style) {
562
+ allStyle = { ...allStyle, ...config.style };
563
+ }
564
+
565
+ // 4. Extended variant classes
566
+ allClasses.push(...extendedResult.variantClasses);
567
+
568
+ // 5. Current component's variants
569
+ const variantsResult = processVariants(
570
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
571
+ resolvedVariants,
572
+ );
573
+ allClasses.push(...variantsResult.classes);
574
+ allStyle = { ...allStyle, ...variantsResult.style };
575
+
576
+ // Add computed results
577
+ allClasses.push(...computedResult.classes);
578
+ allStyle = { ...allStyle, ...computedResult.style };
579
+
580
+ // Merge class from props
581
+ if ("class" in props) {
582
+ allClasses.push(props.class);
583
+ }
584
+ if ("className" in props) {
585
+ allClasses.push(props.className);
586
+ }
587
+
588
+ // Merge style from props
589
+ if (props.style != null) {
590
+ allStyle = { ...allStyle, ...normalizeStyle(props.style) };
591
+ }
592
+
593
+ return {
594
+ className: cx(...(allClasses as ClsxClassValue[])),
595
+ style: allStyle,
596
+ };
597
+ };
598
+
599
+ const createModalComponent = <R extends ComponentResult>(
600
+ mode: Mode,
601
+ ): ModalComponent<MergedVariants, R> => {
602
+ const propsKeys = getPropsKeys(mode);
603
+
604
+ const component = ((props: ComponentProps<MergedVariants> = {}) => {
605
+ const { className, style } = computeResult(props);
606
+
607
+ if (mode === "jsx") {
608
+ return { className, style: styleValueToJSXStyle(style) } as R;
609
+ }
610
+ if (mode === "html") {
611
+ return {
612
+ class: className,
613
+ style: styleValueToHTMLStyle(style),
614
+ } as R;
615
+ }
616
+ // htmlObj
617
+ return {
618
+ class: className,
619
+ style: styleValueToHTMLObjStyle(style),
620
+ } as R;
621
+ }) as ModalComponent<MergedVariants, R>;
622
+
623
+ component.class = (props: ComponentProps<MergedVariants> = {}) => {
624
+ return computeResult(props).className;
625
+ };
626
+
627
+ component.style = ((props: ComponentProps<MergedVariants> = {}) => {
628
+ const { style } = computeResult(props);
629
+ if (mode === "jsx") return styleValueToJSXStyle(style);
630
+ if (mode === "html") return styleValueToHTMLStyle(style);
631
+ return styleValueToHTMLObjStyle(style);
632
+ }) as ModalComponent<MergedVariants, R>["style"];
633
+
634
+ component.getVariants = (
635
+ variants?: VariantValues<MergedVariants>,
636
+ ): VariantValues<MergedVariants> => {
637
+ return resolveVariants(
638
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
639
+ variants as VariantValues<Record<string, unknown>>,
640
+ ) as VariantValues<MergedVariants>;
641
+ };
642
+
643
+ component.keys = propsKeys as (keyof MergedVariants | keyof R)[];
644
+
645
+ component.onlyVariants = {
646
+ getVariants: (
647
+ variants?: VariantValues<MergedVariants>,
648
+ ): VariantValues<MergedVariants> => {
649
+ return resolveVariants(
650
+ config as CVConfig<Variants, ComputedVariants, AnyComponent[]>,
651
+ variants as VariantValues<Record<string, unknown>>,
652
+ ) as VariantValues<MergedVariants>;
653
+ },
654
+ keys: variantKeys as (keyof MergedVariants)[],
655
+ } as OnlyVariantsComponent<MergedVariants>;
656
+
657
+ // Compute base class (without variants) - includes extended base classes
658
+ const extendedBaseClasses: ClassValue[] = [];
659
+ if (config.extend) {
660
+ for (const ext of config.extend) {
661
+ extendedBaseClasses.push(ext._baseClass);
662
+ }
663
+ }
664
+ component._baseClass = cx(
665
+ ...(extendedBaseClasses as ClsxClassValue[]),
666
+ config.class as ClsxClassValue,
667
+ );
668
+
669
+ return component;
670
+ };
671
+
672
+ // Create the default modal component
673
+ const defaultComponent = createModalComponent<StyleProps[M]>(defaultMode);
674
+
675
+ // Create all modal variants
676
+ const jsxComponent = createModalComponent<JSXProps>("jsx");
677
+ const htmlComponent = createModalComponent<HTMLProps>("html");
678
+ const htmlObjComponent = createModalComponent<HTMLObjProps>("htmlObj");
679
+
680
+ // Build the final component
681
+ const component = defaultComponent as Component<V, CV, E, StyleProps[M]>;
682
+ component.jsx = jsxComponent;
683
+ component.html = htmlComponent;
684
+ component.htmlObj = htmlObjComponent;
685
+
686
+ return component;
687
+ };
688
+
689
+ return { cv, cx };
690
+ }
691
+
692
+ export const { cv, cx } = create();