@sprawlify/react 0.0.3 → 0.0.4

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.
@@ -1,149 +1,5 @@
1
- import { t as __export } from "../../chunk-CbegLjfk.mjs";
2
- import { c as useEnvironmentContext, d as normalizeProps, f as useMachine, l as mergeProps, n as sprawlify, o as useLocaleContext } from "../../factory-B_Ye-J6y.mjs";
3
- import { t as createContext$1 } from "../../create-context-fSIoyq0R.mjs";
4
- import { forwardRef, useId, useRef } from "react";
5
- import { jsx } from "react/jsx-runtime";
6
- import * as collapsible from "@sprawlify/primitives/machines/collapsible";
7
- import { anatomy as collapsibleAnatomy } from "@sprawlify/primitives/machines/collapsible";
1
+ import "../../factory-BvslhNMh.mjs";
2
+ import "../../create-context-C0L0yhLQ.mjs";
3
+ import { a as CollapsibleRoot, c as CollapsibleIndicator, d as useCollapsibleContext, i as CollapsibleRootProvider, l as CollapsibleContext, n as collapsibleAnatomy, o as useCollapsible, r as CollapsibleTrigger, t as collapsible_exports, u as CollapsibleContent } from "../../collapsible-uHsTDy9p.mjs";
8
4
 
