@zayne-labs/ui-react 0.4.2 → 0.5.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.
@@ -0,0 +1,135 @@
1
+ import * as React2 from 'react';
2
+ import { useState, Component, Suspense, use } from 'react';
3
+ import { createCustomContext, useCallbackRef } from '@zayne-labs/toolkit-react';
4
+ import { isFunction } from '@zayne-labs/toolkit-type-helpers';
5
+
6
+ // src/components/common/await/await.tsx
7
+ var [ErrorBoundaryContextProvider, useErrorBoundaryContext] = createCustomContext({
8
+ hookName: "useErrorBoundaryContext",
9
+ name: "ErrorBoundaryContext",
10
+ providerName: "ErrorBoundaryContextProvider"
11
+ });
12
+ var useErrorBoundary = () => {
13
+ const { resetErrorBoundary } = useErrorBoundaryContext();
14
+ const [state, setState] = useState({
15
+ error: null,
16
+ hasError: false
17
+ });
18
+ if (state.hasError) {
19
+ throw state.error;
20
+ }
21
+ const resetBoundary = useCallbackRef(() => {
22
+ resetErrorBoundary();
23
+ setState({
24
+ error: null,
25
+ hasError: false
26
+ });
27
+ });
28
+ const showBoundary = useCallbackRef((error) => {
29
+ setState({
30
+ error,
31
+ hasError: true
32
+ });
33
+ });
34
+ return { resetBoundary, showBoundary };
35
+ };
36
+ var initialState = {
37
+ error: null,
38
+ hasError: false
39
+ };
40
+ var hasArrayChanged = (a = [], b = []) => {
41
+ return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
42
+ };
43
+ var ErrorBoundary = class extends Component {
44
+ constructor(props) {
45
+ super(props);
46
+ this.state = initialState;
47
+ }
48
+ static getDerivedStateFromError(error) {
49
+ return { error, hasError: true };
50
+ }
51
+ componentDidCatch(error, info) {
52
+ this.props.onError?.(error, info);
53
+ }
54
+ componentDidUpdate(prevProps, prevState) {
55
+ const { hasError } = this.state;
56
+ const { resetKeys } = this.props;
57
+ if (hasError && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
58
+ this.props.onReset?.({
59
+ next: resetKeys,
60
+ prev: prevProps.resetKeys,
61
+ reason: "keys"
62
+ });
63
+ this.setState(initialState);
64
+ }
65
+ }
66
+ render() {
67
+ const { children, fallback } = this.props;
68
+ const { error, hasError } = this.state;
69
+ let childToRender = children;
70
+ if (hasError) {
71
+ switch (true) {
72
+ case isFunction(fallback): {
73
+ const props = { error, resetErrorBoundary: this.#resetErrorBoundary };
74
+ childToRender = fallback(props);
75
+ break;
76
+ }
77
+ case fallback !== void 0: {
78
+ childToRender = fallback;
79
+ break;
80
+ }
81
+ default: {
82
+ console.error("error-boundary requires a fallback prop");
83
+ throw error;
84
+ }
85
+ }
86
+ }
87
+ return /* @__PURE__ */ React2.createElement(
88
+ ErrorBoundaryContextProvider,
89
+ {
90
+ value: { error, hasError, resetErrorBoundary: this.#resetErrorBoundary }
91
+ },
92
+ childToRender
93
+ );
94
+ }
95
+ #resetErrorBoundary = (...args) => {
96
+ const { error } = this.state;
97
+ if (error !== null) {
98
+ this.props.onReset?.({
99
+ args,
100
+ reason: "imperative-api"
101
+ });
102
+ this.setState(initialState);
103
+ }
104
+ };
105
+ };
106
+
107
+ // src/components/common/await/await.tsx
108
+ function Await(props) {
109
+ const { errorFallback, fallback, ...restOfProps } = props;
110
+ const awaitedInnerElement = /* @__PURE__ */ React2.createElement(AwaitInner, { ...restOfProps });
111
+ switch (true) {
112
+ // eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- || makes more sense here
113
+ case (errorFallback && fallback || errorFallback): {
114
+ return /* @__PURE__ */ React2.createElement(ErrorBoundary, { fallback: errorFallback }, /* @__PURE__ */ React2.createElement(Suspense, { fallback }, awaitedInnerElement), ";");
115
+ }
116
+ case fallback: {
117
+ return /* @__PURE__ */ React2.createElement(Suspense, { fallback }, awaitedInnerElement);
118
+ }
119
+ default: {
120
+ return awaitedInnerElement;
121
+ }
122
+ }
123
+ }
124
+ function AwaitInner(props) {
125
+ const { children, promise, render } = props;
126
+ const result = use(promise);
127
+ if (typeof children === "function") {
128
+ return children(result);
129
+ }
130
+ return render(result);
131
+ }
132
+
133
+ export { Await, ErrorBoundary, useErrorBoundary, useErrorBoundaryContext };
134
+ //# sourceMappingURL=chunk-6BUR5OWX.js.map
135
+ //# sourceMappingURL=chunk-6BUR5OWX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/common/error-boundary/error-boundary-context.ts","../../src/components/common/error-boundary/useErrorBoundary.ts","../../src/components/common/error-boundary/error-boundary.tsx","../../src/components/common/await/await.tsx"],"names":["React"],"mappings":";;;;;;AAQO,IAAM,CAAC,4BAAA,EAA8B,uBAAuB,CAAA,GAClE,mBAA8C,CAAA;AAAA,EAC7C,QAAU,EAAA,yBAAA;AAAA,EACV,IAAM,EAAA,sBAAA;AAAA,EACN,YAAc,EAAA;AACf,CAAC;ACCK,IAAM,mBAAmB,MAA4B;AAC3D,EAAM,MAAA,EAAE,kBAAmB,EAAA,GAAI,uBAAwB,EAAA;AAEvD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAwC,CAAA;AAAA,IACjE,KAAO,EAAA,IAAA;AAAA,IACP,QAAU,EAAA;AAAA,GACV,CAAA;AAED,EAAA,IAAI,MAAM,QAAU,EAAA;AACnB,IAAA,MAAM,KAAM,CAAA,KAAA;AAAA;AAGb,EAAM,MAAA,aAAA,GAAgB,eAAe,MAAM;AAC1C,IAAmB,kBAAA,EAAA;AAEnB,IAAS,QAAA,CAAA;AAAA,MACR,KAAO,EAAA,IAAA;AAAA,MACP,QAAU,EAAA;AAAA,KACV,CAAA;AAAA,GACD,CAAA;AAED,EAAM,MAAA,YAAA,GAAe,cAAe,CAAA,CAAC,KAAkB,KAAA;AACtD,IAAS,QAAA,CAAA;AAAA,MACR,KAAA;AAAA,MACA,QAAU,EAAA;AAAA,KACV,CAAA;AAAA,GACD,CAAA;AAED,EAAO,OAAA,EAAE,eAAe,YAAa,EAAA;AACtC;AC3BA,IAAM,YAAmC,GAAA;AAAA,EACxC,KAAO,EAA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AA,MAAA,CAAA,aAAA,CAAC,UAAY,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AAEzD,EAAA,QAAQ,IAAM;AAAA;AAAA,IAEb,MAAM,aAAiB,IAAA,QAAA,IAAa,aAAe,GAAA;AAClD,MACC,uBAAA,MAAA,CAAA,aAAA,CAAC,iBAAc,QAAU,EAAA,aAAA,EAAA,uCACvB,QAAS,EAAA,EAAA,QAAA,EAAA,EAAqB,mBAAoB,CAAA,EAAW,GAC/D,CAAA;AAAA;AAEF,IAEA,KAAK,QAAU,EAAA;AACd,MAAO,uBAAA,MAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,QAAA,EAAA,EAAqB,mBAAoB,CAAA;AAAA;AAC3D,IAEA,SAAS;AACR,MAAO,OAAA,mBAAA;AAAA;AACR;AAEF;AAEA,SAAS,WAAmB,KAAgC,EAAA;AAC3D,EAAA,MAAM,EAAE,QAAA,EAAU,OAAS,EAAA,MAAA,EAAW,GAAA,KAAA;AAEtC,EAAM,MAAA,MAAA,GAAS,IAAI,OAAO,CAAA;AAE1B,EAAI,IAAA,OAAO,aAAa,UAAY,EAAA;AACnC,IAAA,OAAO,SAAS,MAAM,CAAA;AAAA;AAGvB,EAAA,OAAO,OAAO,MAAM,CAAA;AACrB","file":"chunk-6BUR5OWX.js","sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type ErrorBoundaryContextType = {\n\terror: unknown;\n\thasError: boolean;\n\tresetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const [ErrorBoundaryContextProvider, useErrorBoundaryContext] =\n\tcreateCustomContext<ErrorBoundaryContextType>({\n\t\thookName: \"useErrorBoundaryContext\",\n\t\tname: \"ErrorBoundaryContext\",\n\t\tproviderName: \"ErrorBoundaryContextProvider\",\n\t});\n","import { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useErrorBoundaryContext } from \"./error-boundary-context\";\n\ntype UseErrorBoundaryState<TError extends Error> =\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t }\n\t| {\n\t\t\terror: TError;\n\t\t\thasError: true;\n\t };\n\nexport const useErrorBoundary = <TError extends Error>() => {\n\tconst { resetErrorBoundary } = useErrorBoundaryContext();\n\n\tconst [state, setState] = useState<UseErrorBoundaryState<TError>>({\n\t\terror: null,\n\t\thasError: false,\n\t});\n\n\tif (state.hasError) {\n\t\tthrow state.error;\n\t}\n\n\tconst resetBoundary = useCallbackRef(() => {\n\t\tresetErrorBoundary();\n\n\t\tsetState({\n\t\t\terror: null,\n\t\t\thasError: false,\n\t\t});\n\t});\n\n\tconst showBoundary = useCallbackRef((error: TError) => {\n\t\tsetState({\n\t\t\terror,\n\t\t\thasError: true,\n\t\t});\n\t});\n\n\treturn { resetBoundary, showBoundary };\n};\n","import { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Component } from \"react\";\nimport { ErrorBoundaryContextProvider } from \"./error-boundary-context\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"./types\";\n\ntype ErrorBoundaryState =\n\t| {\n\t\t\terror: Error;\n\t\t\thasError: true;\n\t }\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t };\n\nconst initialState: ErrorBoundaryState = {\n\terror: null,\n\thasError: false,\n};\n\nconst hasArrayChanged = (a: unknown[] = [], b: unknown[] = []) => {\n\treturn a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));\n};\n\n/**\n * Copied from react-error-boundary package\n * @see https://github.com/bvaughn/react-error-boundary\n */\n\nclass ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\n\t\tthis.state = initialState;\n\t}\n\n\tstatic getDerivedStateFromError(error: Error) {\n\t\treturn { error, hasError: true };\n\t}\n\n\toverride componentDidCatch(error: Error, info: React.ErrorInfo) {\n\t\tthis.props.onError?.(error, info);\n\t}\n\n\toverride componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState) {\n\t\tconst { hasError } = this.state;\n\t\tconst { resetKeys } = this.props;\n\n\t\t// There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n\t\t// we'd end up resetting the error boundary immediately.\n\t\t// This would likely trigger a second error to be thrown.\n\t\t// So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n\t\tif (hasError && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\tnext: resetKeys,\n\t\t\t\tprev: prevProps.resetKeys,\n\t\t\t\treason: \"keys\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t}\n\n\toverride render() {\n\t\tconst { children, fallback } = this.props;\n\t\tconst { error, hasError } = this.state;\n\n\t\tlet childToRender = children;\n\n\t\tif (hasError) {\n\t\t\tswitch (true) {\n\t\t\t\tcase isFunction(fallback): {\n\t\t\t\t\tconst props: FallbackProps = { error, resetErrorBoundary: this.#resetErrorBoundary };\n\n\t\t\t\t\tchildToRender = fallback(props);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase fallback !== undefined: {\n\t\t\t\t\tchildToRender = fallback;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconsole.error(\"error-boundary requires a fallback prop\");\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn (\n\t\t\t<ErrorBoundaryContextProvider\n\t\t\t\tvalue={{ error, hasError, resetErrorBoundary: this.#resetErrorBoundary }}\n\t\t\t>\n\t\t\t\t{childToRender}\n\t\t\t</ErrorBoundaryContextProvider>\n\t\t);\n\t}\n\n\t#resetErrorBoundary = (...args: unknown[]) => {\n\t\tconst { error } = this.state;\n\n\t\tif (error !== null) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\targs,\n\t\t\t\treason: \"imperative-api\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t};\n}\n\nexport { ErrorBoundary };\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { Suspense, use } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\ntype RenderPropFn<Tvalue> = (result: Tvalue) => React.ReactNode;\n\nexport type AwaitInnerProps<Tvalue> = DiscriminatedRenderProps<RenderPropFn<Tvalue>> & {\n\tpromise: Promise<Tvalue>;\n};\n\ntype AwaitProps<Tvalue> = AwaitInnerProps<Tvalue> & {\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function Await<Tvalue>(props: AwaitProps<Tvalue>) {\n\tconst { errorFallback, fallback, ...restOfProps } = props;\n\n\tconst awaitedInnerElement = <AwaitInner {...restOfProps} />;\n\n\tswitch (true) {\n\t\t// eslint-disable-next-line ts-eslint/prefer-nullish-coalescing -- || makes more sense here\n\t\tcase (errorFallback && fallback) || errorFallback: {\n\t\t\treturn (\n\t\t\t\t<ErrorBoundary fallback={errorFallback}>\n\t\t\t\t\t<Suspense fallback={fallback}>{awaitedInnerElement}</Suspense>;\n\t\t\t\t</ErrorBoundary>\n\t\t\t);\n\t\t}\n\n\t\tcase fallback: {\n\t\t\treturn <Suspense fallback={fallback}>{awaitedInnerElement}</Suspense>;\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn awaitedInnerElement;\n\t\t}\n\t}\n}\n\nfunction AwaitInner<TValue>(props: AwaitInnerProps<TValue>) {\n\tconst { children, promise, render } = props;\n\n\tconst result = use(promise);\n\n\tif (typeof children === \"function\") {\n\t\treturn children(result);\n\t}\n\n\treturn render(result);\n}\n"]}
@@ -1,8 +1,77 @@
1
+ import * as react from 'react';
2
+ import { Component } from 'react';
3
+ import { DiscriminatedRenderProps } from '@zayne-labs/toolkit-react/utils';
1
4
  export { ForBase, ForList, ForRenderProps, getElementList } from './for/index.js';
2
5
  export { Show, ShowContent, ShowFallback, ShowRoot } from './show/index.js';
3
6
  export { Slot, Slottable } from './slot/index.js';
4
7
  export { Switch, SwitchDefault, SwitchMatch, SwitchRoot } from './switch/index.js';
5
8
  export { Teleport } from './teleport/index.js';
6
- import 'react';
7
- import '@zayne-labs/toolkit-react/utils';
8
9
  import '@zayne-labs/toolkit-type-helpers';
10
+
11
+ type ErrorBoundaryContextType = {
12
+ error: unknown;
13
+ hasError: boolean;
14
+ resetErrorBoundary: (...args: unknown[]) => void;
15
+ };
16
+ declare const useErrorBoundaryContext: () => ErrorBoundaryContextType;
17
+
18
+ declare const useErrorBoundary: <TError extends Error>() => {
19
+ resetBoundary: () => void;
20
+ showBoundary: (error: TError) => void;
21
+ };
22
+
23
+ type FallbackProps = {
24
+ error: unknown;
25
+ resetErrorBoundary: (...args: unknown[]) => void;
26
+ };
27
+ type ErrorBoundaryProps = {
28
+ children: React.ReactNode;
29
+ fallback: React.ReactNode | ((props: FallbackProps) => React.ReactNode);
30
+ onError?: (error: Error, info: React.ErrorInfo & {
31
+ ownerStack?: string;
32
+ }) => void;
33
+ onReset?: (details: {
34
+ args: unknown[];
35
+ reason: "imperative-api";
36
+ } | {
37
+ next: unknown[] | undefined;
38
+ prev: unknown[] | undefined;
39
+ reason: "keys";
40
+ }) => void;
41
+ resetKeys?: unknown[];
42
+ };
43
+
44
+ type ErrorBoundaryState = {
45
+ error: Error;
46
+ hasError: true;
47
+ } | {
48
+ error: null;
49
+ hasError: false;
50
+ };
51
+ /**
52
+ * Copied from react-error-boundary package
53
+ * @see https://github.com/bvaughn/react-error-boundary
54
+ */
55
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
56
+ #private;
57
+ constructor(props: ErrorBoundaryProps);
58
+ static getDerivedStateFromError(error: Error): {
59
+ error: Error;
60
+ hasError: boolean;
61
+ };
62
+ componentDidCatch(error: Error, info: react.ErrorInfo): void;
63
+ componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
64
+ render(): react.JSX.Element;
65
+ }
66
+
67
+ type RenderPropFn<Tvalue> = (result: Tvalue) => react.ReactNode;
68
+ type AwaitInnerProps<Tvalue> = DiscriminatedRenderProps<RenderPropFn<Tvalue>> & {
69
+ promise: Promise<Tvalue>;
70
+ };
71
+ type AwaitProps<Tvalue> = AwaitInnerProps<Tvalue> & {
72
+ errorFallback?: ErrorBoundaryProps["fallback"];
73
+ fallback?: react.ReactNode;
74
+ };
75
+ declare function Await<Tvalue>(props: AwaitProps<Tvalue>): react.JSX.Element;
76
+
77
+ export { Await, type AwaitInnerProps, ErrorBoundary, type ErrorBoundaryContextType, type ErrorBoundaryProps, type FallbackProps, useErrorBoundary, useErrorBoundaryContext };
@@ -1,4 +1,4 @@
1
- import '../chunk-HKPJTORQ.js';
1
+ export { Await, ErrorBoundary, useErrorBoundary, useErrorBoundaryContext } from '../chunk-6BUR5OWX.js';
2
2
  export { ForBase, ForList, getElementList } from '../chunk-DW3FXTFL.js';
