@awc-ui/react 1.0.0 → 1.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.
@@ -0,0 +1,511 @@
1
+ /**
2
+ * SSR runtime vendored from @stencil/react-output-target 1.6.2 (MIT).
3
+ * Copyright (c) 2019-present Drifty Co. See THIRD_PARTY_LICENSES.md.
4
+ *
5
+ * Kept local so the serializer fix also ships to published-package consumers.
6
+ * The upstream child resolver and client wrapper are preserved. Local changes:
7
+ * escape attributes, apply declared Core props before server rendering, and
8
+ * preserve the initial values supported by Core's browser attribute readers.
9
+ * Regeneration must not overwrite this file.
10
+ */
11
+ import l, { Fragment as N } from "react";
12
+ import { createComponent as C } from "@stencil/react-output-target/runtime";
13
+
14
+ const escapeAttribute = (value: unknown) => String(value).replace(/[&"'<>]/g, char => ({
15
+ '&': '&amp;', '"': '&quot;', "'": '&#39;', '<': '&lt;', '>': '&gt;',
16
+ }[char]));
17
+ // These Core components accept an array or its JSON attribute form.
18
+ const jsonArrayAttributes: Record<string, string | undefined> = {
19
+ "md-autocomplete": "options",
20
+ "md-multi-select": "options",
21
+ "md-organization-chart": "nodes",
22
+ "md-select": "options",
23
+ "md-transfer-list": "items",
24
+ };
25
+
26
+ function getSsrArrayAttribute(tag: string, attribute: string, value: unknown[]) {
27
+ if (jsonArrayAttributes[tag] === attribute) return attribute;
28
+ if (attribute === "value" && (tag === "md-autocomplete" || tag === "md-multi-select") &&
29
+ value.every(item => typeof item === "string")) {
30
+ return "data-awc-initial-values";
31
+ }
32
+ }
33
+
34
+ var U = {
35
+ animationIterationCount: 1,
36
+ aspectRatio: 1,
37
+ borderImageOutset: 1,
38
+ borderImageSlice: 1,
39
+ borderImageWidth: 1,
40
+ boxFlex: 1,
41
+ boxFlexGroup: 1,
42
+ boxOrdinalGroup: 1,
43
+ columnCount: 1,
44
+ columns: 1,
45
+ flex: 1,
46
+ flexGrow: 1,
47
+ flexPositive: 1,
48
+ flexShrink: 1,
49
+ flexNegative: 1,
50
+ flexOrder: 1,
51
+ gridRow: 1,
52
+ gridRowEnd: 1,
53
+ gridRowSpan: 1,
54
+ gridRowStart: 1,
55
+ gridColumn: 1,
56
+ gridColumnEnd: 1,
57
+ gridColumnSpan: 1,
58
+ gridColumnStart: 1,
59
+ msGridRow: 1,
60
+ msGridRowSpan: 1,
61
+ msGridColumn: 1,
62
+ msGridColumnSpan: 1,
63
+ fontWeight: 1,
64
+ lineHeight: 1,
65
+ opacity: 1,
66
+ order: 1,
67
+ orphans: 1,
68
+ scale: 1,
69
+ tabSize: 1,
70
+ widows: 1,
71
+ zIndex: 1,
72
+ zoom: 1,
73
+ WebkitLineClamp: 1,
74
+ // SVG-related properties
75
+ fillOpacity: 1,
76
+ floodOpacity: 1,
77
+ stopOpacity: 1,
78
+ strokeDasharray: 1,
79
+ strokeDashoffset: 1,
80
+ strokeMiterlimit: 1,
81
+ strokeOpacity: 1,
82
+ strokeWidth: 1
83
+ }, v = "px", F = (e) => typeof e == "number" || typeof e == "string";
84
+ function W(e) {
85
+ return e.startsWith("--") ? e : e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
86
+ }
87
+ function D(e, t, n = v) {
88
+ if (typeof t != "string" && typeof t != "number")
89
+ throw new Error(
90
+ "Invalid input: value of 'cssProperties' must be string or number."
91
+ );
92
+ const r = e.startsWith("--") || U[e] === 1;
93
+ if (typeof t == "string" || t === 0 || r)
94
+ return `${t}`;
95
+ const i = (typeof n == "string" ? n : n[e]) || v;
96
+ return `${t}${i}`;
97
+ }
98
+ function q(e, t) {
99
+ if (typeof e != "object" || e === null)
100
+ throw new TypeError(
101
+ `[stringifyStyleDeclaration]: Expected 'styleDeclaration' to be a non-null object, but received ${e} (type:${typeof e}).`
102
+ );
103
+ const n = t != null && t.important ? "!important" : "";
104
+ return Object.entries(e).filter(([r, i]) => F(i)).map(
105
+ ([r, i]) => `${W(r)}:${D(
106
+ r,
107
+ i,
108
+ t == null ? void 0 : t.unit
109
+ )}${n};`
110
+ ).join("");
111
+ }
112
+ function G(e, t = !1) {
113
+ if (typeof e != "object" || e === null)
114
+ throw new TypeError(
115
+ `[stringifyCSSProperties]: Expected 'cssProperties' to be a non-null object, but received ${e} (type:${typeof e}).`
116
+ );
117
+ return q(e, typeof t == "boolean" ? {
118
+ important: t
119
+ } : t);
120
+ }
121
+ const E = {
122
+ acceptCharset: "accept-charset",
123
+ accessKey: "accesskey",
124
+ allowFullScreen: "allowfullscreen",
125
+ autoCapitalize: "autocapitalize",
126
+ autoComplete: "autocomplete",
127
+ autoCorrect: "autocorrect",
128
+ autoFocus: "autofocus",
129
+ autoPlay: "autoplay",
130
+ autoSave: "autosave",
131
+ cellPadding: "cellpadding",
132
+ cellSpacing: "cellspacing",
133
+ charSet: "charset",
134
+ className: "class",
135
+ classID: "classid",
136
+ colSpan: "colspan",
137
+ contentEditable: "contenteditable",
138
+ contextMenu: "contextmenu",
139
+ controlsList: "controlslist",
140
+ crossOrigin: "crossorigin",
141
+ dangerouslySetInnerHTML: "dangerouslysetinnerhtml",
142
+ dateTime: "datetime",
143
+ defaultChecked: "defaultchecked",
144
+ defaultValue: "defaultvalue",
145
+ disablePictureInPicture: "disablepictureinpicture",
146
+ disableRemotePlayback: "disableremoteplayback",
147
+ encType: "enctype",
148
+ enterKeyHint: "enterkeyhint",
149
+ fetchPriority: "fetchpriority",
150
+ htmlFor: "for",
151
+ formMethod: "formmethod",
152
+ formAction: "formaction",
153
+ formEncType: "formenctype",
154
+ formNoValidate: "formnovalidate",
155
+ formTarget: "formtarget",
156
+ frameBorder: "frameborder",
157
+ hrefLang: "hreflang",
158
+ httpEquiv: "http-equiv",
159
+ imageSizes: "imagesizes",
160
+ imageSrcSet: "imagesrcset",
161
+ inputMode: "inputmode",
162
+ itemID: "itemid",
163
+ itemProp: "itemprop",
164
+ itemRef: "itemref",
165
+ itemScope: "itemscope",
166
+ itemType: "itemtype",
167
+ keyParams: "keyparams",
168
+ keyType: "keytype",
169
+ marginWidth: "marginwidth",
170
+ marginHeight: "marginheight",
171
+ maxLength: "maxlength",
172
+ mediaGroup: "mediagroup",
173
+ noModule: "nomodule",
174
+ noValidate: "novalidate",
175
+ playsInline: "playsinline",
176
+ radioGroup: "radiogroup",
177
+ readOnly: "readonly",
178
+ referrerPolicy: "referrerpolicy",
179
+ rowSpan: "rowspan",
180
+ spellCheck: "spellcheck",
181
+ srcDoc: "srcdoc",
182
+ srcLang: "srclang",
183
+ srcSet: "srcset",
184
+ tabIndex: "tabindex",
185
+ useMap: "usemap",
186
+ accentHeight: "accent-height",
187
+ alignmentBaseline: "alignment-baseline",
188
+ arabicForm: "arabic-form",
189
+ attributeName: "attributename",
190
+ attributeType: "attributetype",
191
+ autoReverse: "autoreverse",
192
+ baseFrequency: "basefrequency",
193
+ baselineShift: "baseline-shift",
194
+ baseProfile: "baseprofile",
195
+ calcMode: "calcmode",
196
+ capHeight: "cap-height",
197
+ clipPath: "clip-path",
198
+ clipPathUnits: "clippathunits",
199
+ clipRule: "clip-rule",
200
+ colorInterpolation: "color-interpolation",
201
+ colorInterpolationFilters: "color-interpolation-filters",
202
+ colorProfile: "color-profile",
203
+ colorRendering: "color-rendering",
204
+ contentScriptType: "contentscripttype",
205
+ contentStyleType: "contentstyletype",
206
+ diffuseConstant: "diffuseconstant",
207
+ dominantBaseline: "dominant-baseline",
208
+ enableBackground: "enable-background",
209
+ externalResourcesRequired: "externalresourcesrequired",
210
+ fillOpacity: "fill-opacity",
211
+ fillRule: "fill-rule",
212
+ filterRes: "filterres",
213
+ filterUnits: "filterunits",
214
+ floodOpacity: "flood-opacity",
215
+ floodColor: "flood-color",
216
+ fontFamily: "font-family",
217
+ fontSize: "font-size",
218
+ fontSizeAdjust: "font-size-adjust",
219
+ fontStretch: "font-stretch",
220
+ fontStyle: "font-style",
221
+ fontVariant: "font-variant",
222
+ fontWeight: "font-weight",
223
+ glyphName: "glyph-name",
224
+ glyphOrientationHorizontal: "glyph-orientation-horizontal",
225
+ glyphOrientationVertical: "glyph-orientation-vertical",
226
+ gradientTransform: "gradienttransform",
227
+ gradientUnits: "gradientunits",
228
+ horizAdvX: "horiz-adv-x",
229
+ horizOriginX: "horiz-origin-x",
230
+ imageRendering: "image-rendering",
231
+ kernelMatrix: "kernelmatrix",
232
+ kernelUnitLength: "kernelunitlength",
233
+ keyPoints: "keypoints",
234
+ keySplines: "keysplines",
235
+ keyTimes: "keytimes",
236
+ lengthAdjust: "lengthadjust",
237
+ letterSpacing: "letter-spacing",
238
+ lightingColor: "lighting-color",
239
+ limitingConeAngle: "limitingconeangle",
240
+ markerEnd: "marker-end",
241
+ markerHeight: "markerheight",
242
+ markerMid: "marker-mid",
243
+ markerStart: "marker-start",
244
+ markerUnits: "markerunits",
245
+ markerWidth: "markerwidth",
246
+ maskContentUnits: "maskcontentunits",
247
+ maskUnits: "maskunits",
248
+ numOctaves: "numoctaves",
249
+ overlinePosition: "overline-position",
250
+ overlineThickness: "overline-thickness",
251
+ paintOrder: "paint-order",
252
+ panose1: "panose-1",
253
+ pathLength: "pathlength",
254
+ patternContentUnits: "patterncontentunits",
255
+ patternTransform: "patterntransform",
256
+ patternUnits: "patternunits",
257
+ pointerEvents: "pointer-events",
258
+ pointsAtX: "pointsatx",
259
+ pointsAtY: "pointsaty",
260
+ pointsAtZ: "pointsatz",
261
+ preserveAlpha: "preservealpha",
262
+ preserveAspectRatio: "preserveaspectratio",
263
+ primitiveUnits: "primitiveunits",
264
+ refX: "refx",
265
+ refY: "refy",
266
+ renderingIntent: "rendering-intent",
267
+ repeatCount: "repeatcount",
268
+ repeatDur: "repeatdur",
269
+ requiredExtensions: "requiredextensions",
270
+ requiredFeatures: "requiredfeatures",
271
+ shapeRendering: "shape-rendering",
272
+ slot: "slot",
273
+ specularConstant: "specularconstant",
274
+ specularExponent: "specularexponent",
275
+ spreadMethod: "spreadmethod",
276
+ startOffset: "startoffset",
277
+ stdDeviation: "stddeviation",
278
+ stitchTiles: "stitchtiles",
279
+ stopColor: "stop-color",
280
+ stopOpacity: "stop-opacity",
281
+ strikethroughPosition: "strikethrough-position",
282
+ strikethroughThickness: "strikethrough-thickness",
283
+ strokeDasharray: "stroke-dasharray",
284
+ strokeDashoffset: "stroke-dashoffset",
285
+ strokeLinecap: "stroke-linecap",
286
+ strokeLinejoin: "stroke-linejoin",
287
+ strokeMiterlimit: "stroke-miterlimit",
288
+ strokeWidth: "stroke-width",
289
+ strokeOpacity: "stroke-opacity",
290
+ suppressContentEditableWarning: "suppresscontenteditablewarning",
291
+ suppressHydrationWarning: "suppresshydrationwarning",
292
+ surfaceScale: "surfacescale",
293
+ systemLanguage: "systemlanguage",
294
+ tableValues: "tablevalues",
295
+ targetX: "targetx",
296
+ targetY: "targety",
297
+ textAnchor: "text-anchor",
298
+ textDecoration: "text-decoration",
299
+ textLength: "textlength",
300
+ textRendering: "text-rendering",
301
+ transformOrigin: "transform-origin",
302
+ underlinePosition: "underline-position",
303
+ underlineThickness: "underline-thickness",
304
+ unicodeBidi: "unicode-bidi",
305
+ unicodeRange: "unicode-range",
306
+ unitsPerEm: "units-per-em",
307
+ vectorEffect: "vector-effect",
308
+ vertAdvY: "vert-adv-y",
309
+ vertOriginX: "vert-origin-x",
310
+ vertOriginY: "vert-origin-y",
311
+ wordSpacing: "word-spacing",
312
+ writingMode: "writing-mode",
313
+ xChannelSelector: "xchannelselector",
314
+ xHeight: "x-height",
315
+ xlinkActuate: "xlink:actuate",
316
+ xlinkArcrole: "xlink:arcrole",
317
+ xlinkHref: "xlink:href",
318
+ xlinkRole: "xlink:role",
319
+ xlinkShow: "xlink:show",
320
+ xlinkTitle: "xlink:title",
321
+ xlinkType: "xlink:type",
322
+ xmlBase: "xml:base",
323
+ xmlLang: "xml:lang",
324
+ xmlnsXlink: "xmlns:xlink",
325
+ yChannelSelector: "ychannelselector",
326
+ zoomAndPan: "zoomandpan"
327
+ }, V = "[react-output-target]", u = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", h = (e) => e == null, R = (e) => Array.isArray(e), B = (e) => !!e && /^\s*class\s+/.test(e.toString()), X = (e) => !!e && typeof e == "object" && "_payload" in e, Y = (e) => !!e && typeof e == "object" && "$$typeof" in e && ("render" in e || "type" in e && "compare" in e), K = (e) => async ({ children: t, ...n }: any = {}) => {
328
+ if (!("process" in globalThis) || typeof window < "u")
329
+ throw new Error("`createComponentForServerSideRendering` can only be run on the server");
330
+ let r = "";
331
+ const i = {};
332
+ for (const [a, o] of Object.entries(n)) {
333
+ // Component properties must reach Stencil unchanged, including explicit false,
334
+ // null, numbers, objects and functions. Attributes alone can lose their type.
335
+ if (a === "ref" || a === "key" || /^on/i.test(a)) continue;
336
+ const componentProperty = Object.prototype.hasOwnProperty.call(e.properties, a);
337
+ if (componentProperty) i[a] = o;
338
+ if (o == null) continue;
339
+ const c = e.properties[a] || E[a] || a;
340
+ if (!/^[^\s"'<>/=]+$/.test(c)) continue;
341
+ const arrayAttribute = Array.isArray(o) ? getSsrArrayAttribute(e.tagName, c, o) : undefined;
342
+ if (arrayAttribute) {
343
+ i[a] = o;
344
+ r += ` ${arrayAttribute}="${escapeAttribute(JSON.stringify(o))}"`;
345
+ } else if (a === "style" && typeof o === "object") {
346
+ r += ` ${c}="${escapeAttribute(G(o))}"`;
347
+ } else if (u(o)) {
348
+ // A native disabled attribute disables form-associated custom elements
349
+ // by presence. Keep the false property above for Stencil's initial render.
350
+ // Other Stencil boolean props, ARIA and data attributes can use "false".
351
+ if (o === false && (c === "disabled" || (!componentProperty && !/^(aria-|data-)/.test(c)))) continue;
352
+ r += ` ${c}="${escapeAttribute(o)}"`;
353
+ } else if (!componentProperty) {
354
+ i[a] = o;
355
+ }
356
+ }
357
+ let s = "";
358
+ const p = e.transformTag ? e.transformTag(e.tagName) : e.tagName, x = `<${p}${r} suppressHydrationWarning="true">`;
359
+ try {
360
+ const a = await k(t), { renderToString: o } = await import("react-dom/server");
361
+ s = o(a).replace(/\n\s+/g, "");
362
+ } catch (a) {
363
+ if (process.env.STENCIL_SSR_DEBUG) {
364
+ const o = a instanceof Error ? a : new Error("Unknown error");
365
+ console.warn(
366
+ `${V} Failed to serialize light DOM for ${x.slice(0, -1)} />: ${o.message} - this may impact the hydration of the component`
367
+ );
368
+ }
369
+ }
370
+ let hostStyle: string | undefined;
371
+ const P = `${x}${s}</${p}>`, { html: g, styles: b } = await e.renderToString(P, {
372
+ fullDocument: !1,
373
+ serializeShadowRoot: e.serializeShadowRoot ?? "declarative-shadow-dom",
374
+ prettyHtml: !0,
375
+ // Preserve final host styles through React's serializer, including when
376
+ // paired with a Core renderer predating the quoted-CSS serialization fix.
377
+ afterHydrate: (document) => {
378
+ const host = document.querySelector(p);
379
+ if (host?.hasAttribute('style')) {
380
+ hostStyle = host.getAttribute('style');
381
+ host.removeAttribute('style');
382
+ }
383
+ },
384
+ ...Object.keys(i).length > 0 && {
385
+ beforeHydrate: (a) => {
386
+ const o = a.querySelector(p);
387
+ if (o)
388
+ for (const [c, m] of Object.entries(i))
389
+ o[c] = m;
390
+ }
391
+ }
392
+ });
393
+ if (!g)
394
+ throw new Error("No HTML returned from renderToString");
395
+ const d = g.split(`
396
+ `), $ = "<!--r.1-->", w = d[1].includes('shadowrootmode="open"'), O = d[1].includes("shadowrootdelegatesfocus");
397
+ let T;
398
+ w && (T = d.slice(2, d.lastIndexOf(" </template>")).join(`
399
+ `).trim());
400
+ const { default: M, attributesToProps } = await import("html-react-parser");
401
+ const preservedStyle = hostStyle === undefined ? {} : attributesToProps({ style: hostStyle });
402
+ const L = M, H = () => L(g, {
403
+ transform(a, o) {
404
+ if ("name" in o && (o.name === p || o.name === e.tagName)) {
405
+ const c = { ...(a as l.ReactElement<any>).props, ...preservedStyle }, m = `${p}`;
406
+ if (!w) {
407
+ const { children: Z, ...I } = c || {}, j = d.slice(1, -1).join(`
408
+ `).trim().replace(new RegExp("(?<=>)\\s+(?=<)", "g"), "").replace(/\n\s+/g, ""), _ = b.length > 0 && b.map((f, A) => /* @__PURE__ */ l.createElement(
409
+ "style",
410
+ {
411
+ href: `stencil-${f.id || e.tagName}`,
412
+ key: f.id || A,
413
+ id: f.id,
414
+ precedence: "stencil",
415
+ suppressHydrationWarning: !0,
416
+ dangerouslySetInnerHTML: { __html: f.content || "" }
417
+ }
418
+ ));
419
+ return /* @__PURE__ */ l.createElement(N, null, _, /* @__PURE__ */ l.createElement(m, { ...I, suppressHydrationWarning: !0, dangerouslySetInnerHTML: { __html: j } }));
420
+ }
421
+ return /* @__PURE__ */ l.createElement(m, { ...c, suppressHydrationWarning: !0 }, /* @__PURE__ */ l.createElement(
422
+ "template",
423
+ {
424
+ shadowrootmode: "open",
425
+ ...O ? { shadowrootdelegatesfocus: "" } : {},
426
+ suppressHydrationWarning: !0,
427
+ dangerouslySetInnerHTML: { __html: $ + T }
428
+ }
429
+ ), t);
430
+ }
431
+ }
432
+ });
433
+ return /* @__PURE__ */ l.createElement(H, null);
434
+ };
435
+ async function k(e) {
436
+ return u(e) || h(e) ? e : (R(e) || (e = [e]), Promise.all(
437
+ Array.from(e).map(async (t) => {
438
+ if (u(t) || h(t))
439
+ return t;
440
+ if (R(t))
441
+ return k(t);
442
+ if (!l.isValidElement(t))
443
+ return t;
444
+ const { type: n, props: r } = t as l.ReactElement<any>, i = await S(n, r);
445
+ return l.isValidElement(i) ? i : {
446
+ ...t,
447
+ props: {
448
+ ...r,
449
+ children: await k(r.children)
450
+ },
451
+ type: i
452
+ };
453
+ })
454
+ ));
455
+ }
456
+ const S = async (e, t) => {
457
+ let n = null;
458
+ if (typeof e == "string")
459
+ return e;
460
+ if (B(e)) {
461
+ const r = new e(t, void 0);
462
+ n = r.render ? r.render() : r;
463
+ } else if (X(e)) {
464
+ const r = e._payload;
465
+ let i;
466
+ if (typeof e._init == "function" && r._result === void 0) {
467
+ const s = await e._init(r);
468
+ i = (s == null ? void 0 : s.default) ?? s;
469
+ } else {
470
+ const { default: s } = r._status === -1 ? await r._result() : r._result;
471
+ i = s;
472
+ }
473
+ n = await S(i, t);
474
+ } else {
475
+ if (Y(e))
476
+ return e;
477
+ typeof e != "object" && (n = await e(t));
478
+ }
479
+ return !h(n) && !u(n) && l.isValidElement(n) && (n = await S(n.type, t)), n;
480
+ };
481
+ let y = null;
482
+ const ee = (e) => {
483
+ if (typeof window < "u") {
484
+ if (e.clientModule)
485
+ return e.clientModule;
486
+ if (C)
487
+ return (C as any)({
488
+ tagName: e.tagName,
489
+ properties: e.properties
490
+ });
491
+ }
492
+ return async (t) => {
493
+ if (!e.hydrateModule)
494
+ throw new Error(
495
+ "`hydrateModule` is required when rendering a Stencil component on the server. This indicates a misconfiguration of the Stencil React output target."
496
+ );
497
+ let n = !1;
498
+ y || (y = await e.hydrateModule, n = !0);
499
+ const r = y;
500
+ if (e.getTagTransformer && n) {
501
+ const i = e.getTagTransformer();
502
+ i && r.setTagTransformer(i);
503
+ }
504
+ return e.transformTag = r.transformTag, K({
505
+ renderToString: r.renderToString,
506
+ ...e
507
+ })(t);
508
+ };
509
+ };
510
+ export const createComponent: typeof import('@stencil/react-output-target/ssr').createComponent = ee;
511
+ export type { HydrateModule, SerializeShadowRootOptions } from '@stencil/react-output-target/ssr';