9
- //#region src/components/collapsible/use-collapsible-context.ts
10
- const [CollapsibleProvider, useCollapsibleContext] = createContext$1({
11
- name: "CollapsibleContext",
12
- hookName: "useCollapsibleContext",
13
- providerName: "<CollapsibleProvider />"
14
- });
15
-
16
- //#endregion
17
- //#region src/components/collapsible/collapsible-content.tsx
18
- const CollapsibleContent = forwardRef((props, ref) => {
19
- const collapsible$1 = useCollapsibleContext();
20
- if (collapsible$1.isUnmounted) return null;
21
- const mergedProps = mergeProps(collapsible$1.getContentProps(), props);
22
- return /* @__PURE__ */ jsx(sprawlify.div, {
23
- ...mergedProps,
24
- ref
25
- });
26
- });
27
- CollapsibleContent.displayName = "CollapsibleContent";
28
-
29
- //#endregion
30
- //#region src/components/collapsible/collapsible-context.tsx
31
- const CollapsibleContext = (props) => props.children(useCollapsibleContext());
32
-
33
- //#endregion
34
- //#region src/components/collapsible/collapsible-indicator.tsx
35
- const CollapsibleIndicator = forwardRef((props, ref) => {
36
- const mergedProps = mergeProps(useCollapsibleContext().getIndicatorProps(), props);
37
- return /* @__PURE__ */ jsx(sprawlify.div, {
38
- ...mergedProps,
39
- ref
40
- });
41
- });
42
- CollapsibleIndicator.displayName = "CollapsibleIndicator";
43
-
44
- //#endregion
45
- //#region src/utils/create-split-props.ts
46
- const createSplitProps = () => (props, keys) => keys.reduce((previousValue, currentValue) => {
47
- const [target, source] = previousValue;
48
- const key = currentValue;
49
- if (source[key] !== void 0) target[key] = source[key];
50
- delete source[key];
51
- return [target, source];
52
- }, [{}, { ...props }]);
53
-
54
- //#endregion
55
- //#region src/components/collapsible/split-collapsible-props.ts
56
- const splitCollapsibleProps = (props) => createSplitProps()(props, [
57
- "collapsedHeight",
58
- "collapsedWidth",
59
- "defaultOpen",
60
- "disabled",
61
- "id",
62
- "ids",
63
- "lazyMount",
64
- "onExitComplete",
65
- "onOpenChange",
66
- "open",
67
- "unmountOnExit"
68
- ]);
69
-
70
- //#endregion
71
- //#region src/components/collapsible/use-collapsible.ts
72
- const useCollapsible = (props = {}) => {
73
- const { lazyMount, unmountOnExit, ...collapsibleProps } = props;
74
- const id = useId();
75
- const wasVisible = useRef(false);
76
- const { dir } = useLocaleContext();
77
- const { getRootNode } = useEnvironmentContext();
78
- const machineProps = {
79
- id,
80
- dir,
81
- getRootNode,
82
- ...collapsibleProps
83
- };
84
- const service = useMachine(collapsible.machine, machineProps);
85
- const api = collapsible.connect(service, normalizeProps);
86
- if (api.visible) wasVisible.current = true;
87
- const isUnmounted = !api.visible && !wasVisible.current && lazyMount || unmountOnExit && !api.visible && wasVisible.current;
88
- return {
89
- ...api,
90
- isUnmounted
91
- };
92
- };
93
-
94
- //#endregion
95
- //#region src/components/collapsible/collapsible-root.tsx
96
- const CollapsibleRoot = forwardRef((props, ref) => {
97
- const [useCollapsibleProps, localProps] = splitCollapsibleProps(props);
98
- const collapsible$1 = useCollapsible(useCollapsibleProps);
99
- const mergedProps = mergeProps(collapsible$1.getRootProps(), localProps);
100
- return /* @__PURE__ */ jsx(CollapsibleProvider, {
101
- value: collapsible$1,
102
- children: /* @__PURE__ */ jsx(sprawlify.div, {
103
- ...mergedProps,
104
- ref
105
- })
106
- });
107
- });
108
- CollapsibleRoot.displayName = "CollapsibleRoot";
109
-
110
- //#endregion
111
- //#region src/components/collapsible/collapsible-root-provider.tsx
112
- const splitRootProviderProps = createSplitProps();
113
- const CollapsibleRootProvider = forwardRef((props, ref) => {
114
- const [{ value: collapsible$1 }, localProps] = splitRootProviderProps(props, ["value"]);
115
- const mergedProps = mergeProps(collapsible$1.getRootProps(), localProps);
116
- return /* @__PURE__ */ jsx(CollapsibleProvider, {
117
- value: collapsible$1,
118
- children: /* @__PURE__ */ jsx(sprawlify.div, {
119
- ...mergedProps,
120
- ref
121
- })
122
- });
123
- });
124
- CollapsibleRootProvider.displayName = "CollapsibleRootProvider";
125
-
126
- //#endregion
127
- //#region src/components/collapsible/collapsible-trigger.tsx
128
- const CollapsibleTrigger = forwardRef((props, ref) => {
129
- const mergedProps = mergeProps(useCollapsibleContext().getTriggerProps(), props);
130
- return /* @__PURE__ */ jsx(sprawlify.button, {
131
- ...mergedProps,
132
- ref
133
- });
134
- });
135
- CollapsibleTrigger.displayName = "CollapsibleTrigger";
136
-
137
- //#endregion
138
- //#region src/components/collapsible/collapsible.ts
139
- var collapsible_exports = /* @__PURE__ */ __export({
140
- Content: () => CollapsibleContent,
141
- Context: () => CollapsibleContext,
142
- Indicator: () => CollapsibleIndicator,
143
- Root: () => CollapsibleRoot,
144
- RootProvider: () => CollapsibleRootProvider,
145
- Trigger: () => CollapsibleTrigger
146
- });
147
-
148
- //#endregion
149
5
  export { collapsible_exports as Collapsible, CollapsibleContent, CollapsibleContext, CollapsibleIndicator, CollapsibleRoot, CollapsibleRootProvider, CollapsibleTrigger, collapsibleAnatomy, useCollapsible, useCollapsibleContext };
@@ -1,18 +1,6 @@
1
1
  import React, { CSSProperties, ComponentPropsWithoutRef, HTMLAttributes, JSX } from "react";
2
2
  import * as _sprawlify_primitives_types0 from "@sprawlify/primitives/types";
3
3
 
