@tmorrow/cre8-wc 2.0.2 → 2.0.4
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/a2ui/catalog.json +5622 -0
- package/a2ui/demo.html +287 -0
- package/a2ui/generate-catalog.mjs +243 -0
- package/a2ui/index.d.ts +4 -0
- package/a2ui/index.js +2 -0
- package/a2ui/index.ts +12 -0
- package/a2ui/registry.d.ts +3 -0
- package/a2ui/registry.js +166 -0
- package/a2ui/registry.ts +182 -0
- package/a2ui/renderer.d.ts +7 -0
- package/a2ui/renderer.js +108 -0
- package/a2ui/renderer.ts +156 -0
- package/a2ui/smoke-test.mjs +238 -0
- package/a2ui/types.d.ts +75 -0
- package/a2ui/types.js +1 -0
- package/a2ui/types.ts +80 -0
- package/cdn/cre8-wc.esm.js +3363 -2861
- package/cdn/cre8-wc.esm.js.map +1 -1
- package/cdn/cre8-wc.min.js +765 -262
- package/cdn/cre8-wc.min.js.map +1 -1
- package/lib/a2ui/index.d.ts +5 -0
- package/lib/a2ui/index.d.ts.map +1 -0
- package/lib/a2ui/index.js +3 -0
- package/lib/a2ui/index.js.map +1 -0
- package/lib/a2ui/registry.d.ts +4 -0
- package/lib/a2ui/registry.d.ts.map +1 -0
- package/lib/a2ui/registry.js +167 -0
- package/lib/a2ui/registry.js.map +1 -0
- package/lib/a2ui/renderer.d.ts +8 -0
- package/lib/a2ui/renderer.d.ts.map +1 -0
- package/lib/a2ui/renderer.js +109 -0
- package/lib/a2ui/renderer.js.map +1 -0
- package/lib/a2ui/types.d.ts +76 -0
- package/lib/a2ui/types.d.ts.map +1 -0
- package/lib/a2ui/types.js +2 -0
- package/lib/a2ui/types.js.map +1 -0
- package/lib/components/icon/icon.d.ts +2 -1
- package/lib/components/icon/icon.d.ts.map +1 -1
- package/lib/components/icon/icon.js +56 -55
- package/lib/components/icon/icon.js.map +1 -1
- package/lib/vite.config.cdn.js +1 -1
- package/lib/vite.config.cdn.js.map +1 -1
- package/lib/vite.config.js +1 -1
- package/lib/vite.config.js.map +1 -1
- package/mcp-manifest.json +2 -2
- package/package.json +15 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { CatalogComponentDef, CatalogSchema, ComponentSpec, EmittedEvent, EventBinding, PropSchema, RegisteredCatalog, } from './types.js';
|
|
2
|
+
export { registerCatalog, validateSpec } from './registry.js';
|
|
3
|
+
export { render } from './renderer.js';
|
|
4
|
+
export type { RenderOptions } from './renderer.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../a2ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../a2ui/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export type {\n CatalogComponentDef,\n CatalogSchema,\n ComponentSpec,\n EmittedEvent,\n EventBinding,\n PropSchema,\n RegisteredCatalog,\n} from './types.js';\nexport { registerCatalog, validateSpec } from './registry.js';\nexport { render } from './renderer.js';\nexport type { RenderOptions } from './renderer.js';\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CatalogSchema, ComponentSpec, RegisteredCatalog } from './types.js';
|
|
2
|
+
export declare function registerCatalog(schema: CatalogSchema): RegisteredCatalog;
|
|
3
|
+
export declare function validateSpec(spec: unknown, catalog: RegisteredCatalog, path?: string): asserts spec is ComponentSpec;
|
|
4
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../a2ui/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAc,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE9F,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAKxE;AA+FD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,SAAM,GAAG,OAAO,CAAC,IAAI,IAAI,aAAa,CA+EjH"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export function registerCatalog(schema) {
|
|
2
|
+
const defs = schema.$defs?.components ?? {};
|
|
3
|
+
const components = new Map(Object.entries(defs));
|
|
4
|
+
const id = schema['x-a2ui']?.catalogId ?? schema.$id ?? 'unknown';
|
|
5
|
+
return { id, schema, components };
|
|
6
|
+
}
|
|
7
|
+
function validatePropValue(value, schema, path) {
|
|
8
|
+
if (value === undefined || value === null)
|
|
9
|
+
return;
|
|
10
|
+
if (!schema)
|
|
11
|
+
return;
|
|
12
|
+
if (schema.const !== undefined && value !== schema.const) {
|
|
13
|
+
throw new Error(`${path}: expected const ${JSON.stringify(schema.const)}, got ${JSON.stringify(value)}`);
|
|
14
|
+
}
|
|
15
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
16
|
+
const allowed = schema.enum.map((v) => JSON.stringify(v)).join(', ');
|
|
17
|
+
throw new Error(`${path}: value ${JSON.stringify(value)} not in enum [${allowed}]`);
|
|
18
|
+
}
|
|
19
|
+
if (schema.oneOf && schema.oneOf.length) {
|
|
20
|
+
const errors = [];
|
|
21
|
+
for (const branch of schema.oneOf) {
|
|
22
|
+
try {
|
|
23
|
+
validatePropValue(value, branch, path);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
errors.push(e.message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`${path}: value ${JSON.stringify(value)} matched none of oneOf branches: ${errors.join(' | ')}`);
|
|
31
|
+
}
|
|
32
|
+
const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
|
|
33
|
+
if (types.length && !types.some((t) => matchesType(t, value))) {
|
|
34
|
+
throw new Error(`${path}: expected type ${types.join('|')}, got ${describeType(value)}`);
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(value) && schema.items) {
|
|
37
|
+
value.forEach((item, i) => validatePropValue(item, schema.items, `${path}[${i}]`));
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === 'object' &&
|
|
40
|
+
value !== null &&
|
|
41
|
+
!Array.isArray(value) &&
|
|
42
|
+
schema.properties) {
|
|
43
|
+
const obj = value;
|
|
44
|
+
if (schema.required) {
|
|
45
|
+
for (const req of schema.required) {
|
|
46
|
+
if (!(req in obj)) {
|
|
47
|
+
throw new Error(`${path}.${req}: required property missing`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const [key, childVal] of Object.entries(obj)) {
|
|
52
|
+
const childSchema = schema.properties[key];
|
|
53
|
+
if (!childSchema) {
|
|
54
|
+
if (schema.additionalProperties === false) {
|
|
55
|
+
throw new Error(`${path}.${key}: unexpected property`);
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
validatePropValue(childVal, childSchema, `${path}.${key}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function matchesType(t, v) {
|
|
64
|
+
switch (t) {
|
|
65
|
+
case 'string':
|
|
66
|
+
return typeof v === 'string';
|
|
67
|
+
case 'number':
|
|
68
|
+
return typeof v === 'number' && Number.isFinite(v);
|
|
69
|
+
case 'integer':
|
|
70
|
+
return typeof v === 'number' && Number.isInteger(v);
|
|
71
|
+
case 'boolean':
|
|
72
|
+
return typeof v === 'boolean';
|
|
73
|
+
case 'array':
|
|
74
|
+
return Array.isArray(v);
|
|
75
|
+
case 'object':
|
|
76
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
77
|
+
case 'null':
|
|
78
|
+
return v === null;
|
|
79
|
+
default:
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function describeType(v) {
|
|
84
|
+
if (v === null)
|
|
85
|
+
return 'null';
|
|
86
|
+
if (Array.isArray(v))
|
|
87
|
+
return 'array';
|
|
88
|
+
return typeof v;
|
|
89
|
+
}
|
|
90
|
+
export function validateSpec(spec, catalog, path = '$') {
|
|
91
|
+
if (!spec || typeof spec !== 'object') {
|
|
92
|
+
throw new Error(`${path}: spec must be an object`);
|
|
93
|
+
}
|
|
94
|
+
const s = spec;
|
|
95
|
+
if (typeof s.component !== 'string') {
|
|
96
|
+
throw new Error(`${path}: spec.component must be a string`);
|
|
97
|
+
}
|
|
98
|
+
if (!catalog.components.has(s.component)) {
|
|
99
|
+
throw new Error(`${path}: component "${s.component}" is not registered in catalog "${catalog.id}"`);
|
|
100
|
+
}
|
|
101
|
+
const def = catalog.components.get(s.component);
|
|
102
|
+
const allowedProps = new Set(Object.keys(def.properties?.props?.properties ?? {}));
|
|
103
|
+
const hasChildren = def.properties?.children !== undefined;
|
|
104
|
+
const allowedSlots = def.properties?.slots
|
|
105
|
+
? new Set(Object.keys(def.properties.slots.properties ?? {}))
|
|
106
|
+
: null;
|
|
107
|
+
if (s.props) {
|
|
108
|
+
if (typeof s.props !== 'object')
|
|
109
|
+
throw new Error(`${path}.props: must be an object`);
|
|
110
|
+
const propDefs = def.properties?.props?.properties ?? {};
|
|
111
|
+
for (const [prop, value] of Object.entries(s.props)) {
|
|
112
|
+
if (!allowedProps.has(prop)) {
|
|
113
|
+
throw new Error(`${path}.props.${prop}: not a declared prop on ${s.component}`);
|
|
114
|
+
}
|
|
115
|
+
validatePropValue(value, propDefs[prop], `${path}.props.${prop}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (s.children !== undefined) {
|
|
119
|
+
if (!hasChildren) {
|
|
120
|
+
throw new Error(`${path}.children: ${s.component} does not accept default children`);
|
|
121
|
+
}
|
|
122
|
+
if (!Array.isArray(s.children))
|
|
123
|
+
throw new Error(`${path}.children: must be an array`);
|
|
124
|
+
s.children.forEach((c, i) => {
|
|
125
|
+
if (typeof c === 'string')
|
|
126
|
+
return;
|
|
127
|
+
validateSpec(c, catalog, `${path}.children[${i}]`);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (s.events !== undefined) {
|
|
131
|
+
if (!s.events || typeof s.events !== 'object' || Array.isArray(s.events)) {
|
|
132
|
+
throw new Error(`${path}.events: must be an object`);
|
|
133
|
+
}
|
|
134
|
+
for (const [evtName, binding] of Object.entries(s.events)) {
|
|
135
|
+
if (typeof binding === 'string')
|
|
136
|
+
continue;
|
|
137
|
+
if (!binding || typeof binding !== 'object') {
|
|
138
|
+
throw new Error(`${path}.events.${evtName}: must be a string or { handler } object`);
|
|
139
|
+
}
|
|
140
|
+
const b = binding;
|
|
141
|
+
if (typeof b.handler !== 'string' || b.handler.length === 0) {
|
|
142
|
+
throw new Error(`${path}.events.${evtName}.handler: must be a non-empty string`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (s.slots !== undefined) {
|
|
147
|
+
if (!allowedSlots) {
|
|
148
|
+
throw new Error(`${path}.slots: ${s.component} does not accept named slots`);
|
|
149
|
+
}
|
|
150
|
+
if (typeof s.slots !== 'object')
|
|
151
|
+
throw new Error(`${path}.slots: must be an object`);
|
|
152
|
+
for (const [slotName, arr] of Object.entries(s.slots)) {
|
|
153
|
+
if (!allowedSlots.has(slotName)) {
|
|
154
|
+
throw new Error(`${path}.slots.${slotName}: not a declared slot on ${s.component}`);
|
|
155
|
+
}
|
|
156
|
+
if (!Array.isArray(arr)) {
|
|
157
|
+
throw new Error(`${path}.slots.${slotName}: must be an array`);
|
|
158
|
+
}
|
|
159
|
+
arr.forEach((c, i) => {
|
|
160
|
+
if (typeof c === 'string')
|
|
161
|
+
return;
|
|
162
|
+
validateSpec(c, catalog, `${path}.slots.${slotName}[${i}]`);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../a2ui/registry.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,UAAU,IAAI,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,IAAI,MAAM,CAAC,GAAG,IAAI,SAAS,CAAC;IAClE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,MAA8B,EAAE,IAAY;IACrF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAClD,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACxF,CAAC;IACJ,CAAC;IAED,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AAC;YACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,UAAU,QAAQ,oBAAoB,CAAC,CAAC;YACjE,CAAC;YACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACnB,IAAI,OAAO,CAAC,KAAK,QAAQ;oBAAE,OAAO;gBAClC,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,UAAU,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { CatalogSchema, ComponentSpec, PropSchema, RegisteredCatalog } from './types.js';\n\nexport function registerCatalog(schema: CatalogSchema): RegisteredCatalog {\n const defs = schema.$defs?.components ?? {};\n const components = new Map(Object.entries(defs));\n const id = schema['x-a2ui']?.catalogId ?? schema.$id ?? 'unknown';\n return { id, schema, components };\n}\n\nfunction validatePropValue(value: unknown, schema: PropSchema | undefined, path: string): void {\n if (value === undefined || value === null) return;\n if (!schema) return;\n\n if (schema.const !== undefined && value !== schema.const) {\n throw new Error(\n `${path}: expected const ${JSON.stringify(schema.const)}, got ${JSON.stringify(value)}`\n );\n }\n\n if (schema.enum && !schema.enum.includes(value as string)) {\n const allowed = schema.enum.map((v) => JSON.stringify(v)).join(', ');\n throw new Error(`${path}: value ${JSON.stringify(value)} not in enum [${allowed}]`);\n }\n\n if (schema.oneOf && schema.oneOf.length) {\n const errors: string[] = [];\n for (const branch of schema.oneOf) {\n try {\n validatePropValue(value, branch, path);\n return;\n } catch (e) {\n errors.push((e as Error).message);\n }\n }\n throw new Error(\n `${path}: value ${JSON.stringify(value)} matched none of oneOf branches: ${errors.join(' | ')}`\n );\n }\n\n const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];\n if (types.length && !types.some((t) => matchesType(t, value))) {\n throw new Error(`${path}: expected type ${types.join('|')}, got ${describeType(value)}`);\n }\n\n if (Array.isArray(value) && schema.items) {\n value.forEach((item, i) => validatePropValue(item, schema.items, `${path}[${i}]`));\n }\n\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n schema.properties\n ) {\n const obj = value as Record<string, unknown>;\n if (schema.required) {\n for (const req of schema.required) {\n if (!(req in obj)) {\n throw new Error(`${path}.${req}: required property missing`);\n }\n }\n }\n for (const [key, childVal] of Object.entries(obj)) {\n const childSchema = schema.properties[key];\n if (!childSchema) {\n if (schema.additionalProperties === false) {\n throw new Error(`${path}.${key}: unexpected property`);\n }\n continue;\n }\n validatePropValue(childVal, childSchema, `${path}.${key}`);\n }\n }\n}\n\nfunction matchesType(t: string, v: unknown): boolean {\n switch (t) {\n case 'string':\n return typeof v === 'string';\n case 'number':\n return typeof v === 'number' && Number.isFinite(v);\n case 'integer':\n return typeof v === 'number' && Number.isInteger(v);\n case 'boolean':\n return typeof v === 'boolean';\n case 'array':\n return Array.isArray(v);\n case 'object':\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n case 'null':\n return v === null;\n default:\n return true;\n }\n}\n\nfunction describeType(v: unknown): string {\n if (v === null) return 'null';\n if (Array.isArray(v)) return 'array';\n return typeof v;\n}\n\nexport function validateSpec(spec: unknown, catalog: RegisteredCatalog, path = '$'): asserts spec is ComponentSpec {\n if (!spec || typeof spec !== 'object') {\n throw new Error(`${path}: spec must be an object`);\n }\n const s = spec as Record<string, unknown>;\n if (typeof s.component !== 'string') {\n throw new Error(`${path}: spec.component must be a string`);\n }\n if (!catalog.components.has(s.component)) {\n throw new Error(\n `${path}: component \"${s.component}\" is not registered in catalog \"${catalog.id}\"`\n );\n }\n\n const def = catalog.components.get(s.component)!;\n const allowedProps = new Set(Object.keys(def.properties?.props?.properties ?? {}));\n const hasChildren = def.properties?.children !== undefined;\n const allowedSlots = def.properties?.slots\n ? new Set(Object.keys(def.properties.slots.properties ?? {}))\n : null;\n\n if (s.props) {\n if (typeof s.props !== 'object') throw new Error(`${path}.props: must be an object`);\n const propDefs = def.properties?.props?.properties ?? {};\n for (const [prop, value] of Object.entries(s.props as Record<string, unknown>)) {\n if (!allowedProps.has(prop)) {\n throw new Error(`${path}.props.${prop}: not a declared prop on ${s.component}`);\n }\n validatePropValue(value, propDefs[prop], `${path}.props.${prop}`);\n }\n }\n\n if (s.children !== undefined) {\n if (!hasChildren) {\n throw new Error(`${path}.children: ${s.component} does not accept default children`);\n }\n if (!Array.isArray(s.children)) throw new Error(`${path}.children: must be an array`);\n s.children.forEach((c, i) => {\n if (typeof c === 'string') return;\n validateSpec(c, catalog, `${path}.children[${i}]`);\n });\n }\n\n if (s.events !== undefined) {\n if (!s.events || typeof s.events !== 'object' || Array.isArray(s.events)) {\n throw new Error(`${path}.events: must be an object`);\n }\n for (const [evtName, binding] of Object.entries(s.events as Record<string, unknown>)) {\n if (typeof binding === 'string') continue;\n if (!binding || typeof binding !== 'object') {\n throw new Error(`${path}.events.${evtName}: must be a string or { handler } object`);\n }\n const b = binding as Record<string, unknown>;\n if (typeof b.handler !== 'string' || b.handler.length === 0) {\n throw new Error(`${path}.events.${evtName}.handler: must be a non-empty string`);\n }\n }\n }\n\n if (s.slots !== undefined) {\n if (!allowedSlots) {\n throw new Error(`${path}.slots: ${s.component} does not accept named slots`);\n }\n if (typeof s.slots !== 'object') throw new Error(`${path}.slots: must be an object`);\n for (const [slotName, arr] of Object.entries(s.slots as Record<string, unknown>)) {\n if (!allowedSlots.has(slotName)) {\n throw new Error(\n `${path}.slots.${slotName}: not a declared slot on ${s.component}`\n );\n }\n if (!Array.isArray(arr)) {\n throw new Error(`${path}.slots.${slotName}: must be an array`);\n }\n arr.forEach((c, i) => {\n if (typeof c === 'string') return;\n validateSpec(c, catalog, `${path}.slots.${slotName}[${i}]`);\n });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentSpec, EmittedEvent, RegisteredCatalog } from './types.js';
|
|
2
|
+
export interface RenderOptions {
|
|
3
|
+
root?: HTMLElement;
|
|
4
|
+
doc?: Document;
|
|
5
|
+
onEvent?: (evt: EmittedEvent) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function render(spec: ComponentSpec, catalog: RegisteredCatalog, options?: RenderOptions): HTMLElement;
|
|
8
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../a2ui/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAGZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;CACvC;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,aAAkB,GAC1B,WAAW,CAMb"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { validateSpec } from './registry.js';
|
|
2
|
+
export function render(spec, catalog, options = {}) {
|
|
3
|
+
validateSpec(spec, catalog);
|
|
4
|
+
const doc = options.doc ?? document;
|
|
5
|
+
const el = buildElement(spec, catalog, doc, '$', options.onEvent);
|
|
6
|
+
if (options.root)
|
|
7
|
+
options.root.replaceChildren(el);
|
|
8
|
+
return el;
|
|
9
|
+
}
|
|
10
|
+
function buildElement(spec, catalog, doc, path, onEvent) {
|
|
11
|
+
const def = catalog.components.get(spec.component);
|
|
12
|
+
const propDefs = def.properties?.props?.properties ?? {};
|
|
13
|
+
const el = doc.createElement(spec.component);
|
|
14
|
+
if (spec.props) {
|
|
15
|
+
for (const [key, value] of Object.entries(spec.props)) {
|
|
16
|
+
applyProp(el, key, value, propDefs[key]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (spec.events && onEvent) {
|
|
20
|
+
for (const [evtName, binding] of Object.entries(spec.events)) {
|
|
21
|
+
attachEvent(el, spec.component, path, evtName, binding, onEvent);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (spec.children) {
|
|
25
|
+
spec.children.forEach((child, i) => {
|
|
26
|
+
if (typeof child === 'string') {
|
|
27
|
+
el.appendChild(doc.createTextNode(child));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
el.appendChild(buildElement(child, catalog, doc, `${path}.children[${i}]`, onEvent));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (spec.slots) {
|
|
34
|
+
for (const [slotName, children] of Object.entries(spec.slots)) {
|
|
35
|
+
children.forEach((child, i) => {
|
|
36
|
+
if (typeof child === 'string') {
|
|
37
|
+
if (slotName === 'default') {
|
|
38
|
+
el.appendChild(doc.createTextNode(child));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const wrap = doc.createElement('span');
|
|
42
|
+
wrap.setAttribute('slot', slotName);
|
|
43
|
+
wrap.textContent = child;
|
|
44
|
+
el.appendChild(wrap);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const childEl = buildElement(child, catalog, doc, `${path}.slots.${slotName}[${i}]`, onEvent);
|
|
49
|
+
if (slotName !== 'default')
|
|
50
|
+
childEl.setAttribute('slot', slotName);
|
|
51
|
+
el.appendChild(childEl);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return el;
|
|
56
|
+
}
|
|
57
|
+
function attachEvent(el, component, path, eventName, binding, onEvent) {
|
|
58
|
+
const handler = typeof binding === 'string' ? binding : binding.handler;
|
|
59
|
+
const stop = typeof binding === 'object' && binding.stopPropagation === true;
|
|
60
|
+
const prevent = typeof binding === 'object' && binding.preventDefault === true;
|
|
61
|
+
el.addEventListener(eventName, (nativeEvent) => {
|
|
62
|
+
if (stop)
|
|
63
|
+
nativeEvent.stopPropagation();
|
|
64
|
+
if (prevent)
|
|
65
|
+
nativeEvent.preventDefault();
|
|
66
|
+
const detail = 'detail' in nativeEvent
|
|
67
|
+
? nativeEvent.detail
|
|
68
|
+
: undefined;
|
|
69
|
+
onEvent({
|
|
70
|
+
component,
|
|
71
|
+
path,
|
|
72
|
+
event: eventName,
|
|
73
|
+
handler,
|
|
74
|
+
detail,
|
|
75
|
+
nativeEvent,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function applyProp(el, key, value, schema) {
|
|
80
|
+
if (value === undefined || value === null)
|
|
81
|
+
return;
|
|
82
|
+
if (schema?.['x-kind'] === 'property') {
|
|
83
|
+
el[key] = value;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (typeof value === 'boolean') {
|
|
87
|
+
if (value)
|
|
88
|
+
el.setAttribute(key, '');
|
|
89
|
+
else
|
|
90
|
+
el.removeAttribute(key);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (Array.isArray(value) || (typeof value === 'object' && value !== null)) {
|
|
94
|
+
el[key] = value;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (schema && isComplexSchema(schema)) {
|
|
98
|
+
el[key] = value;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
el.setAttribute(key, String(value));
|
|
102
|
+
}
|
|
103
|
+
function isComplexSchema(schema) {
|
|
104
|
+
const t = schema.type;
|
|
105
|
+
if (Array.isArray(t))
|
|
106
|
+
return t.some((x) => x === 'object' || x === 'array');
|
|
107
|
+
return t === 'object' || t === 'array';
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../a2ui/renderer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,C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\n PropSchema,\n RegisteredCatalog,\n} from './types.js';\nimport { validateSpec } from './registry.js';\n\nexport interface RenderOptions {\n root?: HTMLElement;\n doc?: Document;\n onEvent?: (evt: EmittedEvent) => void;\n}\n\nexport function render(\n spec: ComponentSpec,\n catalog: RegisteredCatalog,\n options: RenderOptions = {}\n): HTMLElement {\n validateSpec(spec, catalog);\n const doc = options.doc ?? document;\n const el = buildElement(spec, catalog, doc, '$', options.onEvent);\n if (options.root) options.root.replaceChildren(el);\n return el;\n}\n\nfunction buildElement(\n spec: ComponentSpec,\n catalog: RegisteredCatalog,\n doc: Document,\n path: string,\n onEvent?: (evt: EmittedEvent) => void\n): HTMLElement {\n const def = catalog.components.get(spec.component)!;\n const propDefs = def.properties?.props?.properties ?? {};\n const el = doc.createElement(spec.component);\n\n if (spec.props) {\n for (const [key, value] of Object.entries(spec.props)) {\n applyProp(el, key, value, propDefs[key]);\n }\n }\n\n if (spec.events && onEvent) {\n for (const [evtName, binding] of Object.entries(spec.events)) {\n attachEvent(el, spec.component, path, evtName, binding, onEvent);\n }\n }\n\n if (spec.children) {\n spec.children.forEach((child, i) => {\n if (typeof child === 'string') {\n el.appendChild(doc.createTextNode(child));\n return;\n }\n el.appendChild(buildElement(child, catalog, doc, `${path}.children[${i}]`, onEvent));\n });\n }\n\n if (spec.slots) {\n for (const [slotName, children] of Object.entries(spec.slots)) {\n children.forEach((child, i) => {\n if (typeof child === 'string') {\n if (slotName === 'default') {\n el.appendChild(doc.createTextNode(child));\n } else {\n const wrap = doc.createElement('span');\n wrap.setAttribute('slot', slotName);\n wrap.textContent = child;\n el.appendChild(wrap);\n }\n return;\n }\n const childEl = buildElement(\n child,\n catalog,\n doc,\n `${path}.slots.${slotName}[${i}]`,\n onEvent\n );\n if (slotName !== 'default') childEl.setAttribute('slot', slotName);\n el.appendChild(childEl);\n });\n }\n }\n\n return el;\n}\n\nfunction attachEvent(\n el: HTMLElement,\n component: string,\n path: string,\n eventName: string,\n binding: EventBinding,\n onEvent: (evt: EmittedEvent) => void\n): void {\n const handler = typeof binding === 'string' ? binding : binding.handler;\n const stop = typeof binding === 'object' && binding.stopPropagation === true;\n const prevent = typeof binding === 'object' && binding.preventDefault === true;\n\n el.addEventListener(eventName, (nativeEvent) => {\n if (stop) nativeEvent.stopPropagation();\n if (prevent) nativeEvent.preventDefault();\n const detail = 'detail' in nativeEvent\n ? (nativeEvent as CustomEvent).detail\n : undefined;\n onEvent({\n component,\n path,\n event: eventName,\n handler,\n detail,\n nativeEvent,\n });\n });\n}\n\nfunction applyProp(\n el: HTMLElement,\n key: string,\n value: unknown,\n schema: PropSchema | undefined\n): void {\n if (value === undefined || value === null) return;\n\n if (schema?.['x-kind'] === 'property') {\n (el as unknown as Record<string, unknown>)[key] = value;\n return;\n }\n\n if (typeof value === 'boolean') {\n if (value) el.setAttribute(key, '');\n else el.removeAttribute(key);\n return;\n }\n\n if (Array.isArray(value) || (typeof value === 'object' && value !== null)) {\n (el as unknown as Record<string, unknown>)[key] = value;\n return;\n }\n\n if (schema && isComplexSchema(schema)) {\n (el as unknown as Record<string, unknown>)[key] = value;\n return;\n }\n\n el.setAttribute(key, String(value));\n}\n\nfunction isComplexSchema(schema: PropSchema): boolean {\n const t = schema.type;\n if (Array.isArray(t)) return t.some((x) => x === 'object' || x === 'array');\n return t === 'object' || t === 'array';\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type SpecChild = ComponentSpec | string;
|
|
2
|
+
export interface ComponentSpec {
|
|
3
|
+
component: string;
|
|
4
|
+
props?: Record<string, unknown>;
|
|
5
|
+
children?: SpecChild[];
|
|
6
|
+
slots?: Record<string, SpecChild[]>;
|
|
7
|
+
events?: Record<string, EventBinding>;
|
|
8
|
+
}
|
|
9
|
+
export type EventBinding = string | {
|
|
10
|
+
handler: string;
|
|
11
|
+
stopPropagation?: boolean;
|
|
12
|
+
preventDefault?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export interface EmittedEvent {
|
|
15
|
+
component: string;
|
|
16
|
+
path: string;
|
|
17
|
+
event: string;
|
|
18
|
+
handler: string;
|
|
19
|
+
detail: unknown;
|
|
20
|
+
nativeEvent: Event;
|
|
21
|
+
}
|
|
22
|
+
export interface CatalogSchema {
|
|
23
|
+
$id?: string;
|
|
24
|
+
$defs?: {
|
|
25
|
+
components?: Record<string, CatalogComponentDef>;
|
|
26
|
+
};
|
|
27
|
+
'x-a2ui'?: {
|
|
28
|
+
catalogId?: string;
|
|
29
|
+
library?: string;
|
|
30
|
+
libraryVersion?: string;
|
|
31
|
+
tagPrefix?: string;
|
|
32
|
+
framework?: string;
|
|
33
|
+
};
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface CatalogComponentDef {
|
|
37
|
+
title?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
'x-category'?: string;
|
|
40
|
+
'x-slot-descriptions'?: Record<string, string>;
|
|
41
|
+
'x-events'?: Record<string, {
|
|
42
|
+
detail?: unknown;
|
|
43
|
+
}>;
|
|
44
|
+
properties?: {
|
|
45
|
+
component?: {
|
|
46
|
+
const?: string;
|
|
47
|
+
};
|
|
48
|
+
props?: {
|
|
49
|
+
properties?: Record<string, PropSchema>;
|
|
50
|
+
};
|
|
51
|
+
children?: unknown;
|
|
52
|
+
slots?: {
|
|
53
|
+
properties?: Record<string, unknown>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface PropSchema {
|
|
58
|
+
type?: string | string[];
|
|
59
|
+
enum?: string[];
|
|
60
|
+
const?: unknown;
|
|
61
|
+
default?: unknown;
|
|
62
|
+
description?: string;
|
|
63
|
+
items?: PropSchema;
|
|
64
|
+
properties?: Record<string, PropSchema>;
|
|
65
|
+
required?: string[];
|
|
66
|
+
additionalProperties?: boolean;
|
|
67
|
+
oneOf?: PropSchema[];
|
|
68
|
+
'x-tsType'?: string;
|
|
69
|
+
'x-kind'?: 'attribute' | 'property';
|
|
70
|
+
}
|
|
71
|
+
export interface RegisteredCatalog {
|
|
72
|
+
id: string;
|
|
73
|
+
schema: CatalogSchema;
|
|
74
|
+
components: Map<string, CatalogComponentDef>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../a2ui/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,GACN;IACE,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEN,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,KAAK,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QACN,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;KAClD,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC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O,CAAC;IAC/B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../a2ui/types.ts"],"names":[],"mappings":"","sourcesContent":["export type SpecChild = ComponentSpec | string;\n\nexport interface ComponentSpec {\n component: string;\n props?: Record<string, unknown>;\n children?: SpecChild[];\n slots?: Record<string, SpecChild[]>;\n events?: Record<string, EventBinding>;\n}\n\nexport type EventBinding =\n | string\n | {\n handler: string;\n stopPropagation?: boolean;\n preventDefault?: boolean;\n };\n\nexport interface EmittedEvent {\n component: string;\n path: string;\n event: string;\n handler: string;\n detail: unknown;\n nativeEvent: Event;\n}\n\nexport interface CatalogSchema {\n $id?: string;\n $defs?: {\n components?: Record<string, CatalogComponentDef>;\n };\n 'x-a2ui'?: {\n catalogId?: string;\n library?: string;\n libraryVersion?: string;\n tagPrefix?: string;\n framework?: string;\n };\n [key: string]: unknown;\n}\n\nexport interface CatalogComponentDef {\n title?: string;\n description?: string;\n 'x-category'?: string;\n 'x-slot-descriptions'?: Record<string, string>;\n 'x-events'?: Record<string, { detail?: unknown }>;\n properties?: {\n component?: { const?: string };\n props?: {\n properties?: Record<string, PropSchema>;\n };\n children?: unknown;\n slots?: {\n properties?: Record<string, unknown>;\n };\n };\n}\n\nexport interface PropSchema {\n type?: string | string[];\n enum?: string[];\n const?: unknown;\n default?: unknown;\n description?: string;\n items?: PropSchema;\n properties?: Record<string, PropSchema>;\n required?: string[];\n additionalProperties?: boolean;\n oneOf?: PropSchema[];\n 'x-tsType'?: string;\n 'x-kind'?: 'attribute' | 'property';\n}\n\nexport interface RegisteredCatalog {\n id: string;\n schema: CatalogSchema;\n components: Map<string, CatalogComponentDef>;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TemplateResult } from 'lit';
|
|
2
2
|
import { Cre8Element } from '../cre8-element';
|
|
3
3
|
/**
|
|
4
|
+
*
|
|
4
5
|
*
|
|
5
6
|
* <svg> is a web component, which can be used with any frontend framework and use any svg.
|
|
6
7
|
* It takes raw svgs as props and renders them.
|
|
@@ -25,7 +26,7 @@ import { Cre8Element } from '../cre8-element';
|
|
|
25
26
|
* If you need to install a newer version than what's included, please see
|
|
26
27
|
* the [installation instructions for svgs](https:/git.express-scripts.com/ExpressScripts/svgs#installation).
|
|
27
28
|
* - Import the component (this is the icon container): `import '@cre8_dev/svgs';`
|
|
28
|
-
* - Import an svg as a string: `import svgInfo from '@tmorrow/cre8-wc/icons/Info.svg';`
|
|
29
|
+
* - Import an svg as a string: `import svgInfo from '@tmorrow/cre8-wc/icons/Info.svg?raw';`
|
|
29
30
|
*
|
|
30
31
|
* Your import paths may be different depending on your project's build configuration.
|
|
31
32
|
* Please see [Importing Icons](https:/static-dev.esi-memberweb-dev.aws.evernorthcloud.com/svgs/?path=/story/icon-sets-importing-@tmorrow/cre8-wc/icons--page)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/icon/icon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,cAAc,EAAG,MAAM,KAAK,CAAC;AAyD5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/icon/icon.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,cAAc,EAAG,MAAM,KAAK,CAAC;AAyD5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,qBAAa,QAAS,SAAQ,WAAW;IACrC,MAAM,CAAC,MAAM,4BAAY;IAEzB;;;;OAIG;IAEH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IAEH,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IAEH,OAAO,CAAC,EAAE,MAAM,CAAc;IAE9B;;;;OAIG;IAEH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,WAAW;IAaX,MAAM;CA0FT;AAOD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,WAAW,EAAE,QAAQ,CAAC;KACzB;IACD,UAAU,MAAM;QACZ,aAAa,CAAC,EAAE,MAAM,CAAC;KAC1B;CACJ;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -10,63 +10,64 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
10
10
|
import { html, } from 'lit';
|
|
11
11
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
12
12
|
import { property } from 'lit/decorators.js';
|
|
13
|
-
import svgAdd from '@tmorrow/cre8-wc/icons/Add.svg';
|
|
14
|
-
import svgArrowLeft from '@tmorrow/cre8-wc/icons/Arrow_-_Left.svg';
|
|
15
|
-
import svgChat from '@tmorrow/cre8-wc/icons/Chat_Default.svg';
|
|
16
|
-
import svgCalendar from '@tmorrow/cre8-wc/icons/Calendar.svg';
|
|
17
|
-
import svgCaretDown from '@tmorrow/cre8-wc/icons/Caret_Down_Filled.svg';
|
|
18
|
-
import svgCheckCircle from '@tmorrow/cre8-wc/icons/Check_Filled.svg';
|
|
19
|
-
import svgCheck from '@tmorrow/cre8-wc/icons/Check.svg';
|
|
20
|
-
import svgClose from '@tmorrow/cre8-wc/icons/Close.svg';
|
|
21
|
-
import svgDownload from '@tmorrow/cre8-wc/icons/Download.svg';
|
|
22
|
-
import svgEdit from '@tmorrow/cre8-wc/icons/Edit.svg';
|
|
23
|
-
import svgEllipsis from '@tmorrow/cre8-wc/icons/Ellipsis_Filled.svg';
|
|
24
|
-
import svgMessageFilled from '@tmorrow/cre8-wc/icons/Message_Unread_Filled.svg';
|
|
25
|
-
import svgMessage from '@tmorrow/cre8-wc/icons/Message_Unread.svg';
|
|
26
|
-
import svgError from '@tmorrow/cre8-wc/icons/Error.svg';
|
|
27
|
-
import svgExternal from '@tmorrow/cre8-wc/icons/External_Link.svg';
|
|
28
|
-
import svgMedication from '@tmorrow/cre8-wc/icons/Medication.svg';
|
|
29
|
-
import svgGlobe from '@tmorrow/cre8-wc/icons/Globe.svg';
|
|
30
|
-
import svgHelp from '@tmorrow/cre8-wc/icons/Help.svg';
|
|
31
|
-
import svgInfoFilled from '@tmorrow/cre8-wc/icons/Info.svg';
|
|
32
|
-
import svgCaretUp from '@tmorrow/cre8-wc/icons/Caret_Up.svg';
|
|
33
|
-
import svgLightbulb from '@tmorrow/cre8-wc/icons/Lightbulb.svg';
|
|
34
|
-
import svgLocation from '@tmorrow/cre8-wc/icons/Location.svg';
|
|
35
|
-
import svgMenu from '@tmorrow/cre8-wc/icons/Menu.svg';
|
|
36
|
-
import svgMinus from '@tmorrow/cre8-wc/icons/Minus.svg';
|
|
37
|
-
import svgAccountFilled from '@tmorrow/cre8-wc/icons/Account_Filled.svg';
|
|
38
|
-
import svgNotification from '@tmorrow/cre8-wc/icons/Notification.svg';
|
|
39
|
-
import svgRefill from '@tmorrow/cre8-wc/icons/Refill.svg';
|
|
40
|
-
import svgAccount from '@tmorrow/cre8-wc/icons/Account.svg';
|
|
41
|
-
import svgPlayFilled from '@tmorrow/cre8-wc/icons/Play_Arrow.svg';
|
|
42
|
-
import svgPlayCircle from '@tmorrow/cre8-wc/icons/Play_Circle.svg';
|
|
43
|
-
import svgSpinner from '@tmorrow/cre8-wc/icons/Spinner_75.svg';
|
|
44
|
-
import svgUndo from '@tmorrow/cre8-wc/icons/Undo.svg';
|
|
45
|
-
import svgSearch from '@tmorrow/cre8-wc/icons/Search.svg';
|
|
46
|
-
import svgCart from '@tmorrow/cre8-wc/icons/Cart.svg';
|
|
47
|
-
import svgRectangle from '@tmorrow/cre8-wc/icons/Rectangle.svg';
|
|
48
|
-
import svgVaccine from '@tmorrow/cre8-wc/icons/Vaccinations.svg';
|
|
49
|
-
import svgWarningFilled from '@tmorrow/cre8-wc/icons/Warning.svg';
|
|
50
|
-
import svgCaretDoubleRight from '@tmorrow/cre8-wc/icons/Caret_Double_Right.svg';
|
|
51
|
-
import svgErrorAlt from '@tmorrow/cre8-wc/icons/error-alt.svg';
|
|
52
|
-
import svgEsi from '@tmorrow/cre8-wc/icons/express-scripts.svg';
|
|
53
|
-
import svgInsta from '@tmorrow/cre8-wc/icons/instagram.svg';
|
|
54
|
-
import svgLinkedin from '@tmorrow/cre8-wc/icons/linkedin.svg';
|
|
55
|
-
import svgOpen from '@tmorrow/cre8-wc/icons/open.svg';
|
|
56
|
-
import svgPause from '@tmorrow/cre8-wc/icons/pause.svg';
|
|
57
|
-
import svgPersonBubble from '@tmorrow/cre8-wc/icons/person-bubble.svg';
|
|
58
|
-
import svgPinterest from '@tmorrow/cre8-wc/icons/pinterest.svg';
|
|
59
|
-
import svgRss from '@tmorrow/cre8-wc/icons/rss-feed.svg';
|
|
60
|
-
import svgRx from '@tmorrow/cre8-wc/icons/rx.svg';
|
|
61
|
-
import svgSwap from '@tmorrow/cre8-wc/icons/swap.svg';
|
|
62
|
-
import svgThumbsUp from '@tmorrow/cre8-wc/icons/thumb-up.svg';
|
|
63
|
-
import svgTrendFlat from '@tmorrow/cre8-wc/icons/trending-flat.svg';
|
|
64
|
-
import svgTrendUp from '@tmorrow/cre8-wc/icons/trending-up.svg';
|
|
65
|
-
import svgTwitter from '@tmorrow/cre8-wc/icons/twitter.svg';
|
|
13
|
+
import svgAdd from '@tmorrow/cre8-wc/icons/Add.svg?raw';
|
|
14
|
+
import svgArrowLeft from '@tmorrow/cre8-wc/icons/Arrow_-_Left.svg?raw';
|
|
15
|
+
import svgChat from '@tmorrow/cre8-wc/icons/Chat_Default.svg?raw';
|
|
16
|
+
import svgCalendar from '@tmorrow/cre8-wc/icons/Calendar.svg?raw';
|
|
17
|
+
import svgCaretDown from '@tmorrow/cre8-wc/icons/Caret_Down_Filled.svg?raw';
|
|
18
|
+
import svgCheckCircle from '@tmorrow/cre8-wc/icons/Check_Filled.svg?raw';
|
|
19
|
+
import svgCheck from '@tmorrow/cre8-wc/icons/Check.svg?raw';
|
|
20
|
+
import svgClose from '@tmorrow/cre8-wc/icons/Close.svg?raw';
|
|
21
|
+
import svgDownload from '@tmorrow/cre8-wc/icons/Download.svg?raw';
|
|
22
|
+
import svgEdit from '@tmorrow/cre8-wc/icons/Edit.svg?raw';
|
|
23
|
+
import svgEllipsis from '@tmorrow/cre8-wc/icons/Ellipsis_Filled.svg?raw';
|
|
24
|
+
import svgMessageFilled from '@tmorrow/cre8-wc/icons/Message_Unread_Filled.svg?raw';
|
|
25
|
+
import svgMessage from '@tmorrow/cre8-wc/icons/Message_Unread.svg?raw';
|
|
26
|
+
import svgError from '@tmorrow/cre8-wc/icons/Error.svg?raw';
|
|
27
|
+
import svgExternal from '@tmorrow/cre8-wc/icons/External_Link.svg?raw';
|
|
28
|
+
import svgMedication from '@tmorrow/cre8-wc/icons/Medication.svg?raw';
|
|
29
|
+
import svgGlobe from '@tmorrow/cre8-wc/icons/Globe.svg?raw';
|
|
30
|
+
import svgHelp from '@tmorrow/cre8-wc/icons/Help.svg?raw';
|
|
31
|
+
import svgInfoFilled from '@tmorrow/cre8-wc/icons/Info.svg?raw';
|
|
32
|
+
import svgCaretUp from '@tmorrow/cre8-wc/icons/Caret_Up.svg?raw';
|
|
33
|
+
import svgLightbulb from '@tmorrow/cre8-wc/icons/Lightbulb.svg?raw';
|
|
34
|
+
import svgLocation from '@tmorrow/cre8-wc/icons/Location.svg?raw';
|
|
35
|
+
import svgMenu from '@tmorrow/cre8-wc/icons/Menu.svg?raw';
|
|
36
|
+
import svgMinus from '@tmorrow/cre8-wc/icons/Minus.svg?raw';
|
|
37
|
+
import svgAccountFilled from '@tmorrow/cre8-wc/icons/Account_Filled.svg?raw';
|
|
38
|
+
import svgNotification from '@tmorrow/cre8-wc/icons/Notification.svg?raw';
|
|
39
|
+
import svgRefill from '@tmorrow/cre8-wc/icons/Refill.svg?raw';
|
|
40
|
+
import svgAccount from '@tmorrow/cre8-wc/icons/Account.svg?raw';
|
|
41
|
+
import svgPlayFilled from '@tmorrow/cre8-wc/icons/Play_Arrow.svg?raw';
|
|
42
|
+
import svgPlayCircle from '@tmorrow/cre8-wc/icons/Play_Circle.svg?raw';
|
|
43
|
+
import svgSpinner from '@tmorrow/cre8-wc/icons/Spinner_75.svg?raw';
|
|
44
|
+
import svgUndo from '@tmorrow/cre8-wc/icons/Undo.svg?raw';
|
|
45
|
+
import svgSearch from '@tmorrow/cre8-wc/icons/Search.svg?raw';
|
|
46
|
+
import svgCart from '@tmorrow/cre8-wc/icons/Cart.svg?raw';
|
|
47
|
+
import svgRectangle from '@tmorrow/cre8-wc/icons/Rectangle.svg?raw';
|
|
48
|
+
import svgVaccine from '@tmorrow/cre8-wc/icons/Vaccinations.svg?raw';
|
|
49
|
+
import svgWarningFilled from '@tmorrow/cre8-wc/icons/Warning.svg?raw';
|
|
50
|
+
import svgCaretDoubleRight from '@tmorrow/cre8-wc/icons/Caret_Double_Right.svg?raw';
|
|
51
|
+
import svgErrorAlt from '@tmorrow/cre8-wc/icons/error-alt.svg?raw';
|
|
52
|
+
import svgEsi from '@tmorrow/cre8-wc/icons/express-scripts.svg?raw';
|
|
53
|
+
import svgInsta from '@tmorrow/cre8-wc/icons/instagram.svg?raw';
|
|
54
|
+
import svgLinkedin from '@tmorrow/cre8-wc/icons/linkedin.svg?raw';
|
|
55
|
+
import svgOpen from '@tmorrow/cre8-wc/icons/open.svg?raw';
|
|
56
|
+
import svgPause from '@tmorrow/cre8-wc/icons/pause.svg?raw';
|
|
57
|
+
import svgPersonBubble from '@tmorrow/cre8-wc/icons/person-bubble.svg?raw';
|
|
58
|
+
import svgPinterest from '@tmorrow/cre8-wc/icons/pinterest.svg?raw';
|
|
59
|
+
import svgRss from '@tmorrow/cre8-wc/icons/rss-feed.svg?raw';
|
|
60
|
+
import svgRx from '@tmorrow/cre8-wc/icons/rx.svg?raw';
|
|
61
|
+
import svgSwap from '@tmorrow/cre8-wc/icons/swap.svg?raw';
|
|
62
|
+
import svgThumbsUp from '@tmorrow/cre8-wc/icons/thumb-up.svg?raw';
|
|
63
|
+
import svgTrendFlat from '@tmorrow/cre8-wc/icons/trending-flat.svg?raw';
|
|
64
|
+
import svgTrendUp from '@tmorrow/cre8-wc/icons/trending-up.svg?raw';
|
|
65
|
+
import svgTwitter from '@tmorrow/cre8-wc/icons/twitter.svg?raw';
|
|
66
66
|
import { Cre8Element } from '../cre8-element';
|
|
67
67
|
import styles from './icon.styles.js';
|
|
68
|
-
import iconSprite from '@tmorrow/cre8-wc/icons/cre8-icons.svg';
|
|
68
|
+
import iconSprite from '@tmorrow/cre8-wc/icons/cre8-icons.svg?raw';
|
|
69
69
|
/**
|
|
70
|
+
*
|
|
70
71
|
*
|
|
71
72
|
* <svg> is a web component, which can be used with any frontend framework and use any svg.
|
|
72
73
|
* It takes raw svgs as props and renders them.
|
|
@@ -91,7 +92,7 @@ import iconSprite from '@tmorrow/cre8-wc/icons/cre8-icons.svg';
|
|
|
91
92
|
* If you need to install a newer version than what's included, please see
|
|
92
93
|
* the [installation instructions for svgs](https:/git.express-scripts.com/ExpressScripts/svgs#installation).
|
|
93
94
|
* - Import the component (this is the icon container): `import '@cre8_dev/svgs';`
|
|
94
|
-
* - Import an svg as a string: `import svgInfo from '@tmorrow/cre8-wc/icons/Info.svg';`
|
|
95
|
+
* - Import an svg as a string: `import svgInfo from '@tmorrow/cre8-wc/icons/Info.svg?raw';`
|
|
95
96
|
*
|
|
96
97
|
* Your import paths may be different depending on your project's build configuration.
|
|
97
98
|
* Please see [Importing Icons](https:/static-dev.esi-memberweb-dev.aws.evernorthcloud.com/svgs/?path=/story/icon-sets-importing-@tmorrow/cre8-wc/icons--page)
|