@zag-js/types 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as React from "react";
1
+ import type { JSX } from "./jsx";
2
2
  export declare type Direction = "ltr" | "rtl";
3
3
  export declare type Orientation = "horizontal" | "vertical";
4
4
  export declare type MaybeElement<T extends HTMLElement = HTMLElement> = T | null;
@@ -33,8 +33,6 @@ export declare type Context<T> = T & RootProperties & {
33
33
  */
34
34
  pointerdownNode?: HTMLElement | null;
35
35
  };
36
- export declare type Style = React.CSSProperties & {
37
- [prop: string]: string | number | undefined;
38
- };
36
+ export declare type Style = JSX.CSSProperties;
39
37
  export * from "./prop-types";
40
- export * from "./controls";
38
+ export type { JSX };
package/dist/index.js CHANGED
@@ -20,9 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- createNormalizer: () => createNormalizer,
24
- defineControls: () => defineControls,
25
- normalizeProp: () => normalizeProp
23
+ createNormalizer: () => createNormalizer
26
24
  });
27
25
  module.exports = __toCommonJS(src_exports);
28
26
 
@@ -34,9 +32,3 @@ function createNormalizer(fn) {
34
32
  }
35
33
  });
36
34
  }
37
- var normalizeProp = createNormalizer((v) => v);
38
-
39
- // src/controls.ts
40
- function defineControls(config) {
41
- return config;
42
- }
package/dist/index.mjs CHANGED
@@ -1,5 +1,3 @@
1
- "use strict";
2
-
3
1
  // src/prop-types.ts
4
2
  function createNormalizer(fn) {
5
3
  return new Proxy({}, {
@@ -8,14 +6,6 @@ function createNormalizer(fn) {
8
6
  }
9
7
  });
10
8
  }
11
- var normalizeProp = createNormalizer((v) => v);
12
-
13
- // src/controls.ts
14
- function defineControls(config) {
15
- return config;
16
- }
17
9
  export {
18
- createNormalizer,
19
- defineControls,
20
- normalizeProp
10
+ createNormalizer
21
11
  };
@@ -1,20 +1,7 @@
1
- import type * as React from "react";
1
+ import type { JSX } from "./jsx";
2
2
  declare type Dict<T = any> = Record<string, T>;
3
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
4
  declare type DataAttr = {
15
- "data-uid"?: string;
16
- "data-name"?: string;
17
- "data-ownedby"?: string;
18
5
  "data-selected"?: Booleanish;
19
6
  "data-expanded"?: Booleanish;
20
7
  "data-highlighted"?: Booleanish;
@@ -25,45 +12,33 @@ declare type DataAttr = {
25
12
  "data-active"?: Booleanish;
26
13
  "data-focus"?: Booleanish;
27
14
  "data-disabled"?: Booleanish;
28
- "data-type"?: string;
29
- "data-value"?: string | number;
30
- "data-valuetext"?: string;
31
15
  "data-open"?: Booleanish;
32
- "data-placement"?: string;
33
- "data-orientation"?: "horizontal" | "vertical";
34
- "data-label"?: string;
35
16
  "data-checked"?: Booleanish;
36
17
  "data-pressed"?: Booleanish;
37
- "data-state"?: string | null;
18
+ "data-complete"?: Booleanish;
19
+ "data-empty"?: Booleanish;
20
+ "data-placeholder-shown"?: Booleanish;
38
21
  "data-half"?: Booleanish;
39
- "data-count"?: number;
22
+ "data-uid"?: string;
23
+ "data-name"?: string;
24
+ "data-ownedby"?: string;
25
+ "data-type"?: string;
26
+ "data-valuetext"?: string;
27
+ "data-placement"?: string;
40
28
  "data-controls"?: string;
41
29
  "data-part"?: string;
30
+ "data-label"?: string;
31
+ "data-state"?: string | null;
32
+ "data-value"?: string | number;
33
+ "data-orientation"?: "horizontal" | "vertical";
34
+ "data-count"?: number;
42
35
  "data-index"?: number;
43
- "data-complete"?: Booleanish;
44
- "data-empty"?: Booleanish;
45
- "data-placeholder-shown"?: Booleanish;
46
36
  };
47
- declare type JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>;
48
- declare type JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>;
49
- declare type JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>;
50
- declare type JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>;
51
- declare type JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>;
52
37
  export declare type PropTypes = Record<"button" | "label" | "input" | "output" | "element", Dict>;
53
- export declare type ReactPropTypes = {
54
- button: JSXButtonAttributes;
55
- label: JSXLabelAttributes;
56
- input: JSXInputAttributes;
57
- output: JSXOutputAttributes;
58
- element: JSXElementAttributes;
59
- };
60
- export declare type NormalizeProps = {
61
- button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T["button"];
62
- label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T["label"];
63
- input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T["input"];
64
- output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T["output"];
65
- element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T["element"];
38
+ export declare type NormalizeProps<T extends PropTypes> = {
39
+ [K in keyof T]: (props: K extends keyof JSX.IntrinsicElements ? DataAttr & JSX.IntrinsicElements[K] : never) => T[K];
40
+ } & {
41
+ element(props: DataAttr & JSX.HTMLAttributes<HTMLElement>): T["element"];
66
42
  };
67
- export declare function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps;
68
- export declare const normalizeProp: NormalizeProps;
43
+ export declare function createNormalizer<T extends PropTypes>(fn: (props: Dict) => Dict): NormalizeProps<T>;
69
44
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/types",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "keywords": [
5
5
  "js",
6
6
  "utils",
@@ -23,6 +23,9 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/chakra-ui/zag/issues"
25
25
  },
26
+ "dependencies": {
27
+ "csstype": "3.1.0"
28
+ },
26
29
  "scripts": {
27
30
  "build:fast": "zag build",
28
31
  "start": "zag build --watch",
@@ -32,4 +35,4 @@
32
35
  "test:ci": "yarn test --ci --runInBand",
33
36
  "test:watch": "yarn test --watch --updateSnapshot"
34
37
  }
35
- }
38
+ }
@@ -1,41 +0,0 @@
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;