@makeswift/prop-controllers 0.4.14-canary.3 → 0.4.15-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/text-area/text-area.ts"],"sourcesContent":["import { AcceptedTextDataTypes } from '@makeswift/controls'\nimport { z } from 'zod'\nimport { ControlDataTypeKey, Options, Types } from '../prop-controllers'\nimport { P, match } from 'ts-pattern'\n\nconst textAreaPropControllerDataV0Schema = z.string()\n\nexport type TextAreaPropControllerDataV0 = z.infer<\n typeof textAreaPropControllerDataV0Schema\n>\n\nexport const TextAreaPropControllerDataV1Type =\n 'prop-controllers::text-area::v1'\n\nconst textAreaPropControllerDataV1Schema = z.object({\n [ControlDataTypeKey]: z.literal(TextAreaPropControllerDataV1Type),\n value: z.string(),\n})\n\nexport type TextAreaPropControllerDataV1 = z.infer<\n typeof textAreaPropControllerDataV1Schema\n>\n\nconst textAreaInteropDataSchema = z.object({\n [ControlDataTypeKey]: z.enum(AcceptedTextDataTypes),\n value: z.string(),\n})\n\nexport const textAreaPropControllerDataSchema = z.union([\n textAreaPropControllerDataV0Schema,\n textAreaPropControllerDataV1Schema,\n textAreaInteropDataSchema,\n])\n\nexport type TextAreaPropControllerData = z.infer<\n typeof textAreaPropControllerDataSchema\n>\n\nexport type TextAreaOptions = Options<{\n preset?: TextAreaPropControllerData\n label?: string\n rows?: number\n}>\n\ntype TextAreaDescriptorV0<_T = TextAreaPropControllerDataV0> = {\n type: typeof Types.TextArea\n options: TextAreaOptions\n}\n\ntype TextAreaDescriptorV1<\n _T = TextAreaPropControllerData,\n U extends TextAreaOptions = TextAreaOptions,\n> = {\n type: typeof Types.TextArea\n version: 1\n options: U\n}\n\nexport type TextAreaDescriptor<_T = TextAreaPropControllerData> =\n | TextAreaDescriptorV0\n | TextAreaDescriptorV1\n\nexport type ResolveTextAreaPropControllerValue<T extends TextAreaDescriptor> =\n T extends TextAreaDescriptor ? string | undefined : never\n\n/**\n * @deprecated Imports from @makeswift/prop-controllers are deprecated. Use\n * @makeswift/runtime/controls instead.\n */\nexport function TextArea(options: TextAreaOptions = {}): TextAreaDescriptorV1 {\n return { type: Types.TextArea, version: 1, options }\n}\n\nexport function getTextAreaPropControllerDataString(\n data: TextAreaPropControllerData | undefined,\n): string | undefined {\n return match(data)\n .with(\n { [ControlDataTypeKey]: P.union(...AcceptedTextDataTypes) },\n (versioned) => versioned.value,\n )\n .otherwise((v0) => v0)\n}\n\nexport function createTextAreaPropControllerDataFromString(\n value: string,\n definition: TextAreaDescriptor,\n): TextAreaPropControllerData {\n return match(definition)\n .with(\n { version: 1 },\n () =>\n ({\n [ControlDataTypeKey]: TextAreaPropControllerDataV1Type,\n value,\n }) as const,\n )\n .otherwise(() => value)\n}\n"],"mappings":"AAAA,SAAS,6BAA6B;AACtC,SAAS,SAAS;AAClB,SAAS,oBAA6B,aAAa;AACnD,SAAS,GAAG,aAAa;AAEzB,MAAM,qCAAqC,EAAE,OAAO;AAM7C,MAAM,mCACX;AAEF,MAAM,qCAAqC,EAAE,OAAO;AAAA,EAClD,CAAC,kBAAkB,GAAG,EAAE,QAAQ,gCAAgC;AAAA,EAChE,OAAO,EAAE,OAAO;AAClB,CAAC;AAMD,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,CAAC,kBAAkB,GAAG,EAAE,KAAK,qBAAqB;AAAA,EAClD,OAAO,EAAE,OAAO;AAClB,CAAC;AAEM,MAAM,mCAAmC,EAAE,MAAM;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAqCM,SAAS,SAAS,UAA2B,CAAC,GAAyB;AAC5E,SAAO,EAAE,MAAM,MAAM,UAAU,SAAS,GAAG,QAAQ;AACrD;AAEO,SAAS,oCACd,MACoB;AACpB,SAAO,MAAM,IAAI,EACd;AAAA,IACC,EAAE,CAAC,kBAAkB,GAAG,EAAE,MAAM,GAAG,qBAAqB,EAAE;AAAA,IAC1D,CAAC,cAAc,UAAU;AAAA,EAC3B,EACC,UAAU,CAAC,OAAO,EAAE;AACzB;AAEO,SAAS,2CACd,OACA,YAC4B;AAC5B,SAAO,MAAM,UAAU,EACpB;AAAA,IACC,EAAE,SAAS,EAAE;AAAA,IACb,OACG;AAAA,MACC,CAAC,kBAAkB,GAAG;AAAA,MACtB;AAAA,IACF;AAAA,EACJ,EACC,UAAU,MAAM,KAAK;AAC1B;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/video/video.ts"],"sourcesContent":["import { z } from 'zod'\nimport { ControlDataTypeKey, Options, Types } from '../prop-controllers'\nimport { P, match } from 'ts-pattern'\n\nconst videoDataSchema = z.object({\n url: z.string().optional(),\n muted: z.boolean().optional(),\n playing: z.boolean().optional(),\n loop: z.boolean().optional(),\n controls: z.boolean().optional(),\n})\n\nexport type VideoData = z.infer<typeof videoDataSchema>\n\nconst videoPropControllerDataV0Schema = videoDataSchema\n\nexport type VideoPropControllerDataV0 = z.infer<\n typeof videoPropControllerDataV0Schema\n>\n\nexport const VideoPropControllerDataV1Type = 'prop-controllers::video::v1'\n\nconst videoPropControllerDataV1Schema = z.object({\n [ControlDataTypeKey]: z.literal(VideoPropControllerDataV1Type),\n value: videoDataSchema,\n})\n\nexport type VideoPropControllerDataV1 = z.infer<\n typeof videoPropControllerDataV1Schema\n>\n\nexport const videoPropControllerDataSchema = z.union([\n videoPropControllerDataV1Schema,\n videoPropControllerDataV0Schema,\n])\n\nexport type VideoPropControllerData = z.infer<\n typeof videoPropControllerDataSchema\n>\n\nexport type VideoOptions = Options<{\n preset?: VideoPropControllerData\n}>\n\ntype VideoDescriptorV0<_T = VideoPropControllerDataV0> = {\n type: typeof Types.Video\n options: VideoOptions\n}\n\ntype VideoDescriptorV1<\n _T = VideoPropControllerData,\n U extends VideoOptions = VideoOptions,\n> = {\n type: typeof Types.Video\n version: 1\n options: U\n}\n\nexport type VideoDescriptor<_T = VideoPropControllerData> =\n | VideoDescriptorV0\n | VideoDescriptorV1\n\nexport type ResolveVideoPropControllerValue<T extends VideoDescriptor> =\n T extends VideoDescriptor ? VideoData | undefined : never\n\n/**\n * @deprecated Imports from @makeswift/prop-controllers are deprecated. Use\n * @makeswift/runtime/controls instead.\n */\nexport function Video(options: VideoOptions = {}): VideoDescriptorV1 {\n return { type: Types.Video, version: 1, options }\n}\n\nexport function getVideoPropControllerDataVideoData(\n data: VideoPropControllerData | undefined,\n): VideoData | undefined {\n return match(data)\n .with(\n { [ControlDataTypeKey]: VideoPropControllerDataV1Type },\n (v1) => v1.value,\n )\n .otherwise((v0) => v0)\n}\n\nexport function createVideoPropControllerDataFromVideoData(\n value: VideoData,\n definition?: VideoDescriptor,\n): VideoPropControllerData {\n return match(definition)\n .with(\n { version: 1 },\n P.nullish,\n () =>\n ({\n [ControlDataTypeKey]: VideoPropControllerDataV1Type,\n value,\n } as const),\n )\n .otherwise(() => value)\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAClB,SAAS,oBAA6B,aAAa;AACnD,SAAS,GAAG,aAAa;AAEzB,MAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,KAAK,EAAE,OAAO,EAAE,SAAS;AAAA,EACzB,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC5B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,MAAM,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC3B,UAAU,EAAE,QAAQ,EAAE,SAAS;AACjC,CAAC;AAID,MAAM,kCAAkC;AAMjC,MAAM,gCAAgC;AAE7C,MAAM,kCAAkC,EAAE,OAAO;AAAA,EAC/C,CAAC,kBAAkB,GAAG,EAAE,QAAQ,6BAA6B;AAAA,EAC7D,OAAO;AACT,CAAC;AAMM,MAAM,gCAAgC,EAAE,MAAM;AAAA,EACnD;AAAA,EACA;AACF,CAAC;AAmCM,SAAS,MAAM,UAAwB,CAAC,GAAsB;AACnE,SAAO,EAAE,MAAM,MAAM,OAAO,SAAS,GAAG,QAAQ;AAClD;AAEO,SAAS,oCACd,MACuB;AACvB,SAAO,MAAM,IAAI,EACd;AAAA,IACC,EAAE,CAAC,kBAAkB,GAAG,8BAA8B;AAAA,IACtD,CAAC,OAAO,GAAG;AAAA,EACb,EACC,UAAU,CAAC,OAAO,EAAE;AACzB;AAEO,SAAS,2CACd,OACA,YACyB;AACzB,SAAO,MAAM,UAAU,EACpB;AAAA,IACC,EAAE,SAAS,EAAE;AAAA,IACb,EAAE;AAAA,IACF,OACG;AAAA,MACC,CAAC,kBAAkB,GAAG;AAAA,MACtB;AAAA,IACF;AAAA,EACJ,EACC,UAAU,MAAM,KAAK;AAC1B;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/width/width.ts"],"sourcesContent":["import { P, match } from 'ts-pattern'\nimport { ControlDataTypeKey, ResolveOptions, Types } from '../prop-controllers'\nimport { z } from 'zod'\nimport { LengthData } from '../data'\nimport {\n ResponsiveLengthData,\n responsiveLengthDataSchema,\n} from '../responsive-length'\n\nconst widthPropControllerDataV0Schema = responsiveLengthDataSchema\n\nexport type WidthPropControllerDataV0 = z.infer<\n typeof widthPropControllerDataV0Schema\n>\n\nexport const WidthPropControllerDataV1Type = 'prop-controllers::width::v1'\n\nconst widthPropControllerDataV1Schema = z.object({\n [ControlDataTypeKey]: z.literal(WidthPropControllerDataV1Type),\n value: responsiveLengthDataSchema,\n})\n\nexport type WidthPropControllerDataV1 = z.infer<\n typeof widthPropControllerDataV1Schema\n>\n\nexport const widthPropControllerDataSchema = z.union([\n widthPropControllerDataV0Schema,\n widthPropControllerDataV1Schema,\n])\n\nexport type WidthPropControllerData = z.infer<\n typeof widthPropControllerDataSchema\n>\n\nexport const WidthPropControllerFormat = {\n ClassName: 'makeswift::prop-controllers::width::format::class-name',\n ResponsiveValue:\n 'makeswift::prop-controllers::width::format::responsive-value',\n} as const\n\nexport type WidthPropControllerFormat =\n typeof WidthPropControllerFormat[keyof typeof WidthPropControllerFormat]\n\ntype WidthOptions = {\n preset?: WidthPropControllerData\n defaultValue?: LengthData\n format?: WidthPropControllerFormat\n}\n\ntype WidthDescriptorV0<\n _T = WidthPropControllerDataV0,\n U extends WidthOptions = WidthOptions,\n> = {\n type: typeof Types.Width\n options: U\n}\n\ntype WidthDescriptorV1<\n _T = WidthPropControllerData,\n U extends WidthOptions = WidthOptions,\n> = {\n type: typeof Types.Width\n version: 1\n options: U\n}\n\nexport type WidthDescriptor<\n _T = WidthPropControllerData,\n U extends WidthOptions = WidthOptions,\n> = WidthDescriptorV0<_T, U> | WidthDescriptorV1<_T, U>\n\nexport type ResolveWidthPropControllerValue<T extends WidthDescriptor> =\n T extends WidthDescriptor\n ? undefined extends ResolveOptions<T['options']>['format']\n ? ResponsiveLengthData | undefined\n : ResolveOptions<\n T['options']\n >['format'] extends typeof WidthPropControllerFormat.ClassName\n ? string\n : ResolveOptions<\n T['options']\n >['format'] extends typeof WidthPropControllerFormat.ResponsiveValue\n ? ResponsiveLengthData | undefined\n : never\n : never\n\n/**\n * @deprecated Imports from `@makeswift/prop-controllers` are deprecated. Use\n * `@makeswift/runtime/controls` instead.\n */\nexport function Width<T extends WidthOptions>(\n options: T & WidthOptions = {} as T,\n): WidthDescriptor<WidthPropControllerData, T> {\n return { type: Types.Width, version: 1, options }\n}\n\nWidth.Format = WidthPropControllerFormat\n\nexport function getWidthPropControllerDataResponsiveLengthData(\n data: WidthPropControllerData | undefined,\n): ResponsiveLengthData | undefined {\n return match(data)\n .with(\n { [ControlDataTypeKey]: WidthPropControllerDataV1Type },\n (v1) => v1.value,\n )\n .otherwise((v0) => v0)\n}\n\nexport function createWidthPropControllerDataFromResponsiveLengthData(\n responsiveLengthData: ResponsiveLengthData,\n definition?: WidthDescriptor,\n): WidthPropControllerData {\n return match(definition)\n .with(\n { version: 1 },\n P.nullish,\n () =>\n ({\n [ControlDataTypeKey]: WidthPropControllerDataV1Type,\n value: responsiveLengthData,\n } as const),\n )\n .otherwise(() => responsiveLengthData)\n}\n"],"mappings":"AAAA,SAAS,GAAG,aAAa;AACzB,SAAS,oBAAoC,aAAa;AAC1D,SAAS,SAAS;AAElB;AAAA,EAEE;AAAA,OACK;AAEP,MAAM,kCAAkC;AAMjC,MAAM,gCAAgC;AAE7C,MAAM,kCAAkC,EAAE,OAAO;AAAA,EAC/C,CAAC,kBAAkB,GAAG,EAAE,QAAQ,6BAA6B;AAAA,EAC7D,OAAO;AACT,CAAC;AAMM,MAAM,gCAAgC,EAAE,MAAM;AAAA,EACnD;AAAA,EACA;AACF,CAAC;AAMM,MAAM,4BAA4B;AAAA,EACvC,WAAW;AAAA,EACX,iBACE;AACJ;AAoDO,SAAS,MACd,UAA4B,CAAC,GACgB;AAC7C,SAAO,EAAE,MAAM,MAAM,OAAO,SAAS,GAAG,QAAQ;AAClD;AAEA,MAAM,SAAS;AAER,SAAS,+CACd,MACkC;AAClC,SAAO,MAAM,IAAI,EACd;AAAA,IACC,EAAE,CAAC,kBAAkB,GAAG,8BAA8B;AAAA,IACtD,CAAC,OAAO,GAAG;AAAA,EACb,EACC,UAAU,CAAC,OAAO,EAAE;AACzB;AAEO,SAAS,sDACd,sBACA,YACyB;AACzB,SAAO,MAAM,UAAU,EACpB;AAAA,IACC,EAAE,SAAS,EAAE;AAAA,IACb,EAAE;AAAA,IACF,OACG;AAAA,MACC,CAAC,kBAAkB,GAAG;AAAA,MACtB,OAAO;AAAA,IACT;AAAA,EACJ,EACC,UAAU,MAAM,oBAAoB;AACzC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/prop-controllers",
3
- "version": "0.4.14-canary.3",
3
+ "version": "0.4.15-canary.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "url": "makeswift/makeswift",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "ts-pattern": "^5.0.8",
17
17
  "zod": "^3.21.4",
18
- "@makeswift/controls": "0.1.20-canary.3"
18
+ "@makeswift/controls": "0.1.21-canary.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@swc/jest": "^0.2.36",