@ark-ui/react 0.0.0-rc-20230204032034 → 0.0.0-rc-20230206155445
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.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +4 -0
- package/dist/splitter/index.d.ts +4 -0
- package/dist/splitter/splitter-context.cjs +14 -0
- package/dist/splitter/splitter-context.d.ts +49 -0
- package/dist/splitter/splitter-context.mjs +9 -0
- package/dist/splitter/splitter-panel.cjs +22 -0
- package/dist/splitter/splitter-panel.d.ts +8 -0
- package/dist/splitter/splitter-panel.mjs +18 -0
- package/dist/splitter/splitter-resize-trigger.cjs +15 -0
- package/dist/splitter/splitter-resize-trigger.d.ts +9 -0
- package/dist/splitter/splitter-resize-trigger.mjs +11 -0
- package/dist/splitter/splitter.anatomy.d.ts +1 -0
- package/dist/splitter/splitter.cjs +29 -0
- package/dist/splitter/splitter.d.ts +6 -0
- package/dist/splitter/splitter.mjs +25 -0
- package/dist/splitter/use-splitter.cjs +21 -0
- package/dist/splitter/use-splitter.d.ts +29 -0
- package/dist/splitter/use-splitter.mjs +17 -0
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -154,6 +154,10 @@ const sliderThumb = require('./slider/slider-thumb.cjs');
|
|
|
154
154
|
const sliderTrack = require('./slider/slider-track.cjs');
|
|
155
155
|
const slider$1 = require('@zag-js/slider');
|
|
156
156
|
const useSlider = require('./slider/use-slider.cjs');
|
|
157
|
+
const splitter = require('./splitter/splitter.cjs');
|
|
158
|
+
const splitterPanel = require('./splitter/splitter-panel.cjs');
|
|
159
|
+
const splitterResizeTrigger = require('./splitter/splitter-resize-trigger.cjs');
|
|
160
|
+
const splitter$1 = require('@zag-js/splitter');
|
|
157
161
|
const tabContent = require('./tabs/tab-content.cjs');
|
|
158
162
|
const tabIndicator = require('./tabs/tab-indicator.cjs');
|
|
159
163
|
const tabList = require('./tabs/tab-list.cjs');
|
|
@@ -400,6 +404,13 @@ Object.defineProperty(exports, 'sliderAnatomy', {
|
|
|
400
404
|
get: () => slider$1.anatomy
|
|
401
405
|
});
|
|
402
406
|
exports.useSlider = useSlider.useSlider;
|
|
407
|
+
exports.Splitter = splitter.Splitter;
|
|
408
|
+
exports.SplitterPanel = splitterPanel.SplitterPanel;
|
|
409
|
+
exports.SplitterResizeTrigger = splitterResizeTrigger.SplitterResizeTrigger;
|
|
410
|
+
Object.defineProperty(exports, 'splitterAnatomy', {
|
|
411
|
+
enumerable: true,
|
|
412
|
+
get: () => splitter$1.anatomy
|
|
413
|
+
});
|
|
403
414
|
exports.TabContent = tabContent.TabContent;
|
|
404
415
|
exports.TabIndicator = tabIndicator.TabIndicator;
|
|
405
416
|
exports.TabList = tabList.TabList;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -150,6 +150,10 @@ export { SliderThumb } from './slider/slider-thumb.mjs';
|
|
|
150
150
|
export { SliderTrack } from './slider/slider-track.mjs';
|
|
151
151
|
export { anatomy as sliderAnatomy } from '@zag-js/slider';
|
|
152
152
|
export { useSlider } from './slider/use-slider.mjs';
|
|
153
|
+
export { Splitter } from './splitter/splitter.mjs';
|
|
154
|
+
export { SplitterPanel } from './splitter/splitter-panel.mjs';
|
|
155
|
+
export { SplitterResizeTrigger } from './splitter/splitter-resize-trigger.mjs';
|
|
156
|
+
export { anatomy as splitterAnatomy } from '@zag-js/splitter';
|
|
153
157
|
export { TabContent } from './tabs/tab-content.mjs';
|
|
154
158
|
export { TabIndicator } from './tabs/tab-indicator.mjs';
|
|
155
159
|
export { TabList } from './tabs/tab-list.mjs';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Splitter, type SplitterProps } from './splitter';
|
|
2
|
+
export { SplitterPanel, type SplitterPanelProps } from './splitter-panel';
|
|
3
|
+
export { SplitterResizeTrigger, type SplitterResizeTriggerProps } from './splitter-resize-trigger';
|
|
4
|
+
export { splitterAnatomy } from './splitter.anatomy';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const createContext = require('../create-context.cjs');
|
|
6
|
+
|
|
7
|
+
const [SplitterProvider, useSplitterContext] = createContext.createContext({
|
|
8
|
+
name: "SplitterContext",
|
|
9
|
+
hookName: "useSplitterContext",
|
|
10
|
+
providerName: "<SplitterProvider />"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports.SplitterProvider = SplitterProvider;
|
|
14
|
+
exports.useSplitterContext = useSplitterContext;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PanelId, PanelProps, ResizeTriggerProps } from '@zag-js/splitter/dist/splitter.types';
|
|
2
|
+
import type { Provider, HTMLAttributes } from 'react';
|
|
3
|
+
import type { UseSplitterReturn } from './use-splitter';
|
|
4
|
+
export type SplitterContext = UseSplitterReturn;
|
|
5
|
+
export declare const SplitterProvider: Provider<{
|
|
6
|
+
isFocused: boolean;
|
|
7
|
+
isDragging: boolean;
|
|
8
|
+
bounds: {
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
collapse(id: PanelId): void;
|
|
13
|
+
expand(id: PanelId): void;
|
|
14
|
+
toggle(id: PanelId): void;
|
|
15
|
+
setSize(id: PanelId, size: number): void;
|
|
16
|
+
rootProps: HTMLAttributes<HTMLElement>;
|
|
17
|
+
getPanelProps(props: PanelProps): HTMLAttributes<HTMLElement>;
|
|
18
|
+
getResizeTriggerState(props: ResizeTriggerProps): {
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
isFocused: boolean;
|
|
21
|
+
panelIds: string[];
|
|
22
|
+
min: number | undefined;
|
|
23
|
+
max: number | undefined;
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
getResizeTriggerProps(props: ResizeTriggerProps): HTMLAttributes<HTMLElement>;
|
|
27
|
+
}>, useSplitterContext: () => {
|
|
28
|
+
isFocused: boolean;
|
|
29
|
+
isDragging: boolean;
|
|
30
|
+
bounds: {
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
} | undefined;
|
|
34
|
+
collapse(id: PanelId): void;
|
|
35
|
+
expand(id: PanelId): void;
|
|
36
|
+
toggle(id: PanelId): void;
|
|
37
|
+
setSize(id: PanelId, size: number): void;
|
|
38
|
+
rootProps: HTMLAttributes<HTMLElement>;
|
|
39
|
+
getPanelProps(props: PanelProps): HTMLAttributes<HTMLElement>;
|
|
40
|
+
getResizeTriggerState(props: ResizeTriggerProps): {
|
|
41
|
+
isDisabled: boolean;
|
|
42
|
+
isFocused: boolean;
|
|
43
|
+
panelIds: string[];
|
|
44
|
+
min: number | undefined;
|
|
45
|
+
max: number | undefined;
|
|
46
|
+
value: number;
|
|
47
|
+
};
|
|
48
|
+
getResizeTriggerProps(props: ResizeTriggerProps): HTMLAttributes<HTMLElement>;
|
|
49
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext } from '../create-context.mjs';
|
|
2
|
+
|
|
3
|
+
const [SplitterProvider, useSplitterContext] = createContext({
|
|
4
|
+
name: "SplitterContext",
|
|
5
|
+
hookName: "useSplitterContext",
|
|
6
|
+
providerName: "<SplitterProvider />"
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { SplitterProvider, useSplitterContext };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
const react = require('@polymorphic-factory/react');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const createSplitProps = require('../create-split-props.cjs');
|
|
9
|
+
const factory = require('../factory.cjs');
|
|
10
|
+
const splitterContext = require('./splitter-context.cjs');
|
|
11
|
+
|
|
12
|
+
const SplitterPanel = react.forwardRef((props, ref) => {
|
|
13
|
+
const [splitterPanelProps, divProps] = createSplitProps.createSplitProps()(props, [
|
|
14
|
+
"id",
|
|
15
|
+
"snapSize"
|
|
16
|
+
]);
|
|
17
|
+
const { getPanelProps } = splitterContext.useSplitterContext();
|
|
18
|
+
const mergedProps = react$1.mergeProps(getPanelProps(splitterPanelProps), divProps);
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.SplitterPanel = SplitterPanel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentWithAs } from '@polymorphic-factory/react';
|
|
2
|
+
import type { connect } from '@zag-js/splitter';
|
|
3
|
+
import { HTMLArkProps } from '../factory';
|
|
4
|
+
import type { Assign } from '../types';
|
|
5
|
+
type GetPanelProps = Parameters<ReturnType<typeof connect>['getPanelProps']>[0];
|
|
6
|
+
export type SplitterPanelProps = Assign<HTMLArkProps<'div'>, GetPanelProps>;
|
|
7
|
+
export declare const SplitterPanel: ComponentWithAs<"div", SplitterPanelProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from '@polymorphic-factory/react';
|
|
3
|
+
import { mergeProps } from '@zag-js/react';
|
|
4
|
+
import { createSplitProps } from '../create-split-props.mjs';
|
|
5
|
+
import { ark } from '../factory.mjs';
|
|
6
|
+
import { useSplitterContext } from './splitter-context.mjs';
|
|
7
|
+
|
|
8
|
+
const SplitterPanel = forwardRef((props, ref) => {
|
|
9
|
+
const [splitterPanelProps, divProps] = createSplitProps()(props, [
|
|
10
|
+
"id",
|
|
11
|
+
"snapSize"
|
|
12
|
+
]);
|
|
13
|
+
const { getPanelProps } = useSplitterContext();
|
|
14
|
+
const mergedProps = mergeProps(getPanelProps(splitterPanelProps), divProps);
|
|
15
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { SplitterPanel };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const React = require('react');
|
|
6
|
+
const splitterContext = require('./splitter-context.cjs');
|
|
7
|
+
|
|
8
|
+
const SplitterResizeTrigger = (props) => {
|
|
9
|
+
const { children, ...tabProps } = props;
|
|
10
|
+
const { getResizeTriggerProps } = splitterContext.useSplitterContext();
|
|
11
|
+
const onlyChild = React.Children.only(children);
|
|
12
|
+
return React.cloneElement(onlyChild, getResizeTriggerProps(tabProps));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.SplitterResizeTrigger = SplitterResizeTrigger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { connect } from '@zag-js/splitter';
|
|
2
|
+
import type { JSXElementConstructor, ReactElement } from 'react';
|
|
3
|
+
import type { Assign } from '../types';
|
|
4
|
+
type SplitterContext = Parameters<ReturnType<typeof connect>['getResizeTriggerProps']>[0];
|
|
5
|
+
export type SplitterResizeTriggerProps = Assign<{
|
|
6
|
+
children: ReactElement;
|
|
7
|
+
}, SplitterContext>;
|
|
8
|
+
export declare const SplitterResizeTrigger: (props: SplitterResizeTriggerProps) => ReactElement<any, string | JSXElementConstructor<any>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Children, cloneElement } from 'react';
|
|
2
|
+
import { useSplitterContext } from './splitter-context.mjs';
|
|
3
|
+
|
|
4
|
+
const SplitterResizeTrigger = (props) => {
|
|
5
|
+
const { children, ...tabProps } = props;
|
|
6
|
+
const { getResizeTriggerProps } = useSplitterContext();
|
|
7
|
+
const onlyChild = Children.only(children);
|
|
8
|
+
return cloneElement(onlyChild, getResizeTriggerProps(tabProps));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { SplitterResizeTrigger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { anatomy as splitterAnatomy } from '@zag-js/splitter';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
const react = require('@polymorphic-factory/react');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const createSplitProps = require('../create-split-props.cjs');
|
|
9
|
+
const factory = require('../factory.cjs');
|
|
10
|
+
const splitterContext = require('./splitter-context.cjs');
|
|
11
|
+
const useSplitter = require('./use-splitter.cjs');
|
|
12
|
+
|
|
13
|
+
const Splitter = react.forwardRef((props, ref) => {
|
|
14
|
+
const [useSplitterProps, divProps] = createSplitProps.createSplitProps()(props, [
|
|
15
|
+
"dir",
|
|
16
|
+
"getRootNode",
|
|
17
|
+
"id",
|
|
18
|
+
"onResize",
|
|
19
|
+
"onResizeEnd",
|
|
20
|
+
"onResizeStart",
|
|
21
|
+
"orientation",
|
|
22
|
+
"size"
|
|
23
|
+
]);
|
|
24
|
+
const splitter = useSplitter.useSplitter(useSplitterProps);
|
|
25
|
+
const mergedProps = react$1.mergeProps(splitter.rootProps, divProps);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(splitterContext.SplitterProvider, { value: splitter, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }) });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.Splitter = Splitter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentWithAs } from '@polymorphic-factory/react';
|
|
2
|
+
import { HTMLArkProps } from '../factory';
|
|
3
|
+
import type { Assign } from '../types';
|
|
4
|
+
import { UseSplitterProps } from './use-splitter';
|
|
5
|
+
export type SplitterProps = Assign<HTMLArkProps<'div'>, UseSplitterProps>;
|
|
6
|
+
export declare const Splitter: ComponentWithAs<"div", SplitterProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from '@polymorphic-factory/react';
|
|
3
|
+
import { mergeProps } from '@zag-js/react';
|
|
4
|
+
import { createSplitProps } from '../create-split-props.mjs';
|
|
5
|
+
import { ark } from '../factory.mjs';
|
|
6
|
+
import { SplitterProvider } from './splitter-context.mjs';
|
|
7
|
+
import { useSplitter } from './use-splitter.mjs';
|
|
8
|
+
|
|
9
|
+
const Splitter = forwardRef((props, ref) => {
|
|
10
|
+
const [useSplitterProps, divProps] = createSplitProps()(props, [
|
|
11
|
+
"dir",
|
|
12
|
+
"getRootNode",
|
|
13
|
+
"id",
|
|
14
|
+
"onResize",
|
|
15
|
+
"onResizeEnd",
|
|
16
|
+
"onResizeStart",
|
|
17
|
+
"orientation",
|
|
18
|
+
"size"
|
|
19
|
+
]);
|
|
20
|
+
const splitter = useSplitter(useSplitterProps);
|
|
21
|
+
const mergedProps = mergeProps(splitter.rootProps, divProps);
|
|
22
|
+
return /* @__PURE__ */ jsx(SplitterProvider, { value: splitter, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { Splitter };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const react = require('@zag-js/react');
|
|
6
|
+
const splitter = require('@zag-js/splitter');
|
|
7
|
+
const React = require('react');
|
|
8
|
+
const environmentContext = require('../environment/environment-context.cjs');
|
|
9
|
+
|
|
10
|
+
const useSplitter = (props) => {
|
|
11
|
+
const getRootNode = environmentContext.useEnvironmentContext();
|
|
12
|
+
const context = {
|
|
13
|
+
id: React.useId(),
|
|
14
|
+
getRootNode,
|
|
15
|
+
...props
|
|
16
|
+
};
|
|
17
|
+
const [state, send] = react.useMachine(splitter.machine(context), { context });
|
|
18
|
+
return splitter.connect(state, send, react.normalizeProps);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.useSplitter = useSplitter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import type { PanelId, PanelProps, ResizeTriggerProps } from '@zag-js/splitter/dist/splitter.types';
|
|
3
|
+
import { Context } from '@zag-js/splitter';
|
|
4
|
+
import type { Optional } from '../types';
|
|
5
|
+
export type UseSplitterProps = Optional<Context, 'id'>;
|
|
6
|
+
export type UseSplitterReturn = ReturnType<typeof useSplitter>;
|
|
7
|
+
export declare const useSplitter: (props: UseSplitterProps) => {
|
|
8
|
+
isFocused: boolean;
|
|
9
|
+
isDragging: boolean;
|
|
10
|
+
bounds: {
|
|
11
|
+
min: number;
|
|
12
|
+
max: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
collapse(id: PanelId): void;
|
|
15
|
+
expand(id: PanelId): void;
|
|
16
|
+
toggle(id: PanelId): void;
|
|
17
|
+
setSize(id: PanelId, size: number): void;
|
|
18
|
+
rootProps: HTMLAttributes<HTMLElement>;
|
|
19
|
+
getPanelProps(props: PanelProps): HTMLAttributes<HTMLElement>;
|
|
20
|
+
getResizeTriggerState(props: ResizeTriggerProps): {
|
|
21
|
+
isDisabled: boolean;
|
|
22
|
+
isFocused: boolean;
|
|
23
|
+
panelIds: string[];
|
|
24
|
+
min: number | undefined;
|
|
25
|
+
max: number | undefined;
|
|
26
|
+
value: number;
|
|
27
|
+
};
|
|
28
|
+
getResizeTriggerProps(props: ResizeTriggerProps): HTMLAttributes<HTMLElement>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
2
|
+
import { machine, connect } from '@zag-js/splitter';
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { useEnvironmentContext } from '../environment/environment-context.mjs';
|
|
5
|
+
|
|
6
|
+
const useSplitter = (props) => {
|
|
7
|
+
const getRootNode = useEnvironmentContext();
|
|
8
|
+
const context = {
|
|
9
|
+
id: useId(),
|
|
10
|
+
getRootNode,
|
|
11
|
+
...props
|
|
12
|
+
};
|
|
13
|
+
const [state, send] = useMachine(machine(context), { context });
|
|
14
|
+
return connect(state, send, normalizeProps);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { useSplitter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark-ui/react",
|
|
3
|
-
"version": "0.0.0-rc-
|
|
3
|
+
"version": "0.0.0-rc-20230206155445",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/chakra-ui/ark#readme",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@zag-js/react": "0.3.8",
|
|
43
43
|
"@zag-js/select": "0.1.10",
|
|
44
44
|
"@zag-js/slider": "0.2.12",
|
|
45
|
+
"@zag-js/splitter": "0.2.11",
|
|
45
46
|
"@zag-js/tabs": "0.2.10",
|
|
46
47
|
"@zag-js/tags-input": "0.3.11",
|
|
47
48
|
"@zag-js/toast": "0.2.11",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"@testing-library/jest-dom": "5.16.5",
|
|
54
55
|
"@testing-library/react": "13.4.0",
|
|
55
56
|
"@testing-library/user-event": "14.4.3",
|
|
56
|
-
"@types/jsdom": "
|
|
57
|
+
"@types/jsdom": "21.1.0",
|
|
57
58
|
"@types/react": "18.0.27",
|
|
58
59
|
"@types/react-dom": "18.0.10",
|
|
59
60
|
"@types/testing-library__jest-dom": "5.14.5",
|