3
3
  export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot } from '../chunk-NCS3WKFW.js';
4
4
  export { Slot, Slottable } from '../chunk-ENDWJXPF.js';
@@ -4,6 +4,7 @@ export { useDragScroll } from './ui/drag-scroll/index.js';
4
4
  export { DropZone, InputProps, RootProps, UseDropZoneProps, useDropZone } from './ui/drop-zone/index.js';
5
5
  export { FieldValues, Form, FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormFieldSubscribe, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormStateSubscribe, FormSubmit, FormTextAreaPrimitive, useFormFieldContext } from './ui/form/index.js';
6
6
  export { useFormContext as useFormRootContext } from 'react-hook-form';
7
+ export { Await, AwaitInnerProps, ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary, useErrorBoundaryContext } from './common/index.js';
7
8
  export { ForBase, ForList, ForRenderProps, getElementList } from './common/for/index.js';
8
9
  export { Show, ShowContent, ShowFallback, ShowRoot } from './common/show/index.js';
9
10
  export { Slot, Slottable } from './common/slot/index.js';
package/dist/esm/index.js CHANGED
@@ -5,7 +5,7 @@ export { useDragScroll } from './chunk-E42DOTGX.js';
5
5
  export { DropZone, useDropZone } from './chunk-2YCUMTC7.js';
