@ark-ui/react 0.9.0 → 0.10.0-beta.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.
- package/CHANGELOG.md +10 -2
- package/factory.d.ts +6 -1
- package/number-input/use-number-input.cjs +8 -1
- package/number-input/use-number-input.mjs +9 -2
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@ description: All notable changes to this project will be documented in this file
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.10.0-beta.0] - 2023-07-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Updated number input `onChange` handler to allow synchronous updates to the value when using the scrubber.
|
|
14
|
+
- Improved TypeScript typings in our factory functions. The changes allow for more accurate type inference for the `ref` property when dealing with both intrinsic HTML elements and custom React components.
|
|
15
|
+
|
|
9
16
|
## [0.9.0] - 2023-07-21
|
|
10
17
|
|
|
11
18
|
### Added
|
|
@@ -133,7 +140,7 @@ description: All notable changes to this project will be documented in this file
|
|
|
133
140
|
- Add `Toast`
|
|
134
141
|
- Add `Tooltip`
|
|
135
142
|
|
|
136
|
-
[unreleased]: https://github.com/chakra-ui/ark/compare/@ark-ui/react@0.
|
|
143
|
+
[unreleased]: https://github.com/chakra-ui/ark/compare/@ark-ui/react@0.10.0-beta.0...HEAD
|
|
137
144
|
[0.1.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.1.0
|
|
138
145
|
[0.2.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.2.0
|
|
139
146
|
[0.3.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.3.0
|
|
@@ -146,5 +153,6 @@ description: All notable changes to this project will be documented in this file
|
|
|
146
153
|
[0.7.3]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.7.3
|
|
147
154
|
[0.8.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.8.0
|
|
148
155
|
[0.8.1]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.8.1
|
|
149
|
-
|
|
150
156
|
[0.9.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.9.0
|
|
157
|
+
|
|
158
|
+
[0.10.0-beta.0]: https://github.com/chakra-ui/ark/releases/tag/@ark-ui/react@0.10.0-beta.0
|
package/factory.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export type AsChildProps = {
|
|
2
3
|
asChild?: boolean;
|
|
3
4
|
};
|
|
@@ -5,7 +6,11 @@ type JsxElements = {
|
|
|
5
6
|
[E in keyof JSX.IntrinsicElements]: AsChildForwardRefComponent<E>;
|
|
6
7
|
};
|
|
7
8
|
export type AsChildForwardRefComponent<E extends React.ElementType> = React.ForwardRefExoticComponent<AsChildComponentProps<E>>;
|
|
8
|
-
export type AsChildComponentProps<E extends React.ElementType> = React.ComponentProps<E> & AsChildProps
|
|
9
|
+
export type AsChildComponentProps<E extends React.ElementType> = Omit<React.ComponentProps<E>, 'ref'> & AsChildProps & {
|
|
10
|
+
ref?: E extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[E] extends {
|
|
11
|
+
ref?: infer R;
|
|
12
|
+
} ? R : never : React.RefObject<HTMLElement>;
|
|
13
|
+
};
|
|
9
14
|
export type HTMLArkProps<T extends React.ElementType> = AsChildComponentProps<T>;
|
|
10
15
|
export declare const jsxFactory: () => JsxElements;
|
|
11
16
|
export declare const ark: JsxElements;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
6
6
|
const numberInput = require('@zag-js/number-input');
|
|
7
7
|
const react = require('@zag-js/react');
|
|
8
8
|
const React = require('react');
|
|
9
|
+
const reactDom = require('react-dom');
|
|
9
10
|
const environmentContext = require('../environment/environment-context.cjs');
|
|
10
11
|
|
|
11
12
|
function _interopNamespaceDefault(e) {
|
|
@@ -35,9 +36,15 @@ const useNumberInput = (props) => {
|
|
|
35
36
|
...props,
|
|
36
37
|
value: props.defaultValue
|
|
37
38
|
};
|
|
39
|
+
const onChange = props.onChange;
|
|
40
|
+
const onChangeWithFlushSync = React.useCallback(
|
|
41
|
+
(e) => reactDom.flushSync(() => onChange?.(e)),
|
|
42
|
+
[onChange]
|
|
43
|
+
);
|
|
38
44
|
const context = {
|
|
39
45
|
...initialContext,
|
|
40
|
-
value: props.value
|
|
46
|
+
value: props.value,
|
|
47
|
+
onChange: onChangeWithFlushSync
|
|
41
48
|
};
|
|
42
49
|
const [state, send] = react.useMachine(numberInput__namespace.machine(initialContext), { context });
|
|
43
50
|
return numberInput__namespace.connect(state, send, react.normalizeProps);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as numberInput from '@zag-js/number-input';
|
|
3
3
|
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
4
|
-
import { useId } from 'react';
|
|
4
|
+
import { useId, useCallback } from 'react';
|
|
5
|
+
import { flushSync } from 'react-dom';
|
|
5
6
|
import { useEnvironmentContext } from '../environment/environment-context.mjs';
|
|
6
7
|
|
|
7
8
|
const useNumberInput = (props) => {
|
|
@@ -12,9 +13,15 @@ const useNumberInput = (props) => {
|
|
|
12
13
|
...props,
|
|
13
14
|
value: props.defaultValue
|
|
14
15
|
};
|
|
16
|
+
const onChange = props.onChange;
|
|
17
|
+
const onChangeWithFlushSync = useCallback(
|
|
18
|
+
(e) => flushSync(() => onChange?.(e)),
|
|
19
|
+
[onChange]
|
|
20
|
+
);
|
|
15
21
|
const context = {
|
|
16
22
|
...initialContext,
|
|
17
|
-
value: props.value
|
|
23
|
+
value: props.value,
|
|
24
|
+
onChange: onChangeWithFlushSync
|
|
18
25
|
};
|
|
19
26
|
const [state, send] = useMachine(numberInput.machine(initialContext), { context });
|
|
20
27
|
return numberInput.connect(state, send, normalizeProps);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-beta.0",
|
|
4
4
|
"description": "A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accordion",
|
|
@@ -96,19 +96,19 @@
|
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@release-it/keep-a-changelog": "4.0.0",
|
|
99
|
-
"@storybook/addon-a11y": "7.1.
|
|
100
|
-
"@storybook/addon-essentials": "7.1.
|
|
101
|
-
"@storybook/addons": "7.1.
|
|
102
|
-
"@storybook/react": "7.1.
|
|
103
|
-
"@storybook/react-vite": "7.1.
|
|
99
|
+
"@storybook/addon-a11y": "7.1.1",
|
|
100
|
+
"@storybook/addon-essentials": "7.1.1",
|
|
101
|
+
"@storybook/addons": "7.1.1",
|
|
102
|
+
"@storybook/react": "7.1.1",
|
|
103
|
+
"@storybook/react-vite": "7.1.1",
|
|
104
104
|
"@testing-library/dom": "9.3.1",
|
|
105
105
|
"@testing-library/jest-dom": "5.17.0",
|
|
106
106
|
"@testing-library/react": "14.0.0",
|
|
107
107
|
"@testing-library/user-event": "14.4.3",
|
|
108
108
|
"@types/jsdom": "21.1.1",
|
|
109
|
-
"@types/react": "18.2.
|
|
109
|
+
"@types/react": "18.2.16",
|
|
110
110
|
"@types/react-dom": "18.2.7",
|
|
111
|
-
"@types/testing-library__jest-dom": "5.14.
|
|
111
|
+
"@types/testing-library__jest-dom": "5.14.9",
|
|
112
112
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
113
113
|
"@typescript-eslint/parser": "5.62.0",
|
|
114
114
|
"@vitejs/plugin-react": "4.0.3",
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
"react-frame-component": "5.2.6",
|
|
124
124
|
"release-it": "16.1.3",
|
|
125
125
|
"resize-observer-polyfill": "1.5.1",
|
|
126
|
-
"storybook": "7.1.
|
|
126
|
+
"storybook": "7.1.1",
|
|
127
127
|
"typescript": "5.1.6",
|
|
128
|
-
"vite": "4.4.
|
|
128
|
+
"vite": "4.4.7",
|
|
129
129
|
"vite-plugin-dts": "2.3.0",
|
|
130
130
|
"vitest": "0.33.0"
|
|
131
131
|
},
|