@webflow/data-types
Advanced tools
+6
-0
| # @webflow/data-types | ||
| ## 0.0.5 | ||
| ### Patch Changes | ||
| - Minor fixes | ||
| ## 0.0.4 | ||
@@ -4,0 +10,0 @@ |
+1
-1
@@ -1,1 +0,1 @@ | ||
| 'use strict';var u=(t=>(t.FEDERATION="FEDERATION",t))(u||{}),l=(t=>(t.React="React",t))(l||{}),m=(n=>(n.Client="Client",n.Server="Server",n))(m||{}),s=(p=>(p.Id="Id",p.Text="Text",p.TextBlock="TextBlock",p.RichText="RichText",p.Link="Link",p.Image="Image",p.Visibility="Visibility",p.Slot="Slot",p))(s||{});var f={Text:e=>({type:"Text",defaultValue:e?.defaultValue,displayName:i(e)}),Id:e=>({type:"Id",displayName:i(e)}),Link:e=>({type:"Link",displayName:i(e)}),Image:e=>({type:"Image",displayName:i(e)}),Visibility:e=>({type:"Visibility",defaultValue:e?.defaultValue,displayName:i(e)}),Slot:e=>({type:"Slot",displayName:i(e)}),TextBlock:e=>({type:"TextBlock",displayName:i(e)}),RichText:e=>({type:"RichText",displayName:i(e)})},d=Object.values(s).reduce((e,t)=>({...e,[t]:f[t]}),{});function i(e){return [e.group,e.name.replaceAll("/","-")].filter(Boolean).join("/")}var o=class extends Error{constructor(t){super(`Invalid ComponentData: ${t}`),this.name="InvalidComponentDataError";}};function y(e){return typeof e=="string"&&Object.values(s).includes(e)}function a(e,t){if(typeof e!="string")throw new o(`prop "${t}" 'name' must be a string`);if(e==="")throw new o(`prop "${t}" 'name' cannot be empty`);return e}function c(e,t){if(e!=null){if(typeof e!="string")throw new o(`prop "${t}" defaultValue must be a string for Text type`);return e}}function T(e,t){if(e!=null){if(typeof e!="boolean")throw new o(`prop "${t}" defaultValue must be a boolean for Visibility type`);return e}}function w(e,t,n){if(e!==void 0)throw new o(`prop "${t}" defaultValue is not supported for ${n} type`)}function P(e,t){let n=e.type;switch(n){case "Text":return {type:"Text",displayName:a(e.displayName,t),defaultValue:c(e.defaultValue,t)};case "Visibility":return {type:"Visibility",displayName:a(e.displayName,t),defaultValue:T(e.defaultValue,t)};case "Id":case "Link":case "Image":case "Slot":case "TextBlock":case "RichText":return {type:n,displayName:a(e.displayName,t),defaultValue:w(e.defaultValue,t,n)};default:let r=n;throw new o(`prop "${t}" has invalid type: ${r}`)}}function g(e){if(!e||typeof e!="object")throw new o("props must be an object");let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!="object")throw new o(`prop "${n}" must be an object`);if(!("type"in r))throw new o(`prop "${n}" is missing required field: type`);if(!y(r.type))throw new o(`prop "${n}" has invalid type: ${String(r.type)}`);t[n]=P(r,n);}return t}function x(e){if(!e||typeof e!="object")throw new o("options must be an object");let t={};for(let[n,r]of Object.entries(e))if(n==="applyTagSelectors"){if(typeof r!="boolean")throw new o('option "applyTagSelectors" must be a boolean');t.applyTagSelectors=r;}return t}function C(e){if(!e||typeof e!="object")throw new o("input must be an object");if(!("name"in e))throw new o("missing required field: 'name'");if(typeof e.name!="string")throw new o("'name' must be a string");if(e.name==="")throw new o("'name' cannot be empty");let t={name:e.name};if("description"in e){if(typeof e.description!="string")throw new o("'description' must be a string when provided");t.description=e.description;}if("group"in e){if(typeof e.group!="string")throw new o("'group' must be a string when provided");t.group=e.group;}return "props"in e&&(t.props=g(e.props)),"options"in e&&(t.options=x(e.options)),t}exports.Environment=m;exports.Framework=l;exports.ModuleLoader=u;exports.PropType=s;exports.parseComponentData=C;exports.props=d; | ||
| 'use strict';var u=(o=>(o.FEDERATION="FEDERATION",o))(u||{}),l=(o=>(o.React="React",o))(l||{}),f=(n=>(n.Client="Client",n.Server="Server",n))(f||{}),s=(p=>(p.Id="Id",p.Text="Text",p.RichText="RichText",p.Link="Link",p.Image="Image",p.Visibility="Visibility",p.Slot="Slot",p))(s||{});var m={Text:e=>({type:"Text",defaultValue:e?.defaultValue,displayName:i(e)}),Id:e=>({type:"Id",displayName:i(e)}),Link:e=>({type:"Link",displayName:i(e)}),Image:e=>({type:"Image",displayName:i(e)}),Visibility:e=>({type:"Visibility",defaultValue:e?.defaultValue,displayName:i(e)}),Slot:e=>({type:"Slot",displayName:i(e)}),RichText:e=>({type:"RichText",displayName:i(e)})},d=Object.values(s).reduce((e,o)=>({...e,[o]:m[o]}),{});function i(e){return [e.group,e.name.replaceAll("/","-")].filter(Boolean).join("/")}var t=class extends Error{constructor(o){super(`Invalid ComponentData: ${o}`),this.name="InvalidComponentDataError";}};function y(e){return typeof e=="string"&&Object.values(s).includes(e)}function a(e,o){if(typeof e!="string")throw new t(`prop "${o}" 'name' must be a string`);if(e==="")throw new t(`prop "${o}" 'name' cannot be empty`);return e}function c(e,o){if(e!=null){if(typeof e!="string")throw new t(`prop "${o}" defaultValue must be a string for Text type`);return e}}function T(e,o){if(e!=null){if(typeof e!="boolean")throw new t(`prop "${o}" defaultValue must be a boolean for Visibility type`);return e}}function P(e,o,n){if(e!==void 0)throw new t(`prop "${o}" defaultValue is not supported for ${n} type`)}function w(e,o){let n=e.type;switch(n){case "Text":return {type:"Text",displayName:a(e.displayName,o),defaultValue:c(e.defaultValue,o)};case "Visibility":return {type:"Visibility",displayName:a(e.displayName,o),defaultValue:T(e.defaultValue,o)};case "Id":case "Link":case "Image":case "Slot":case "RichText":return {type:n,displayName:a(e.displayName,o),defaultValue:P(e.defaultValue,o,n)};default:let r=n;throw new t(`prop "${o}" has invalid type: ${r}`)}}function g(e){if(!e||typeof e!="object")throw new t("props must be an object");let o={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!="object")throw new t(`prop "${n}" must be an object`);if(!("type"in r))throw new t(`prop "${n}" is missing required field: type`);if(!y(r.type))throw new t(`prop "${n}" has invalid type: ${String(r.type)}`);o[n]=w(r,n);}return o}function C(e){if(!e||typeof e!="object")throw new t("options must be an object");let o={};for(let[n,r]of Object.entries(e))if(n==="applyTagSelectors"){if(typeof r!="boolean")throw new t('option "applyTagSelectors" must be a boolean');o.applyTagSelectors=r;}return o}function b(e){if(!e||typeof e!="object")throw new t("input must be an object");if(!("name"in e))throw new t("missing required field: 'name'");if(typeof e.name!="string")throw new t("'name' must be a string");if(e.name==="")throw new t("'name' cannot be empty");let o={name:e.name};if("description"in e){if(typeof e.description!="string")throw new t("'description' must be a string when provided");o.description=e.description;}if("group"in e){if(typeof e.group!="string")throw new t("'group' must be a string when provided");o.group=e.group;}return "props"in e&&(o.props=g(e.props)),"options"in e&&(o.options=C(e.options)),o}exports.Environment=f;exports.Framework=l;exports.ModuleLoader=u;exports.PropType=s;exports.parseComponentData=b;exports.props=d; |
+1
-4
@@ -26,3 +26,2 @@ /** | ||
| Text = "Text", | ||
| TextBlock = "TextBlock", | ||
| RichText = "RichText", | ||
@@ -38,3 +37,2 @@ Link = "Link", | ||
| [PropType.Text]: string; | ||
| [PropType.TextBlock]: NodeType; | ||
| [PropType.RichText]: NodeType; | ||
@@ -55,3 +53,3 @@ [PropType.Link]: { | ||
| type PropTypesWithOptionalDefaultValue = PropType.Text | PropType.Visibility; | ||
| type PropTypesWithoutDefaultValue = PropType.Id | PropType.Link | PropType.Image | PropType.Slot | PropType.TextBlock | PropType.RichText; | ||
| type PropTypesWithoutDefaultValue = PropType.Id | PropType.Link | PropType.Image | PropType.Slot | PropType.RichText; | ||
| type ComponentProp<T extends PropType = PropType, NodeType = unknown> = T extends PropTypesWithRequiredDefaultValue ? { | ||
@@ -151,3 +149,2 @@ defaultValue: PropValues<NodeType>[T]; | ||
| Text: PropConstructor<PropType.Text>; | ||
| TextBlock: PropConstructor<PropType.TextBlock>; | ||
| RichText: PropConstructor<PropType.RichText>; | ||
@@ -154,0 +151,0 @@ Link: PropConstructor<PropType.Link>; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| var u=(t=>(t.FEDERATION="FEDERATION",t))(u||{}),l=(t=>(t.React="React",t))(l||{}),m=(n=>(n.Client="Client",n.Server="Server",n))(m||{}),s=(p=>(p.Id="Id",p.Text="Text",p.TextBlock="TextBlock",p.RichText="RichText",p.Link="Link",p.Image="Image",p.Visibility="Visibility",p.Slot="Slot",p))(s||{});var f={Text:e=>({type:"Text",defaultValue:e?.defaultValue,displayName:i(e)}),Id:e=>({type:"Id",displayName:i(e)}),Link:e=>({type:"Link",displayName:i(e)}),Image:e=>({type:"Image",displayName:i(e)}),Visibility:e=>({type:"Visibility",defaultValue:e?.defaultValue,displayName:i(e)}),Slot:e=>({type:"Slot",displayName:i(e)}),TextBlock:e=>({type:"TextBlock",displayName:i(e)}),RichText:e=>({type:"RichText",displayName:i(e)})},d=Object.values(s).reduce((e,t)=>({...e,[t]:f[t]}),{});function i(e){return [e.group,e.name.replaceAll("/","-")].filter(Boolean).join("/")}var o=class extends Error{constructor(t){super(`Invalid ComponentData: ${t}`),this.name="InvalidComponentDataError";}};function y(e){return typeof e=="string"&&Object.values(s).includes(e)}function a(e,t){if(typeof e!="string")throw new o(`prop "${t}" 'name' must be a string`);if(e==="")throw new o(`prop "${t}" 'name' cannot be empty`);return e}function c(e,t){if(e!=null){if(typeof e!="string")throw new o(`prop "${t}" defaultValue must be a string for Text type`);return e}}function T(e,t){if(e!=null){if(typeof e!="boolean")throw new o(`prop "${t}" defaultValue must be a boolean for Visibility type`);return e}}function w(e,t,n){if(e!==void 0)throw new o(`prop "${t}" defaultValue is not supported for ${n} type`)}function P(e,t){let n=e.type;switch(n){case "Text":return {type:"Text",displayName:a(e.displayName,t),defaultValue:c(e.defaultValue,t)};case "Visibility":return {type:"Visibility",displayName:a(e.displayName,t),defaultValue:T(e.defaultValue,t)};case "Id":case "Link":case "Image":case "Slot":case "TextBlock":case "RichText":return {type:n,displayName:a(e.displayName,t),defaultValue:w(e.defaultValue,t,n)};default:let r=n;throw new o(`prop "${t}" has invalid type: ${r}`)}}function g(e){if(!e||typeof e!="object")throw new o("props must be an object");let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!="object")throw new o(`prop "${n}" must be an object`);if(!("type"in r))throw new o(`prop "${n}" is missing required field: type`);if(!y(r.type))throw new o(`prop "${n}" has invalid type: ${String(r.type)}`);t[n]=P(r,n);}return t}function x(e){if(!e||typeof e!="object")throw new o("options must be an object");let t={};for(let[n,r]of Object.entries(e))if(n==="applyTagSelectors"){if(typeof r!="boolean")throw new o('option "applyTagSelectors" must be a boolean');t.applyTagSelectors=r;}return t}function C(e){if(!e||typeof e!="object")throw new o("input must be an object");if(!("name"in e))throw new o("missing required field: 'name'");if(typeof e.name!="string")throw new o("'name' must be a string");if(e.name==="")throw new o("'name' cannot be empty");let t={name:e.name};if("description"in e){if(typeof e.description!="string")throw new o("'description' must be a string when provided");t.description=e.description;}if("group"in e){if(typeof e.group!="string")throw new o("'group' must be a string when provided");t.group=e.group;}return "props"in e&&(t.props=g(e.props)),"options"in e&&(t.options=x(e.options)),t}export{m as Environment,l as Framework,u as ModuleLoader,s as PropType,C as parseComponentData,d as props}; | ||
| var u=(o=>(o.FEDERATION="FEDERATION",o))(u||{}),l=(o=>(o.React="React",o))(l||{}),f=(n=>(n.Client="Client",n.Server="Server",n))(f||{}),s=(p=>(p.Id="Id",p.Text="Text",p.RichText="RichText",p.Link="Link",p.Image="Image",p.Visibility="Visibility",p.Slot="Slot",p))(s||{});var m={Text:e=>({type:"Text",defaultValue:e?.defaultValue,displayName:i(e)}),Id:e=>({type:"Id",displayName:i(e)}),Link:e=>({type:"Link",displayName:i(e)}),Image:e=>({type:"Image",displayName:i(e)}),Visibility:e=>({type:"Visibility",defaultValue:e?.defaultValue,displayName:i(e)}),Slot:e=>({type:"Slot",displayName:i(e)}),RichText:e=>({type:"RichText",displayName:i(e)})},d=Object.values(s).reduce((e,o)=>({...e,[o]:m[o]}),{});function i(e){return [e.group,e.name.replaceAll("/","-")].filter(Boolean).join("/")}var t=class extends Error{constructor(o){super(`Invalid ComponentData: ${o}`),this.name="InvalidComponentDataError";}};function y(e){return typeof e=="string"&&Object.values(s).includes(e)}function a(e,o){if(typeof e!="string")throw new t(`prop "${o}" 'name' must be a string`);if(e==="")throw new t(`prop "${o}" 'name' cannot be empty`);return e}function c(e,o){if(e!=null){if(typeof e!="string")throw new t(`prop "${o}" defaultValue must be a string for Text type`);return e}}function T(e,o){if(e!=null){if(typeof e!="boolean")throw new t(`prop "${o}" defaultValue must be a boolean for Visibility type`);return e}}function P(e,o,n){if(e!==void 0)throw new t(`prop "${o}" defaultValue is not supported for ${n} type`)}function w(e,o){let n=e.type;switch(n){case "Text":return {type:"Text",displayName:a(e.displayName,o),defaultValue:c(e.defaultValue,o)};case "Visibility":return {type:"Visibility",displayName:a(e.displayName,o),defaultValue:T(e.defaultValue,o)};case "Id":case "Link":case "Image":case "Slot":case "RichText":return {type:n,displayName:a(e.displayName,o),defaultValue:P(e.defaultValue,o,n)};default:let r=n;throw new t(`prop "${o}" has invalid type: ${r}`)}}function g(e){if(!e||typeof e!="object")throw new t("props must be an object");let o={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!="object")throw new t(`prop "${n}" must be an object`);if(!("type"in r))throw new t(`prop "${n}" is missing required field: type`);if(!y(r.type))throw new t(`prop "${n}" has invalid type: ${String(r.type)}`);o[n]=w(r,n);}return o}function C(e){if(!e||typeof e!="object")throw new t("options must be an object");let o={};for(let[n,r]of Object.entries(e))if(n==="applyTagSelectors"){if(typeof r!="boolean")throw new t('option "applyTagSelectors" must be a boolean');o.applyTagSelectors=r;}return o}function b(e){if(!e||typeof e!="object")throw new t("input must be an object");if(!("name"in e))throw new t("missing required field: 'name'");if(typeof e.name!="string")throw new t("'name' must be a string");if(e.name==="")throw new t("'name' cannot be empty");let o={name:e.name};if("description"in e){if(typeof e.description!="string")throw new t("'description' must be a string when provided");o.description=e.description;}if("group"in e){if(typeof e.group!="string")throw new t("'group' must be a string when provided");o.group=e.group;}return "props"in e&&(o.props=g(e.props)),"options"in e&&(o.options=C(e.options)),o}export{f as Environment,l as Framework,u as ModuleLoader,s as PropType,b as parseComponentData,d as props}; |
+1
-1
| { | ||
| "name": "@webflow/data-types", | ||
| "version": "0.0.4", | ||
| "version": "0.0.5", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs", |
15375
-1.78%166
-1.78%