6
6
  export { form_parts_exports as Form, FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormFieldSubscribe, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormStateSubscribe, FormSubmit, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext, useFormContext as useFormRootContext } from './chunk-3OWAXCPZ.js';
7
7
  import './chunk-OHG7GB7O.js';
8
- import './chunk-HKPJTORQ.js';
8
+ export { Await, ErrorBoundary, useErrorBoundary, useErrorBoundaryContext } from './chunk-6BUR5OWX.js';
9
9
  export { ForBase, ForList, getElementList } from './chunk-DW3FXTFL.js';
10
10
  export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot } from './chunk-NCS3WKFW.js';
11
11
  export { Slot, Slottable } from './chunk-ENDWJXPF.js';
@@ -69,6 +69,8 @@ declare const useDragScroll: <TElement extends HTMLElement>(props?: DragScrollPr
69
69
  inert?: boolean | undefined;
70
70
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
71
71
  is?: string | undefined;
72
+ exportparts?: string | undefined;
73
+ part?: string | undefined;
72
74
  "aria-activedescendant"?: string | undefined;
73
75
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
74
76
  "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
@@ -276,6 +278,8 @@ declare const useDragScroll: <TElement extends HTMLElement>(props?: DragScrollPr
276
278
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLElement> | undefined;
277
279
  onScroll?: react.UIEventHandler<HTMLElement> | undefined;
278
280
  onScrollCapture?: react.UIEventHandler<HTMLElement> | undefined;
281
+ onScrollEnd?: react.UIEventHandler<HTMLElement> | undefined;
282
+ onScrollEndCapture?: react.UIEventHandler<HTMLElement> | undefined;
279
283
  onWheel?: react.WheelEventHandler<HTMLElement> | undefined;
280
284
  onWheelCapture?: react.WheelEventHandler<HTMLElement> | undefined;
281
285
  onAnimationStart?: react.AnimationEventHandler<HTMLElement> | undefined;
@@ -135,6 +135,8 @@ declare const useDropZone: (props: UseDropZoneProps) => {
135
135
  inert?: boolean | undefined;
136
136
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
137
137
  is?: string | undefined;
138
+ exportparts?: string | undefined;
139
+ part?: string | undefined;
138
140
  "aria-activedescendant"?: string | undefined;
139
141
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
140
142
  "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
@@ -341,6 +343,8 @@ declare const useDropZone: (props: UseDropZoneProps) => {
341
343
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLInputElement> | undefined;
342
344
  onScroll?: react.UIEventHandler<HTMLInputElement> | undefined;
343
345
  onScrollCapture?: react.UIEventHandler<HTMLInputElement> | undefined;
346
+ onScrollEnd?: react.UIEventHandler<HTMLInputElement> | undefined;
347
+ onScrollEndCapture?: react.UIEventHandler<HTMLInputElement> | undefined;
344
348
  onWheel?: react.WheelEventHandler<HTMLInputElement> | undefined;
345
349
  onWheelCapture?: react.WheelEventHandler<HTMLInputElement> | undefined;
346
350
  onAnimationStart?: react.AnimationEventHandler<HTMLInputElement> | undefined;
@@ -428,6 +432,8 @@ declare const useDropZone: (props: UseDropZoneProps) => {
428
432
  inert?: boolean | undefined;
429
433
  inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
430
434
  is?: string | undefined;
435
+ exportparts?: string | undefined;
436
+ part?: string | undefined;
431
437
  "aria-activedescendant"?: string | undefined;
432
438
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
433
439
  "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
@@ -631,6 +637,8 @@ declare const useDropZone: (props: UseDropZoneProps) => {
631
637
  onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLDivElement> | undefined;
632
638
  onScroll?: react.UIEventHandler<HTMLDivElement> | undefined;
633
639
  onScrollCapture?: react.UIEventHandler<HTMLDivElement> | undefined;
640
+ onScrollEnd?: react.UIEventHandler<HTMLDivElement> | undefined;
641
+ onScrollEndCapture?: react.UIEventHandler<HTMLDivElement> | undefined;
634
642
  onWheel?: react.WheelEventHandler<HTMLDivElement> | undefined;
635
643
  onWheelCapture?: react.WheelEventHandler<HTMLDivElement> | undefined;
636
644
  onAnimationStart?: react.AnimationEventHandler<HTMLDivElement> | undefined;
@@ -1,6 +1,6 @@
1
1
  export { form_parts_exports as Form, FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormFieldSubscribe, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormStateSubscribe, FormSubmit, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext, useFormContext as useFormRootContext } from '../../chunk-3OWAXCPZ.js';
2
2
  import '../../chunk-OHG7GB7O.js';
3
- import '../../chunk-HKPJTORQ.js';
3
+ import '../../chunk-6BUR5OWX.js';
4
4
  import '../../chunk-DW3FXTFL.js';
5
5
  import '../../chunk-NCS3WKFW.js';
6
6
  import '../../chunk-ENDWJXPF.js';
@@ -5,7 +5,7 @@ export { useDragScroll } from '../chunk-E42DOTGX.js';
5
5
  export { DropZone, useDropZone } from '../chunk-2YCUMTC7.js';
6
6
  export { form_parts_exports as Form, FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormFieldSubscribe, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormStateSubscribe, FormSubmit, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext, useFormContext as useFormRootContext } from '../chunk-3OWAXCPZ.js';
7
7
  import '../chunk-OHG7GB7O.js';
8
- import '../chunk-HKPJTORQ.js';
8
+ import '../chunk-6BUR5OWX.js';
9
9
  import '../chunk-DW3FXTFL.js';
10
10
  import '../chunk-NCS3WKFW.js';
11
11
  import '../chunk-ENDWJXPF.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zayne-labs/ui-react",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.5.0",
5
5
  "description": "A composable UI/UI-utilities components library. ",
6
6
  "author": "Ryan Zayne",
7
7
  "license": "MIT",
@@ -48,25 +48,24 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@zayne-labs/toolkit-core": "^0.8.55",
52
- "@zayne-labs/toolkit-react": "^0.8.55",
53
- "@zayne-labs/toolkit-type-helpers": "^0.8.55"
51
+ "@zayne-labs/toolkit-core": "^0.8.60",
52
+ "@zayne-labs/toolkit-react": "^0.8.60",
53
+ "@zayne-labs/toolkit-type-helpers": "^0.8.60"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@arethetypeswrong/cli": "0.17.4",
57
57
  "@size-limit/esbuild-why": "11.2.0",
58
58
  "@size-limit/preset-small-lib": "11.2.0",
59
59
  "@total-typescript/ts-reset": "0.6.1",
60
- "@types/react": "^19.0.10",
60
+ "@types/react": "^19.0.12",
61
61
  "@types/react-dom": "^19.0.4",
62
- "@zayne-labs/prettier-config": "^0.7.8",
63
62
  "@zayne-labs/tsconfig": "0.7.8",
64
63
  "concurrently": "^9.0.1",
65
64
  "cross-env": "^7.0.3",
66
65
  "publint": "^0.3.9",
67
- "react": "^19.0.0",
68
- "react-dom": "^19.0.0",
69
- "react-hook-form": "^7.53.2",
66
+ "react": "^19.1.0",
67
+ "react-dom": "^19.1.0",
68
+ "react-hook-form": "^7.55.0",
70
69
  "size-limit": "11.2.0",
71
70
  "tailwind-merge": "^3.0.2",
72
71
  "terser": "5.39.0",
@@ -96,6 +95,8 @@
96
95
  "dev": "pnpm build:dev --watch",
97
96
  "lint:attw": "attw --pack . --profile esm-only --format table-flipped --ignore-rules=cjs-resolves-to-esm --ignore-rules=named-exports",
98
97
  "lint:check-types": "tsc --pretty -p tsconfig.json",
98
+ "lint:eslint": "eslint . --max-warnings 0",
99
+ "lint:eslint:interactive": "pnpx eslint-interactive@latest . --max-warnings 0 --fix",
99
100
  "lint:publint": "publint --strict .",
100
101
  "lint:size": "size-limit",
101
102
  "release:test": "pnpx pkg-pr-new publish"
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-HKPJTORQ.js.map
3
- //# sourceMappingURL=chunk-HKPJTORQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-HKPJTORQ.js"}