@zag-js/types 0.0.0-dev-20220406144843

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,41 @@
1
+ export declare type ControlProp = {
2
+ type: "boolean";
3
+ label?: string;
4
+ defaultValue: boolean;
5
+ } | {
6
+ type: "string";
7
+ label?: string;
8
+ defaultValue: string;
9
+ placeholder?: string;
10
+ } | {
11
+ type: "select";
12
+ options: readonly string[];
13
+ defaultValue: string;
14
+ label?: string;
15
+ } | {
16
+ type: "multiselect";
17
+ options: readonly string[];
18
+ defaultValue: string[];
19
+ label?: string;
20
+ } | {
21
+ type: "number";
22
+ label?: string;
23
+ defaultValue: number;
24
+ min?: number;
25
+ max?: number;
26
+ };
27
+ export declare type ControlRecord = Record<string, ControlProp>;
28
+ export declare type ControlValue<T extends ControlRecord> = {
29
+ [K in keyof T]: T[K] extends {
30
+ type: "boolean";
31
+ } ? boolean : T[K] extends {
32
+ type: "string";
33
+ } ? string : T[K] extends {
34
+ type: "select";
35
+ } ? T[K]["options"][number] : T[K] extends {
36
+ type: "multiselect";
37
+ } ? T[K]["options"][number][] : T[K] extends {
38
+ type: "number";
39
+ } ? number : never;
40
+ };
41
+ export declare function defineControls<T extends ControlRecord>(config: T): T;
@@ -0,0 +1,31 @@
1
+ import type * as React from "react";
2
+ export declare type Direction = "ltr" | "rtl";
3
+ export declare type Orientation = "horizontal" | "vertical";
4
+ export declare type MaybeElement<T extends HTMLElement = HTMLElement> = T | null;
5
+ export declare type Context<T> = T & {
6
+ /**
7
+ * @internal
8
+ * The unique identifier of the accordion.
9
+ */
10
+ uid: string;
11
+ /**
12
+ * @internal
13
+ * The owner document of the accordion widget.
14
+ */
15
+ doc?: Document;
16
+ /**
17
+ * @internal
18
+ * The related target when the element is blurred.
19
+ * Used as a polyfill for `e.relatedTarget`
20
+ */
21
+ pointerdownNode?: HTMLElement | null;
22
+ /**
23
+ * The document's text/writing direction.
24
+ */
25
+ dir?: Direction;
26
+ };
27
+ export declare type Style = React.CSSProperties & {
28
+ [prop: string]: string | number | undefined;
29
+ };
30
+ export * from "./prop-types";
31
+ export * from "./controls";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=t=>a(t,"__esModule",{value:!0});var d=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},y=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of s(e))!p.call(t,o)&&(n||o!=="default")&&a(t,o,{get:()=>e[o],enumerable:!(r=i(e,o))||r.enumerable});return t};var b=(t=>(e,n)=>t&&t.get(e)||(n=y(u({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var c={};d(c,{createNormalizer:()=>l,defineControls:()=>m,normalizeProp:()=>T});function l(t){return{button:t,label:t,input:t,output:t,element:t}}var T=l(t=>t);function m(t){return t}module.exports=b(c);
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/prop-types.ts", "../src/controls.ts"],
4
+ "sourcesContent": ["import type * as React from \"react\"\n\nexport type Direction = \"ltr\" | \"rtl\"\n\nexport type Orientation = \"horizontal\" | \"vertical\"\n\nexport type MaybeElement<T extends HTMLElement = HTMLElement> = T | null\n\nexport type Context<T> = T & {\n /**\n * @internal\n * The unique identifier of the accordion.\n */\n uid: string\n /**\n * @internal\n * The owner document of the accordion widget.\n */\n doc?: Document\n /**\n * @internal\n * The related target when the element is blurred.\n * Used as a polyfill for `e.relatedTarget`\n */\n pointerdownNode?: HTMLElement | null\n /**\n * The document's text/writing direction.\n */\n dir?: Direction\n}\n\nexport type Style = React.CSSProperties & {\n [prop: string]: string | number | undefined\n}\n\nexport * from \"./prop-types\"\nexport * from \"./controls\"\n", "import type * as React from \"react\"\n\ntype Dict<T = any> = Record<string, T>\n\ntype Booleanish = boolean | \"true\" | \"false\"\n\ntype Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]?: T[P] }\n\ntype WithStyle<T extends { style?: any }> = Omit<T, \"style\"> & {\n style?: T[\"style\"] & {\n [prop: string]: string | number | undefined\n }\n}\n\ntype DataAttr = {\n \"data-uid\"?: string\n \"data-name\"?: string\n \"data-ownedby\"?: string\n \"data-selected\"?: Booleanish\n \"data-expanded\"?: Booleanish\n \"data-highlighted\"?: Booleanish\n \"data-readonly\"?: Booleanish\n \"data-invalid\"?: Booleanish\n \"data-hover\"?: Booleanish\n \"data-active\"?: Booleanish\n \"data-focus\"?: Booleanish\n \"data-disabled\"?: Booleanish\n \"data-type\"?: string\n \"data-value\"?: string | number\n \"data-valuetext\"?: string\n \"data-open\"?: Booleanish\n \"data-placement\"?: string\n \"data-orientation\"?: \"horizontal\" | \"vertical\"\n \"data-label\"?: string\n \"data-checked\"?: Booleanish\n \"data-pressed\"?: Booleanish\n \"data-state\"?: string | null\n \"data-half\"?: Booleanish\n \"data-count\"?: number\n \"data-controls\"?: string\n \"data-part\"?: string\n \"data-index\"?: number\n \"data-complete\"?: Booleanish\n \"data-empty\"?: Booleanish\n \"data-placeholder-shown\"?: Booleanish\n}\n\ntype JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>\ntype JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>\ntype JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>\ntype JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>\ntype JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>\n\nexport type PropTypes = Record<\"button\" | \"label\" | \"input\" | \"output\" | \"element\", Dict>\n\nexport type ReactPropTypes = {\n button: JSXButtonAttributes\n label: JSXLabelAttributes\n input: JSXInputAttributes\n output: JSXOutputAttributes\n element: JSXElementAttributes\n}\n\nexport type NormalizeProps = {\n button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T[\"button\"]\n label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T[\"label\"]\n input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T[\"input\"]\n output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T[\"output\"]\n element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T[\"element\"]\n}\n\nexport function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps {\n return { button: fn, label: fn, input: fn, output: fn, element: fn }\n}\n\nexport const normalizeProp = createNormalizer((v) => v)\n", "export type ControlProp =\n | { type: \"boolean\"; label?: string; defaultValue: boolean }\n | { type: \"string\"; label?: string; defaultValue: string; placeholder?: string }\n | { type: \"select\"; options: readonly string[]; defaultValue: string; label?: string }\n | { type: \"multiselect\"; options: readonly string[]; defaultValue: string[]; label?: string }\n | { type: \"number\"; label?: string; defaultValue: number; min?: number; max?: number }\n\nexport type ControlRecord = Record<string, ControlProp>\n\nexport type ControlValue<T extends ControlRecord> = {\n [K in keyof T]: T[K] extends { type: \"boolean\" }\n ? boolean\n : T[K] extends { type: \"string\" }\n ? string\n : T[K] extends { type: \"select\" }\n ? T[K][\"options\"][number]\n : T[K] extends { type: \"multiselect\" }\n ? T[K][\"options\"][number][]\n : T[K] extends { type: \"number\" }\n ? number\n : never\n}\n\nexport function defineControls<T extends ControlRecord>(config: T) {\n return config\n}\n"],
5
+ "mappings": "8gBAAA,gFCuEO,WAA0B,EAA2C,CAC1E,MAAO,CAAE,OAAQ,EAAI,MAAO,EAAI,MAAO,EAAI,OAAQ,EAAI,QAAS,GAG3D,GAAM,GAAgB,EAAiB,AAAC,GAAM,GCpD9C,WAAiD,EAAW,CACjE,MAAO",
6
+ "names": []
7
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ function e(t){return{button:t,label:t,input:t,output:t,element:t}}var n=e(t=>t);function a(t){return t}export{e as createNormalizer,a as defineControls,n as normalizeProp};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/prop-types.ts", "../src/controls.ts"],
4
+ "sourcesContent": ["import type * as React from \"react\"\n\ntype Dict<T = any> = Record<string, T>\n\ntype Booleanish = boolean | \"true\" | \"false\"\n\ntype Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]?: T[P] }\n\ntype WithStyle<T extends { style?: any }> = Omit<T, \"style\"> & {\n style?: T[\"style\"] & {\n [prop: string]: string | number | undefined\n }\n}\n\ntype DataAttr = {\n \"data-uid\"?: string\n \"data-name\"?: string\n \"data-ownedby\"?: string\n \"data-selected\"?: Booleanish\n \"data-expanded\"?: Booleanish\n \"data-highlighted\"?: Booleanish\n \"data-readonly\"?: Booleanish\n \"data-invalid\"?: Booleanish\n \"data-hover\"?: Booleanish\n \"data-active\"?: Booleanish\n \"data-focus\"?: Booleanish\n \"data-disabled\"?: Booleanish\n \"data-type\"?: string\n \"data-value\"?: string | number\n \"data-valuetext\"?: string\n \"data-open\"?: Booleanish\n \"data-placement\"?: string\n \"data-orientation\"?: \"horizontal\" | \"vertical\"\n \"data-label\"?: string\n \"data-checked\"?: Booleanish\n \"data-pressed\"?: Booleanish\n \"data-state\"?: string | null\n \"data-half\"?: Booleanish\n \"data-count\"?: number\n \"data-controls\"?: string\n \"data-part\"?: string\n \"data-index\"?: number\n \"data-complete\"?: Booleanish\n \"data-empty\"?: Booleanish\n \"data-placeholder-shown\"?: Booleanish\n}\n\ntype JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>\ntype JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>\ntype JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>\ntype JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>\ntype JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>\n\nexport type PropTypes = Record<\"button\" | \"label\" | \"input\" | \"output\" | \"element\", Dict>\n\nexport type ReactPropTypes = {\n button: JSXButtonAttributes\n label: JSXLabelAttributes\n input: JSXInputAttributes\n output: JSXOutputAttributes\n element: JSXElementAttributes\n}\n\nexport type NormalizeProps = {\n button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T[\"button\"]\n label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T[\"label\"]\n input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T[\"input\"]\n output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T[\"output\"]\n element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T[\"element\"]\n}\n\nexport function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps {\n return { button: fn, label: fn, input: fn, output: fn, element: fn }\n}\n\nexport const normalizeProp = createNormalizer((v) => v)\n", "export type ControlProp =\n | { type: \"boolean\"; label?: string; defaultValue: boolean }\n | { type: \"string\"; label?: string; defaultValue: string; placeholder?: string }\n | { type: \"select\"; options: readonly string[]; defaultValue: string; label?: string }\n | { type: \"multiselect\"; options: readonly string[]; defaultValue: string[]; label?: string }\n | { type: \"number\"; label?: string; defaultValue: number; min?: number; max?: number }\n\nexport type ControlRecord = Record<string, ControlProp>\n\nexport type ControlValue<T extends ControlRecord> = {\n [K in keyof T]: T[K] extends { type: \"boolean\" }\n ? boolean\n : T[K] extends { type: \"string\" }\n ? string\n : T[K] extends { type: \"select\" }\n ? T[K][\"options\"][number]\n : T[K] extends { type: \"multiselect\" }\n ? T[K][\"options\"][number][]\n : T[K] extends { type: \"number\" }\n ? number\n : never\n}\n\nexport function defineControls<T extends ControlRecord>(config: T) {\n return config\n}\n"],
5
+ "mappings": "AAuEO,WAA0B,EAA2C,CAC1E,MAAO,CAAE,OAAQ,EAAI,MAAO,EAAI,MAAO,EAAI,OAAQ,EAAI,QAAS,GAG3D,GAAM,GAAgB,EAAiB,AAAC,GAAM,GCpD9C,WAAiD,EAAW,CACjE,MAAO",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ import type * as React from "react";
2
+ declare type Dict<T = any> = Record<string, T>;
3
+ declare type Booleanish = boolean | "true" | "false";
4
+ declare type Omit<T, K extends keyof T> = {
5
+ [P in Exclude<keyof T, K>]?: T[P];
6
+ };
7
+ declare type WithStyle<T extends {
8
+ style?: any;
9
+ }> = Omit<T, "style"> & {
10
+ style?: T["style"] & {
11
+ [prop: string]: string | number | undefined;
12
+ };
13
+ };
14
+ declare type DataAttr = {
15
+ "data-uid"?: string;
16
+ "data-name"?: string;
17
+ "data-ownedby"?: string;
18
+ "data-selected"?: Booleanish;
19
+ "data-expanded"?: Booleanish;
20
+ "data-highlighted"?: Booleanish;
21
+ "data-readonly"?: Booleanish;
22
+ "data-invalid"?: Booleanish;
23
+ "data-hover"?: Booleanish;
24
+ "data-active"?: Booleanish;
25
+ "data-focus"?: Booleanish;
26
+ "data-disabled"?: Booleanish;
27
+ "data-type"?: string;
28
+ "data-value"?: string | number;
29
+ "data-valuetext"?: string;
30
+ "data-open"?: Booleanish;
31
+ "data-placement"?: string;
32
+ "data-orientation"?: "horizontal" | "vertical";
33
+ "data-label"?: string;
34
+ "data-checked"?: Booleanish;
35
+ "data-pressed"?: Booleanish;
36
+ "data-state"?: string | null;
37
+ "data-half"?: Booleanish;
38
+ "data-count"?: number;
39
+ "data-controls"?: string;
40
+ "data-part"?: string;
41
+ "data-index"?: number;
42
+ "data-complete"?: Booleanish;
43
+ "data-empty"?: Booleanish;
44
+ "data-placeholder-shown"?: Booleanish;
45
+ };
46
+ declare type JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>;
47
+ declare type JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>;
48
+ declare type JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>;
49
+ declare type JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>;
50
+ declare type JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>;
51
+ export declare type PropTypes = Record<"button" | "label" | "input" | "output" | "element", Dict>;
52
+ export declare type ReactPropTypes = {
53
+ button: JSXButtonAttributes;
54
+ label: JSXLabelAttributes;
55
+ input: JSXInputAttributes;
56
+ output: JSXOutputAttributes;
57
+ element: JSXElementAttributes;
58
+ };
59
+ export declare type NormalizeProps = {
60
+ button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T["button"];
61
+ label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T["label"];
62
+ input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T["input"];
63
+ output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T["output"];
64
+ element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T["element"];
65
+ };
66
+ export declare function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps;
67
+ export declare const normalizeProp: NormalizeProps;
68
+ export {};
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@zag-js/types",
3
+ "version": "0.0.0-dev-20220406144843",
4
+ "keywords": [
5
+ "js",
6
+ "utils",
7
+ "utils"
8
+ ],
9
+ "author": "Segun Adebayo <sage@adebayosegun.com>",
10
+ "homepage": "https://github.com/chakra-ui/ui-machines#readme",
11
+ "license": "MIT",
12
+ "main": "dist/index.js",
13
+ "module": "dist/index.mjs",
14
+ "types": "dist/index.d.ts",
15
+ "repository": "https://github.com/chakra-ui/ui-machines/tree/main/packages/utilities/types",
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/chakra-ui/ui-machines/issues"
25
+ }
26
+ }