4
- //#region src/components/factory.d.ts
5
- interface PolymorphicProps {
6
- asChild?: boolean | undefined;
7
- }
8
- type JsxElements = { [E in keyof JSX.IntrinsicElements]: SprawlifyForwardRefComponent<E> };
9
- type SprawlifyForwardRefComponent<E$1 extends React.ElementType> = React.ForwardRefExoticComponent<SprawlifyPropsWithRef<E$1>>;
10
- type SprawlifyPropsWithRef<E$1 extends React.ElementType> = React.ComponentPropsWithRef<E$1> & PolymorphicProps;
11
- type HTMLProps<T extends keyof JSX.IntrinsicElements> = ComponentPropsWithoutRef<T>;
12
- type HTMLSprawlifyProps<T extends keyof JSX.IntrinsicElements> = HTMLProps<T> & PolymorphicProps;
13
- declare const jsxFactory: () => JsxElements;
14
- declare const sprawlify: JsxElements;
15
- //#endregion
16
4
  //#region src/core/normalize-props.d.ts
17
5
  type WithoutRef<T> = Omit<T, "ref">;
18
6
  type ElementsWithoutRef = { [K in keyof JSX.IntrinsicElements]: WithoutRef<JSX.IntrinsicElements[K]> };
@@ -26,4 +14,16 @@ declare const normalizeProps: _sprawlify_primitives_types0.NormalizeProps<PropTy
26
14
  type Assign<T, U> = Omit<T, keyof U> & U;
27
15
  type Optional<T, K$1 extends keyof T> = Pick<Partial<T>, K$1> & Omit<T, K$1>;
28
16
  //#endregion
29
- export { HTMLProps as a, jsxFactory as c, normalizeProps as i, sprawlify as l, Optional as n, HTMLSprawlifyProps as o, PropTypes as r, PolymorphicProps as s, Assign as t };
17
+ //#region src/components/factory.d.ts
18
+ interface PolymorphicProps {
19
+ asChild?: boolean | undefined;
20
+ }
21
+ type JsxElements = { [E in keyof JSX.IntrinsicElements]: SprawlifyForwardRefComponent<E> };
22
+ type SprawlifyForwardRefComponent<E$1 extends React.ElementType> = React.ForwardRefExoticComponent<SprawlifyPropsWithRef<E$1>>;
23
+ type SprawlifyPropsWithRef<E$1 extends React.ElementType> = React.ComponentPropsWithRef<E$1> & PolymorphicProps;
24
+ type HTMLProps<T extends keyof JSX.IntrinsicElements> = ComponentPropsWithoutRef<T>;
25
+ type HTMLSprawlifyProps<T extends keyof JSX.IntrinsicElements> = HTMLProps<T> & PolymorphicProps;
26
+ declare const jsxFactory: () => JsxElements;
27
+ declare const sprawlify: JsxElements;
28
+ //#endregion
29
+ export { sprawlify as a, PropTypes as c, jsxFactory as i, normalizeProps as l, HTMLSprawlifyProps as n, Assign as o, PolymorphicProps as r, Optional as s, HTMLProps as t };
@@ -2,18 +2,6 @@ import { Machine, MachineSchema, Service } from "@sprawlify/primitives/core";
2
2
  import React, { CSSProperties, ComponentPropsWithoutRef, HTMLAttributes, JSX, PropsWithChildren, RefObject } from "react";
3
3
  import * as _sprawlify_primitives_types0 from "@sprawlify/primitives/types";
4
4
 
5
- //#region src/components/factory.d.ts
6
- interface PolymorphicProps {
7
- asChild?: boolean | undefined;
8
- }
9
- type JsxElements = { [E in keyof JSX.IntrinsicElements]: SprawlifyForwardRefComponent<E> };
10
- type SprawlifyForwardRefComponent<E$1 extends React.ElementType> = React.ForwardRefExoticComponent<SprawlifyPropsWithRef<E$1>>;
11
- type SprawlifyPropsWithRef<E$1 extends React.ElementType> = React.ComponentPropsWithRef<E$1> & PolymorphicProps;
12
- type HTMLProps<T extends keyof JSX.IntrinsicElements> = ComponentPropsWithoutRef<T>;
13
- type HTMLSprawlifyProps<T extends keyof JSX.IntrinsicElements> = HTMLProps<T> & PolymorphicProps;
14
- declare const jsxFactory: () => JsxElements;
15
- declare const sprawlify: JsxElements;
16
- //#endregion
17
5
  //#region src/core/machine.d.ts
18
6
  declare function useMachine<T extends MachineSchema>(machine: Machine<T>, userProps?: Partial<T["props"]>): Service<T>;
