@ethereal-nexus/core 0.1.2 → 0.1.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.
@@ -49,9 +49,9 @@ function parsePrimitives(schema) {
49
49
 
50
50
  // src/decorators/webcomponent/webcomponent.ts
51
51
  function webcomponent(schema, options) {
52
- const props = {
52
+ const props = schema ? {
53
53
  ...parsePrimitives(schema)
54
- };
54
+ } : void 0;
55
55
  return (component) => {
56
56
  const name = pascalToKebab(component.displayName);
57
57
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/decorators/index.ts","../../src/decorators/webcomponent/webcomponent.ts","../../src/utils/pascalToKebab.ts","../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from './webcomponent'","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
1
+ {"version":3,"sources":["../../src/decorators/index.ts","../../src/decorators/webcomponent/webcomponent.ts","../../src/utils/pascalToKebab.ts","../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from './webcomponent'","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
@@ -13,9 +13,9 @@ function parsePrimitives(schema) {
13
13
 
14
14
  // src/decorators/webcomponent/webcomponent.ts
15
15
  function webcomponent(schema, options) {
16
- const props = {
16
+ const props = schema ? {
17
17
  ...parsePrimitives(schema)
18
- };
18
+ } : void 0;
19
19
  return (component) => {
20
20
  const name = pascalToKebab(component.displayName);
21
21
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/decorators/webcomponent/webcomponent.ts","../../src/utils/pascalToKebab.ts","../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/decorators/webcomponent/webcomponent.ts","../../src/utils/pascalToKebab.ts","../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -49,9 +49,9 @@ function parsePrimitives(schema) {
49
49
 
50
50
  // src/decorators/webcomponent/webcomponent.ts
51
51
  function webcomponent(schema, options) {
52
- const props = {
52
+ const props = schema ? {
53
53
  ...parsePrimitives(schema)
54
- };
54
+ } : void 0;
55
55
  return (component) => {
56
56
  const name = pascalToKebab(component.displayName);
57
57
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/decorators/webcomponent/index.ts","../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from './webcomponent'","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
1
+ {"version":3,"sources":["../../../src/decorators/webcomponent/index.ts","../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from './webcomponent'","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
@@ -13,9 +13,9 @@ function parsePrimitives(schema) {
13
13
 
14
14
  // src/decorators/webcomponent/webcomponent.ts
15
15
  function webcomponent(schema, options) {
16
- const props = {
16
+ const props = schema ? {
17
17
  ...parsePrimitives(schema)
18
- };
18
+ } : void 0;
19
19
  return (component) => {
20
20
  const name = pascalToKebab(component.displayName);
21
21
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -7,6 +7,6 @@ import '../../types/webcomponent.mjs';
7
7
  import '../../schema/optional/optional.mjs';
8
8
 
9
9
  type BaseOptions = {};
10
- declare function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions): <P extends {} = {}>(component: React.ComponentType<P>) => void;
10
+ declare function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions): <P extends {} = {}>(component: React.ComponentType<P>) => void;
11
11
 
12
12
  export { webcomponent };
@@ -7,6 +7,6 @@ import '../../types/webcomponent.js';
7
7
  import '../../schema/optional/optional.js';
8
8
 
9
9
  type BaseOptions = {};
10
- declare function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions): <P extends {} = {}>(component: React.ComponentType<P>) => void;
10
+ declare function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions): <P extends {} = {}>(component: React.ComponentType<P>) => void;
11
11
 
12
12
  export { webcomponent };
@@ -47,9 +47,9 @@ function parsePrimitives(schema) {
47
47
 
48
48
  // src/decorators/webcomponent/webcomponent.ts
49
49
  function webcomponent(schema, options) {
50
- const props = {
50
+ const props = schema ? {
51
51
  ...parsePrimitives(schema)
52
- };
52
+ } : void 0;
53
53
  return (component) => {
54
54
  const name = pascalToKebab(component.displayName);
55
55
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
1
+ {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAA,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["r2wc"]}
@@ -13,9 +13,9 @@ function parsePrimitives(schema) {
13
13
 
14
14
  // src/decorators/webcomponent/webcomponent.ts
15
15
  function webcomponent(schema, options) {
16
- const props = {
16
+ const props = schema ? {
17
17
  ...parsePrimitives(schema)
18
- };
18
+ } : void 0;
19
19
  return (component) => {
20
20
  const name = pascalToKebab(component.displayName);
21
21
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/decorators/webcomponent/webcomponent.ts","../../../src/utils/pascalToKebab.ts","../../../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AACA,OAAO,UAAU;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACAO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AFIO,SAAS,aAAsC,QAA0B,SAAuB;AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/dist/index.js CHANGED
@@ -295,9 +295,9 @@ function parsePrimitives(schema) {
295
295
 
296
296
  // src/decorators/webcomponent/webcomponent.ts
297
297
  function webcomponent(schema, options) {
298
- const props = {
298
+ const props = schema ? {
299
299
  ...parsePrimitives(schema)
300
- };
300
+ } : void 0;
301
301
  return (component) => {
302
302
  const name = pascalToKebab(component.displayName);
303
303
  if (!window.customElements.get(name)) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/schema/dialog/dialog.ts","../src/schema/multifield/multifield.ts","../src/schema/text/text.ts","../src/schema/checkbox/checkbox.ts","../src/schema/pathbrowser/pathbrowser.ts","../src/schema/image/image.ts","../src/schema/select/select.ts","../src/schema/hidden/hidden.ts","../src/schema/optional/optional.ts","../src/schema/object/object.ts","../src/decorators/webcomponent/webcomponent.ts","../src/utils/pascalToKebab.ts","../src/functions/parse/parse.ts","../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from \"./schema/dialog\";\n\nexport * from \"./schema/multifield\";\nexport * from \"./schema/text\";\nexport * from \"./schema/checkbox\";\nexport * from \"./schema/pathbrowser\";\nexport * from \"./schema/image\";\nexport * from \"./schema/select\";\n\nexport * from \"./schema/hidden\";\nexport * from \"./schema/optional\";\nexport * from \"./schema/object\";\n\nexport * from \"./types\";\n\nexport * from \"./decorators\"\nexport * from \"./functions\"","import { BaseSchema, EntryMask } from '../../types';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface DialogSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'dialog';\n tabs: (tabs: Record<string, EntryMask<TEntries>>) => Omit<DialogSchema<TEntries>, 'tabs'>\n}\n\nexport function dialog<TEntries extends ObjectEntries>(entries: TEntries): DialogSchema<TEntries> {\n return {\n type: 'dialog',\n tabs(tabs) {\n return {\n ...this,\n tabs: undefined,\n _parse() {\n const usedEntries = new Set<keyof TEntries>();\n\n const tabsArray = Object.entries(tabs)\n .map(([tabKey, value]) => {\n\n const children = Object.entries(value).map(([key, value]) => {\n if(value === true) {\n if (usedEntries.has(key)) {\n throw new Error(`Entry \"${String(tabKey)}.${String(key)}\" is already used in another tab.`);\n }\n usedEntries.add(key);\n return {\n id: key,\n ...entries[key]._parse()\n }\n }\n })\n\n return {\n type: 'tab',\n label: tabKey,\n id: `tab_${tabKey.toLowerCase().replaceAll(' ', '')}`,\n children,\n }\n })\n\n return [{\n type: 'tabs',\n id: 'tabs',\n children: tabsArray\n }];\n }\n }\n },\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return Object.entries(entries)\n .reduce(\n (acc: Record<string, WebcomponentPropTypes>, [key, entry]) => {\n const type = entry._primitive();\n if(typeof type === 'string') {\n acc[key] = type;\n }\n return acc;\n }, {});\n }\n };\n}","import {\n BaseFieldInput,\n BaseSchema,\n InferOutput\n} from '../../types';\n\nexport interface MultifieldSchema<\n TChildren extends BaseSchema<unknown>,\n> extends BaseSchema<InferOutput<TChildren>[]> {\n readonly type: 'multifield';\n /**\n * The children item schema.\n */\n readonly children: TChildren;\n}\n\ninterface MultifieldInput<TChildren extends BaseSchema<unknown>> extends BaseFieldInput {\n children: TChildren\n}\n\nexport function multifield<const TChildren extends BaseSchema<unknown>>(input: MultifieldInput<TChildren>): MultifieldSchema<TChildren> {\n const {label, children} = input;\n const childrenParse = children._parse();\n\n return {\n type: 'multifield',\n _parse() {\n return {\n type: 'multifield',\n label,\n children: Array.isArray(childrenParse) ? childrenParse : [childrenParse]\n }\n },\n _primitive() {\n return 'json'\n },\n ...input\n };\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface TextSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'textfield';\n}\n\ninterface TextInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function text(input: TextInput): TextSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'textfield',\n _parse() {\n return {\n type: 'textfield',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface CheckBoxSchema<TOutput extends boolean = boolean> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'checkbox';\n}\n\ninterface CheckBoxInput extends BaseFieldInput {}\n\nexport function checkbox(input: CheckBoxInput): CheckBoxSchema {\n const {label} = input;\n\n return {\n type: 'checkbox',\n _parse() {\n return {\n type: 'checkbox',\n label,\n }\n },\n _primitive() {\n return 'boolean'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface PathBrowserSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'pathbrowser';\n}\n\ninterface PathBrowserInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function pathbrowser(input: PathBrowserInput): PathBrowserSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'pathbrowser',\n _parse() {\n return {\n type: 'pathbrowser',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface ImageSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'image';\n}\n\ninterface ImageInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function image(input: ImageInput): ImageSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'image',\n _parse() {\n return {\n type: 'image',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface SelectSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'select';\n}\n\ninterface SelectInput extends BaseFieldInput {\n values: {\n value: string,\n label: string,\n }[]\n}\n\nexport function select(input: SelectInput): SelectSchema {\n const {label, values} = input;\n\n return {\n type: 'select',\n _parse() {\n return {\n type: 'select',\n label,\n values,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}\n","import { type BaseSchema } from '../../types';\nimport { type WebcomponentPropTypes } from '../../types/webcomponent';\n\nexport interface HiddenSchema extends BaseSchema<string> {\n /**\n * The schema type.\n */\n type: 'hidden';\n}\n\ninterface HiddenInput {\n type: WebcomponentPropTypes\n}\n\n/**\n * Creates a hidden schema.\n *\n * @param input The type of input for the webcomponent binding.\n *\n * @returns A hidden schema.\n */\nexport function hidden(input: HiddenInput): HiddenSchema {\n const {type} = input;\n\n return {\n type: 'hidden',\n _parse() {\n //Explicitly hidding this input from the parse final result.\n return this;\n },\n _primitive() {\n return type\n },\n }\n}","import { BaseSchema, Output } from '../../types';\n\n/**\n * Optional schema type.\n */\nexport interface OptionalSchema<\n TWrapped extends BaseSchema,\n TOutput = Output<TWrapped> | undefined\n> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'optional';\n /**\n * The wrapped schema.\n */\n wrapped: TWrapped;\n}\n\n\n/**\n * Creates an optional schema.\n *\n * @param wrapped The wrapped schema.\n *\n * @returns A optional schema.\n */\nexport function optional<TWrapped extends BaseSchema>(\n wrapped: TWrapped\n): OptionalSchema<TWrapped> {\n return {\n type: 'optional',\n wrapped,\n _primitive() {\n return this.wrapped._primitive();\n },\n _parse() {\n return this.wrapped._parse();\n },\n };\n}","import type { BaseSchema } from '../../types';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface ObjectSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'object';\n}\n\nexport function object<TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries> {\n return {\n type: 'object',\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return 'json'\n }\n };\n}","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parse<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return {\n dialog: schema._parse()\n }\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,SAAS,OAAuC,SAA2C;AAChG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM;AACT,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AACP,gBAAM,cAAc,oBAAI,IAAoB;AAE5C,gBAAM,YAAY,OAAO,QAAQ,IAAI,EAClC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM;AAExB,kBAAM,WAAW,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAM;AAC3D,kBAAGA,WAAU,MAAM;AACjB,oBAAI,YAAY,IAAI,GAAG,GAAG;AACxB,wBAAM,IAAI,MAAM,UAAU,OAAO,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,mCAAmC;AAAA,gBAC5F;AACA,4BAAY,IAAI,GAAG;AACnB,uBAAO;AAAA,kBACL,IAAI;AAAA,kBACJ,GAAG,QAAQ,GAAG,EAAE,OAAO;AAAA,gBACzB;AAAA,cACF;AAAA,YACF,CAAC;AAED,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO;AAAA,cACP,IAAI,OAAO,OAAO,YAAY,EAAE,WAAW,KAAK,EAAE,CAAC;AAAA,cACnD;AAAA,YACF;AAAA,UACF,CAAC;AAEH,iBAAO,CAAC;AAAA,YACN,MAAM;AAAA,YACN,IAAI;AAAA,YACJ,UAAU;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AACP,aAAO,OAAO,QAAQ,OAAO,EAC1B,IAAI,CAAC,CAAC,KAAK,KAA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;ACjCO,SAAS,OAAuC,SAA2C;AAChG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AACP,aAAO,OAAO,QAAQ,OAAO,EAC1B,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO;AAAA,QACtB,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,GAAG,MAAM,OAAO;AAAA,MAClB,EAAE,EACD,OAAO,CAAC,UAAkB;AACzB,YAAG,UAAU,OAAM;AACjB,iBAAO,MAAM,SAAS;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACL;AAAA,IACA,aAAa;AACX,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;AC1BA,oCAAiB;;;ACDV,SAAS,cAAc,kBAA0B;AACtD,SAAO,iBACJ,QAAQ,mBAAmB,OAAO,EAClC,YAAY;AACjB;;;ACDO,SAAS,MAA+B,QAAyB;AACtE,SAAO;AAAA,IACL,QAAQ,OAAO,OAAO;AAAA,EACxB;AACF;;;ACHO,SAAS,gBAAyC,QAAyB;AAChF,SAAO,OAAO,WAAW;AAC3B;;;AHIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAC,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["value","r2wc"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/schema/dialog/dialog.ts","../src/schema/multifield/multifield.ts","../src/schema/text/text.ts","../src/schema/checkbox/checkbox.ts","../src/schema/pathbrowser/pathbrowser.ts","../src/schema/image/image.ts","../src/schema/select/select.ts","../src/schema/hidden/hidden.ts","../src/schema/optional/optional.ts","../src/schema/object/object.ts","../src/decorators/webcomponent/webcomponent.ts","../src/utils/pascalToKebab.ts","../src/functions/parse/parse.ts","../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["export * from \"./schema/dialog\";\n\nexport * from \"./schema/multifield\";\nexport * from \"./schema/text\";\nexport * from \"./schema/checkbox\";\nexport * from \"./schema/pathbrowser\";\nexport * from \"./schema/image\";\nexport * from \"./schema/select\";\n\nexport * from \"./schema/hidden\";\nexport * from \"./schema/optional\";\nexport * from \"./schema/object\";\n\nexport * from \"./types\";\n\nexport * from \"./decorators\"\nexport * from \"./functions\"","import { BaseSchema, EntryMask } from '../../types';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface DialogSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'dialog';\n tabs: (tabs: Record<string, EntryMask<TEntries>>) => Omit<DialogSchema<TEntries>, 'tabs'>\n}\n\nexport function dialog<TEntries extends ObjectEntries>(entries: TEntries): DialogSchema<TEntries> {\n return {\n type: 'dialog',\n tabs(tabs) {\n return {\n ...this,\n tabs: undefined,\n _parse() {\n const usedEntries = new Set<keyof TEntries>();\n\n const tabsArray = Object.entries(tabs)\n .map(([tabKey, value]) => {\n\n const children = Object.entries(value).map(([key, value]) => {\n if(value === true) {\n if (usedEntries.has(key)) {\n throw new Error(`Entry \"${String(tabKey)}.${String(key)}\" is already used in another tab.`);\n }\n usedEntries.add(key);\n return {\n id: key,\n ...entries[key]._parse()\n }\n }\n })\n\n return {\n type: 'tab',\n label: tabKey,\n id: `tab_${tabKey.toLowerCase().replaceAll(' ', '')}`,\n children,\n }\n })\n\n return [{\n type: 'tabs',\n id: 'tabs',\n children: tabsArray\n }];\n }\n }\n },\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return Object.entries(entries)\n .reduce(\n (acc: Record<string, WebcomponentPropTypes>, [key, entry]) => {\n const type = entry._primitive();\n if(typeof type === 'string') {\n acc[key] = type;\n }\n return acc;\n }, {});\n }\n };\n}","import {\n BaseFieldInput,\n BaseSchema,\n InferOutput\n} from '../../types';\n\nexport interface MultifieldSchema<\n TChildren extends BaseSchema<unknown>,\n> extends BaseSchema<InferOutput<TChildren>[]> {\n readonly type: 'multifield';\n /**\n * The children item schema.\n */\n readonly children: TChildren;\n}\n\ninterface MultifieldInput<TChildren extends BaseSchema<unknown>> extends BaseFieldInput {\n children: TChildren\n}\n\nexport function multifield<const TChildren extends BaseSchema<unknown>>(input: MultifieldInput<TChildren>): MultifieldSchema<TChildren> {\n const {label, children} = input;\n const childrenParse = children._parse();\n\n return {\n type: 'multifield',\n _parse() {\n return {\n type: 'multifield',\n label,\n children: Array.isArray(childrenParse) ? childrenParse : [childrenParse]\n }\n },\n _primitive() {\n return 'json'\n },\n ...input\n };\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface TextSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'textfield';\n}\n\ninterface TextInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function text(input: TextInput): TextSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'textfield',\n _parse() {\n return {\n type: 'textfield',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface CheckBoxSchema<TOutput extends boolean = boolean> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'checkbox';\n}\n\ninterface CheckBoxInput extends BaseFieldInput {}\n\nexport function checkbox(input: CheckBoxInput): CheckBoxSchema {\n const {label} = input;\n\n return {\n type: 'checkbox',\n _parse() {\n return {\n type: 'checkbox',\n label,\n }\n },\n _primitive() {\n return 'boolean'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface PathBrowserSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'pathbrowser';\n}\n\ninterface PathBrowserInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function pathbrowser(input: PathBrowserInput): PathBrowserSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'pathbrowser',\n _parse() {\n return {\n type: 'pathbrowser',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface ImageSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'image';\n}\n\ninterface ImageInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function image(input: ImageInput): ImageSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'image',\n _parse() {\n return {\n type: 'image',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface SelectSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'select';\n}\n\ninterface SelectInput extends BaseFieldInput {\n values: {\n value: string,\n label: string,\n }[]\n}\n\nexport function select(input: SelectInput): SelectSchema {\n const {label, values} = input;\n\n return {\n type: 'select',\n _parse() {\n return {\n type: 'select',\n label,\n values,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}\n","import { type BaseSchema } from '../../types';\nimport { type WebcomponentPropTypes } from '../../types/webcomponent';\n\nexport interface HiddenSchema extends BaseSchema<string> {\n /**\n * The schema type.\n */\n type: 'hidden';\n}\n\ninterface HiddenInput {\n type: WebcomponentPropTypes\n}\n\n/**\n * Creates a hidden schema.\n *\n * @param input The type of input for the webcomponent binding.\n *\n * @returns A hidden schema.\n */\nexport function hidden(input: HiddenInput): HiddenSchema {\n const {type} = input;\n\n return {\n type: 'hidden',\n _parse() {\n //Explicitly hidding this input from the parse final result.\n return this;\n },\n _primitive() {\n return type\n },\n }\n}","import { BaseSchema, Output } from '../../types';\n\n/**\n * Optional schema type.\n */\nexport interface OptionalSchema<\n TWrapped extends BaseSchema,\n TOutput = Output<TWrapped> | undefined\n> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'optional';\n /**\n * The wrapped schema.\n */\n wrapped: TWrapped;\n}\n\n\n/**\n * Creates an optional schema.\n *\n * @param wrapped The wrapped schema.\n *\n * @returns A optional schema.\n */\nexport function optional<TWrapped extends BaseSchema>(\n wrapped: TWrapped\n): OptionalSchema<TWrapped> {\n return {\n type: 'optional',\n wrapped,\n _primitive() {\n return this.wrapped._primitive();\n },\n _parse() {\n return this.wrapped._parse();\n },\n };\n}","import type { BaseSchema } from '../../types';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface ObjectSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'object';\n}\n\nexport function object<TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries> {\n return {\n type: 'object',\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return 'json'\n }\n };\n}","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parse<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return {\n dialog: schema._parse()\n }\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,SAAS,OAAuC,SAA2C;AAChG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM;AACT,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AACP,gBAAM,cAAc,oBAAI,IAAoB;AAE5C,gBAAM,YAAY,OAAO,QAAQ,IAAI,EAClC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM;AAExB,kBAAM,WAAW,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAM;AAC3D,kBAAGA,WAAU,MAAM;AACjB,oBAAI,YAAY,IAAI,GAAG,GAAG;AACxB,wBAAM,IAAI,MAAM,UAAU,OAAO,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,mCAAmC;AAAA,gBAC5F;AACA,4BAAY,IAAI,GAAG;AACnB,uBAAO;AAAA,kBACL,IAAI;AAAA,kBACJ,GAAG,QAAQ,GAAG,EAAE,OAAO;AAAA,gBACzB;AAAA,cACF;AAAA,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,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,YACA,8BAAAC,SAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["value","r2wc"]}
package/dist/index.mjs CHANGED
@@ -247,9 +247,9 @@ function parsePrimitives(schema) {
247
247
 
248
248
  // src/decorators/webcomponent/webcomponent.ts
249
249
  function webcomponent(schema, options) {
250
- const props = {
250
+ const props = schema ? {
251
251
  ...parsePrimitives(schema)
252
- };
252
+ } : void 0;
253
253
  return (component) => {
254
254
  const name = pascalToKebab(component.displayName);
255
255
  if (!window.customElements.get(name)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema/dialog/dialog.ts","../src/schema/multifield/multifield.ts","../src/schema/text/text.ts","../src/schema/checkbox/checkbox.ts","../src/schema/pathbrowser/pathbrowser.ts","../src/schema/image/image.ts","../src/schema/select/select.ts","../src/schema/hidden/hidden.ts","../src/schema/optional/optional.ts","../src/schema/object/object.ts","../src/decorators/webcomponent/webcomponent.ts","../src/utils/pascalToKebab.ts","../src/functions/parse/parse.ts","../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import { BaseSchema, EntryMask } from '../../types';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface DialogSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'dialog';\n tabs: (tabs: Record<string, EntryMask<TEntries>>) => Omit<DialogSchema<TEntries>, 'tabs'>\n}\n\nexport function dialog<TEntries extends ObjectEntries>(entries: TEntries): DialogSchema<TEntries> {\n return {\n type: 'dialog',\n tabs(tabs) {\n return {\n ...this,\n tabs: undefined,\n _parse() {\n const usedEntries = new Set<keyof TEntries>();\n\n const tabsArray = Object.entries(tabs)\n .map(([tabKey, value]) => {\n\n const children = Object.entries(value).map(([key, value]) => {\n if(value === true) {\n if (usedEntries.has(key)) {\n throw new Error(`Entry \"${String(tabKey)}.${String(key)}\" is already used in another tab.`);\n }\n usedEntries.add(key);\n return {\n id: key,\n ...entries[key]._parse()\n }\n }\n })\n\n return {\n type: 'tab',\n label: tabKey,\n id: `tab_${tabKey.toLowerCase().replaceAll(' ', '')}`,\n children,\n }\n })\n\n return [{\n type: 'tabs',\n id: 'tabs',\n children: tabsArray\n }];\n }\n }\n },\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return Object.entries(entries)\n .reduce(\n (acc: Record<string, WebcomponentPropTypes>, [key, entry]) => {\n const type = entry._primitive();\n if(typeof type === 'string') {\n acc[key] = type;\n }\n return acc;\n }, {});\n }\n };\n}","import {\n BaseFieldInput,\n BaseSchema,\n InferOutput\n} from '../../types';\n\nexport interface MultifieldSchema<\n TChildren extends BaseSchema<unknown>,\n> extends BaseSchema<InferOutput<TChildren>[]> {\n readonly type: 'multifield';\n /**\n * The children item schema.\n */\n readonly children: TChildren;\n}\n\ninterface MultifieldInput<TChildren extends BaseSchema<unknown>> extends BaseFieldInput {\n children: TChildren\n}\n\nexport function multifield<const TChildren extends BaseSchema<unknown>>(input: MultifieldInput<TChildren>): MultifieldSchema<TChildren> {\n const {label, children} = input;\n const childrenParse = children._parse();\n\n return {\n type: 'multifield',\n _parse() {\n return {\n type: 'multifield',\n label,\n children: Array.isArray(childrenParse) ? childrenParse : [childrenParse]\n }\n },\n _primitive() {\n return 'json'\n },\n ...input\n };\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface TextSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'textfield';\n}\n\ninterface TextInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function text(input: TextInput): TextSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'textfield',\n _parse() {\n return {\n type: 'textfield',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface CheckBoxSchema<TOutput extends boolean = boolean> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'checkbox';\n}\n\ninterface CheckBoxInput extends BaseFieldInput {}\n\nexport function checkbox(input: CheckBoxInput): CheckBoxSchema {\n const {label} = input;\n\n return {\n type: 'checkbox',\n _parse() {\n return {\n type: 'checkbox',\n label,\n }\n },\n _primitive() {\n return 'boolean'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface PathBrowserSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'pathbrowser';\n}\n\ninterface PathBrowserInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function pathbrowser(input: PathBrowserInput): PathBrowserSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'pathbrowser',\n _parse() {\n return {\n type: 'pathbrowser',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface ImageSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'image';\n}\n\ninterface ImageInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function image(input: ImageInput): ImageSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'image',\n _parse() {\n return {\n type: 'image',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface SelectSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'select';\n}\n\ninterface SelectInput extends BaseFieldInput {\n values: {\n value: string,\n label: string,\n }[]\n}\n\nexport function select(input: SelectInput): SelectSchema {\n const {label, values} = input;\n\n return {\n type: 'select',\n _parse() {\n return {\n type: 'select',\n label,\n values,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}\n","import { type BaseSchema } from '../../types';\nimport { type WebcomponentPropTypes } from '../../types/webcomponent';\n\nexport interface HiddenSchema extends BaseSchema<string> {\n /**\n * The schema type.\n */\n type: 'hidden';\n}\n\ninterface HiddenInput {\n type: WebcomponentPropTypes\n}\n\n/**\n * Creates a hidden schema.\n *\n * @param input The type of input for the webcomponent binding.\n *\n * @returns A hidden schema.\n */\nexport function hidden(input: HiddenInput): HiddenSchema {\n const {type} = input;\n\n return {\n type: 'hidden',\n _parse() {\n //Explicitly hidding this input from the parse final result.\n return this;\n },\n _primitive() {\n return type\n },\n }\n}","import { BaseSchema, Output } from '../../types';\n\n/**\n * Optional schema type.\n */\nexport interface OptionalSchema<\n TWrapped extends BaseSchema,\n TOutput = Output<TWrapped> | undefined\n> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'optional';\n /**\n * The wrapped schema.\n */\n wrapped: TWrapped;\n}\n\n\n/**\n * Creates an optional schema.\n *\n * @param wrapped The wrapped schema.\n *\n * @returns A optional schema.\n */\nexport function optional<TWrapped extends BaseSchema>(\n wrapped: TWrapped\n): OptionalSchema<TWrapped> {\n return {\n type: 'optional',\n wrapped,\n _primitive() {\n return this.wrapped._primitive();\n },\n _parse() {\n return this.wrapped._parse();\n },\n };\n}","import type { BaseSchema } from '../../types';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface ObjectSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'object';\n}\n\nexport function object<TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries> {\n return {\n type: 'object',\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return 'json'\n }\n };\n}","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> = {\n ...parsePrimitives(schema),\n };\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parse<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return {\n dialog: schema._parse()\n }\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AASO,SAAS,OAAuC,SAA2C;AAChG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM;AACT,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AACP,gBAAM,cAAc,oBAAI,IAAoB;AAE5C,gBAAM,YAAY,OAAO,QAAQ,IAAI,EAClC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM;AAExB,kBAAM,WAAW,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAM;AAC3D,kBAAGA,WAAU,MAAM;AACjB,oBAAI,YAAY,IAAI,GAAG,GAAG;AAC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WAAW;AAC3B;;;AHIO,SAAS,aAAsC,QAAyB,SAAuB;AACpG,QAAM,QAA+C;AAAA,IACnD,GAAG,gBAAgB,MAAM;AAAA,EAC3B;AAEA,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["value"]}
1
+ {"version":3,"sources":["../src/schema/dialog/dialog.ts","../src/schema/multifield/multifield.ts","../src/schema/text/text.ts","../src/schema/checkbox/checkbox.ts","../src/schema/pathbrowser/pathbrowser.ts","../src/schema/image/image.ts","../src/schema/select/select.ts","../src/schema/hidden/hidden.ts","../src/schema/optional/optional.ts","../src/schema/object/object.ts","../src/decorators/webcomponent/webcomponent.ts","../src/utils/pascalToKebab.ts","../src/functions/parse/parse.ts","../src/functions/parse/parsePrimitives.ts"],"sourcesContent":["import { BaseSchema, EntryMask } from '../../types';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface DialogSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'dialog';\n tabs: (tabs: Record<string, EntryMask<TEntries>>) => Omit<DialogSchema<TEntries>, 'tabs'>\n}\n\nexport function dialog<TEntries extends ObjectEntries>(entries: TEntries): DialogSchema<TEntries> {\n return {\n type: 'dialog',\n tabs(tabs) {\n return {\n ...this,\n tabs: undefined,\n _parse() {\n const usedEntries = new Set<keyof TEntries>();\n\n const tabsArray = Object.entries(tabs)\n .map(([tabKey, value]) => {\n\n const children = Object.entries(value).map(([key, value]) => {\n if(value === true) {\n if (usedEntries.has(key)) {\n throw new Error(`Entry \"${String(tabKey)}.${String(key)}\" is already used in another tab.`);\n }\n usedEntries.add(key);\n return {\n id: key,\n ...entries[key]._parse()\n }\n }\n })\n\n return {\n type: 'tab',\n label: tabKey,\n id: `tab_${tabKey.toLowerCase().replaceAll(' ', '')}`,\n children,\n }\n })\n\n return [{\n type: 'tabs',\n id: 'tabs',\n children: tabsArray\n }];\n }\n }\n },\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return Object.entries(entries)\n .reduce(\n (acc: Record<string, WebcomponentPropTypes>, [key, entry]) => {\n const type = entry._primitive();\n if(typeof type === 'string') {\n acc[key] = type;\n }\n return acc;\n }, {});\n }\n };\n}","import {\n BaseFieldInput,\n BaseSchema,\n InferOutput\n} from '../../types';\n\nexport interface MultifieldSchema<\n TChildren extends BaseSchema<unknown>,\n> extends BaseSchema<InferOutput<TChildren>[]> {\n readonly type: 'multifield';\n /**\n * The children item schema.\n */\n readonly children: TChildren;\n}\n\ninterface MultifieldInput<TChildren extends BaseSchema<unknown>> extends BaseFieldInput {\n children: TChildren\n}\n\nexport function multifield<const TChildren extends BaseSchema<unknown>>(input: MultifieldInput<TChildren>): MultifieldSchema<TChildren> {\n const {label, children} = input;\n const childrenParse = children._parse();\n\n return {\n type: 'multifield',\n _parse() {\n return {\n type: 'multifield',\n label,\n children: Array.isArray(childrenParse) ? childrenParse : [childrenParse]\n }\n },\n _primitive() {\n return 'json'\n },\n ...input\n };\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface TextSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'textfield';\n}\n\ninterface TextInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function text(input: TextInput): TextSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'textfield',\n _parse() {\n return {\n type: 'textfield',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface CheckBoxSchema<TOutput extends boolean = boolean> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'checkbox';\n}\n\ninterface CheckBoxInput extends BaseFieldInput {}\n\nexport function checkbox(input: CheckBoxInput): CheckBoxSchema {\n const {label} = input;\n\n return {\n type: 'checkbox',\n _parse() {\n return {\n type: 'checkbox',\n label,\n }\n },\n _primitive() {\n return 'boolean'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface PathBrowserSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'pathbrowser';\n}\n\ninterface PathBrowserInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function pathbrowser(input: PathBrowserInput): PathBrowserSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'pathbrowser',\n _parse() {\n return {\n type: 'pathbrowser',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface ImageSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'image';\n}\n\ninterface ImageInput extends BaseFieldInput {\n placeholder: string;\n}\n\nexport function image(input: ImageInput): ImageSchema {\n const {placeholder, label} = input;\n\n return {\n type: 'image',\n _parse() {\n return {\n type: 'image',\n label,\n placeholder,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}","import { BaseFieldInput, type BaseSchema } from '../../types';\n\nexport interface SelectSchema<TOutput extends string = string> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'select';\n}\n\ninterface SelectInput extends BaseFieldInput {\n values: {\n value: string,\n label: string,\n }[]\n}\n\nexport function select(input: SelectInput): SelectSchema {\n const {label, values} = input;\n\n return {\n type: 'select',\n _parse() {\n return {\n type: 'select',\n label,\n values,\n }\n },\n _primitive() {\n return 'string'\n },\n ...input,\n }\n}\n","import { type BaseSchema } from '../../types';\nimport { type WebcomponentPropTypes } from '../../types/webcomponent';\n\nexport interface HiddenSchema extends BaseSchema<string> {\n /**\n * The schema type.\n */\n type: 'hidden';\n}\n\ninterface HiddenInput {\n type: WebcomponentPropTypes\n}\n\n/**\n * Creates a hidden schema.\n *\n * @param input The type of input for the webcomponent binding.\n *\n * @returns A hidden schema.\n */\nexport function hidden(input: HiddenInput): HiddenSchema {\n const {type} = input;\n\n return {\n type: 'hidden',\n _parse() {\n //Explicitly hidding this input from the parse final result.\n return this;\n },\n _primitive() {\n return type\n },\n }\n}","import { BaseSchema, Output } from '../../types';\n\n/**\n * Optional schema type.\n */\nexport interface OptionalSchema<\n TWrapped extends BaseSchema,\n TOutput = Output<TWrapped> | undefined\n> extends BaseSchema<TOutput> {\n /**\n * The schema type.\n */\n type: 'optional';\n /**\n * The wrapped schema.\n */\n wrapped: TWrapped;\n}\n\n\n/**\n * Creates an optional schema.\n *\n * @param wrapped The wrapped schema.\n *\n * @returns A optional schema.\n */\nexport function optional<TWrapped extends BaseSchema>(\n wrapped: TWrapped\n): OptionalSchema<TWrapped> {\n return {\n type: 'optional',\n wrapped,\n _primitive() {\n return this.wrapped._primitive();\n },\n _parse() {\n return this.wrapped._parse();\n },\n };\n}","import type { BaseSchema } from '../../types';\nimport { ObjectEntries, ObjectOutput } from '../../types/object';\n\nexport interface ObjectSchema<TEntries extends ObjectEntries, TOutput = ObjectOutput<TEntries>> extends BaseSchema<TOutput> {\n type: 'object';\n}\n\nexport function object<TEntries extends ObjectEntries>(entries: TEntries): ObjectSchema<TEntries> {\n return {\n type: 'object',\n _parse() {\n return Object.entries(entries)\n .map(([key, entry]) => ({\n id: key,\n name: key,\n ...entry._parse()\n }))\n .filter((entry: object) => {\n if('type' in entry){\n return entry.type !== 'hidden'\n }\n })\n },\n _primitive() {\n return 'json'\n }\n };\n}","import type React from 'react';\nimport r2wc from '@r2wc/react-to-web-component';\nimport { DialogSchema } from '../../schema/dialog';\nimport { pascalToKebab } from '../../utils/pascalToKebab';\nimport { parsePrimitives } from '../../functions';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\ntype BaseOptions = {}\n\nexport function webcomponent<T extends ObjectEntries>(schema?: DialogSchema<T>, options?: BaseOptions) {\n const props: Record<string, WebcomponentPropTypes> | undefined = schema ? {\n ...parsePrimitives(schema),\n } : undefined;\n\n return <P extends {} = {}>(component: React.ComponentType<P>) => {\n const name = pascalToKebab(component.displayName!)\n\n if (!window.customElements.get(name)) {\n customElements.define(\n name,\n r2wc(component, {\n props,\n }),\n );\n }\n }\n}","export function pascalToKebab(pascalCaseString: string) {\n return pascalCaseString\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n}","import { DialogSchema } from '../../schema/dialog';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parse<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return {\n dialog: schema._parse()\n }\n}","import { DialogSchema } from '../../schema/dialog';\nimport { WebcomponentPropTypes } from '../../types/webcomponent';\nimport { ObjectEntries } from '../../types/object';\n\nexport function parsePrimitives<T extends ObjectEntries>(schema: DialogSchema<T>) {\n return schema._primitive() as Record<string, WebcomponentPropTypes>\n}"],"mappings":";AASO,SAAS,OAAuC,SAA2C;AAChG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK,MAAM;AACT,aAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM;AAAA,QACN,SAAS;AACP,gBAAM,cAAc,oBAAI,IAAoB;AAE5C,gBAAM,YAAY,OAAO,QAAQ,IAAI,EAClC,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM;AAExB,kBAAM,WAAW,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAKA,MAAK,MAAM;AAC3D,kBAAGA,WAAU,MAAM;AACjB,oBAAI,YAAY,IAAI,GAAG,GAAG;AACxB,wBAAM,IAAI,MAAM,UAAU,OAAO,MAAM,CAAC,IA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AACrG,QAAM,QAA2D,SAAS;AAAA,IACxE,GAAG,gBAAgB,MAAM;AAAA,EAC3B,IAAI;AAEJ,SAAO,CAAoB,cAAsC;AAC/D,UAAM,OAAO,cAAc,UAAU,WAAY;AAEjD,QAAI,CAAC,OAAO,eAAe,IAAI,IAAI,GAAG;AACpC,qBAAe;AAAA,QACb;AAAA,QACA,KAAK,WAAW;AAAA,UACd;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["value"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethereal-nexus/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",