19
7
  //#endregion
@@ -38,4 +26,16 @@ declare const Portal: (props: PropsWithChildren<PortalProps>) => JSX.Element;
38
26
  type Assign<T, U> = Omit<T, keyof U> & U;
39
27
  type Optional<T, K$1 extends keyof T> = Pick<Partial<T>, K$1> & Omit<T, K$1>;
40
28
  //#endregion
41
- export { PropTypes as a, HTMLProps as c, jsxFactory as d, sprawlify as f, PortalProps as i, HTMLSprawlifyProps as l, Optional as n, normalizeProps as o, Portal as r, useMachine as s, Assign as t, PolymorphicProps as u };
29
+ //#region src/components/factory.d.ts
30
+ interface PolymorphicProps {
31
+ asChild?: boolean | undefined;
32
+ }
33
+ type JsxElements = { [E in keyof JSX.IntrinsicElements]: SprawlifyForwardRefComponent<E> };
34
+ type SprawlifyForwardRefComponent<E$1 extends React.ElementType> = React.ForwardRefExoticComponent<SprawlifyPropsWithRef<E$1>>;
35
+ type SprawlifyPropsWithRef<E$1 extends React.ElementType> = React.ComponentPropsWithRef<E$1> & PolymorphicProps;
36
+ type HTMLProps<T extends keyof JSX.IntrinsicElements> = ComponentPropsWithoutRef<T>;
37
+ type HTMLSprawlifyProps<T extends keyof JSX.IntrinsicElements> = HTMLProps<T> & PolymorphicProps;
38
+ declare const jsxFactory: () => JsxElements;
39
+ declare const sprawlify: JsxElements;
40
+ //#endregion
41
+ export { sprawlify as a, Portal as c, normalizeProps as d, useMachine as f, jsxFactory as i, PortalProps as l, HTMLSprawlifyProps as n, Assign as o, PolymorphicProps as r, Optional as s, HTMLProps as t, PropTypes as u };
@@ -1,4 +1,4 @@
1
- import { t as createContext$1 } from "./create-context-fSIoyq0R.mjs";
1
+ import { t as createContext$1 } from "./create-context-C0L0yhLQ.mjs";
2
2
  import { INIT_STATE, MachineStatus, createScope, mergeProps, mergeProps as mergeProps$1 } from "@sprawlify/primitives/core";
3
3
  import { compact, ensure, identity, isFunction, isString, toArray, warn } from "@sprawlify/primitives/utils";
4
4
  import * as React$1 from "react";
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as HTMLProps, c as jsxFactory, i as normalizeProps, l as sprawlify, n as Optional, o as HTMLSprawlifyProps, r as PropTypes, s as PolymorphicProps, t as Assign } from "./types-B_h5HVp2.cjs";
2
- import { n as createContext } from "./index-BbLlW5Mk.cjs";
1
+ import { a as sprawlify, c as PropTypes, i as jsxFactory, l as normalizeProps, n as HTMLSprawlifyProps, o as Assign, r as PolymorphicProps, s as Optional, t as HTMLProps } from "./factory-B3Fr36su.cjs";
2
+ import { n as createContext } from "./index-Bk-VrHD9.cjs";
3
3
  import { JSX, PropsWithChildren, ReactNode, RefObject } from "react";
4
4
  import { Machine, MachineSchema, Service } from "@sprawlify/primitives/core";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as PropTypes, c as HTMLProps, d as jsxFactory, f as sprawlify, i as PortalProps, l as HTMLSprawlifyProps, n as Optional, o as normalizeProps, r as Portal, s as useMachine, t as Assign, u as PolymorphicProps } from "./types-CwELsIN6.mjs";
2
- import { n as createContext } from "./index-CgR7RZbW.mjs";
1
+ import { a as sprawlify, c as Portal, d as normalizeProps, f as useMachine, i as jsxFactory, l as PortalProps, n as HTMLSprawlifyProps, o as Assign, r as PolymorphicProps, s as Optional, t as HTMLProps, u as PropTypes } from "./factory-BV5hc6hz.mjs";
2
+ import { n as createContext } from "./index-lntzaDM3.mjs";
3
3
  import { PropsWithChildren, ReactNode } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
  import { FilterOptions, FilterReturn, Locale } from "@sprawlify/primitives/i18n-utils";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as LocaleProvider, c as useEnvironmentContext, d as normalizeProps, f as useMachine, i as useCollator, l as mergeProps, n as sprawlify, o as useLocaleContext, r as useFilter, s as EnvironmentProvider, t as jsxFactory, u as Portal } from "./factory-B_Ye-J6y.mjs";
2
- import { t as createContext } from "./create-context-fSIoyq0R.mjs";
3
- import "./utils-CM4cOr5z.mjs";
1
+ import { a as LocaleProvider, c as useEnvironmentContext, d as normalizeProps, f as useMachine, i as useCollator, l as mergeProps, n as sprawlify, o as useLocaleContext, r as useFilter, s as EnvironmentProvider, t as jsxFactory, u as Portal } from "./factory-BvslhNMh.mjs";
2
+ import { t as createContext } from "./create-context-C0L0yhLQ.mjs";
3
+ import "./utils-Q0vUJnHt.mjs";
4
4
 
5
5
  export { EnvironmentProvider, LocaleProvider, Portal, createContext, jsxFactory, normalizeProps, sprawlify, useCollator, useEnvironmentContext, useFilter, useLocaleContext, useMachine };
@@ -0,0 +1,9 @@
1
+ import "react";
2
+
3
+ //#region src/utils/render-strategy.d.ts
4
+ interface RenderStrategyProps {
5
+ lazyMount?: boolean | undefined;
6
+ unmountOnExit?: boolean | undefined;
7
+ }
8
+ //#endregion
9
+ export { RenderStrategyProps as t };
@@ -0,0 +1,8 @@
1
+ //#endregion
2
+ //#region src/utils/render-strategy.d.ts
3
+ interface RenderStrategyProps {
4
+ lazyMount?: boolean | undefined;
5
+ unmountOnExit?: boolean | undefined;
6
+ }
7
+ //#endregion
8
+ export { __export as n, RenderStrategyProps as t };
@@ -1,2 +1,2 @@
1
- import { n as createContext, t as mergeProps } from "../index-BbLlW5Mk.cjs";
1
+ import { n as createContext, t as mergeProps } from "../index-Bk-VrHD9.cjs";
2
2
  export { createContext, mergeProps };
@@ -1,2 +1,2 @@
1
- import { n as createContext, t as mergeProps } from "../index-CgR7RZbW.mjs";
1
+ import { n as createContext, t as mergeProps } from "../index-lntzaDM3.mjs";
2
2
  export { createContext, mergeProps };
@@ -1,4 +1,4 @@
1
- import { t as createContext } from "../create-context-fSIoyq0R.mjs";
2
- import { t as mergeProps } from "../utils-CM4cOr5z.mjs";
1
+ import { t as createContext } from "../create-context-C0L0yhLQ.mjs";
2
+ import { t as mergeProps } from "../utils-Q0vUJnHt.mjs";
3
3
 
4
4
  export { createContext, mergeProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprawlify/react",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "React wrapper for primitives.",
6
6
  "author": "sprawlify <npm@sprawlify.com>",
@@ -18,6 +18,16 @@
18
18
  "default": "./dist/index.cjs"
19
19
  }
20
20
  },
21
+ "./accordion": {
22
+ "import": {
23
+ "types": "./dist/components/accordion/index.d.mts",
24
+ "default": "./dist/components/accordion/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./dist/components/accordion/index.d.cts",
28
+ "default": "./dist/components/accordion/index.cjs"
29
+ }
30
+ },
21
31
  "./collapsible": {
22
32
  "import": {
23
33
  "types": "./dist/components/collapsible/index.d.mts",
@@ -36,7 +46,7 @@
36
46
  "access": "public"
37
47
  },
38
48
  "dependencies": {
39
- "@sprawlify/primitives": "0.0.3"
49
+ "@sprawlify/primitives": "0.0.4"
40
50
  },
41
51
  "peerDependencies": {
42
52
  "react": ">=19.0.0",
File without changes
File without changes