@lumx/react 3.18.2-alpha.0 → 3.18.2-alpha.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.
@@ -0,0 +1,236 @@
1
+ import React__default, { useContext, useEffect, useMemo, useRef, createContext } from 'react';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import { createPortal } from 'react-dom';
4
+
5
+ function _defineProperty(e, r, t) {
6
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
7
+ value: t,
8
+ enumerable: !0,
9
+ configurable: !0,
10
+ writable: !0
11
+ }) : e[r] = t, e;
12
+ }
13
+ function _extends() {
14
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
15
+ for (var e = 1; e < arguments.length; e++) {
16
+ var t = arguments[e];
17
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
18
+ }
19
+ return n;
20
+ }, _extends.apply(null, arguments);
21
+ }
22
+ function ownKeys(e, r) {
23
+ var t = Object.keys(e);
24
+ if (Object.getOwnPropertySymbols) {
25
+ var o = Object.getOwnPropertySymbols(e);
26
+ r && (o = o.filter(function (r) {
27
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
28
+ })), t.push.apply(t, o);
29
+ }
30
+ return t;
31
+ }
32
+ function _objectSpread2(e) {
33
+ for (var r = 1; r < arguments.length; r++) {
34
+ var t = null != arguments[r] ? arguments[r] : {};
35
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
36
+ _defineProperty(e, r, t[r]);
37
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
38
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
39
+ });
40
+ }
41
+ return e;
42
+ }
43
+ function _objectWithoutProperties(e, t) {
44
+ if (null == e) return {};
45
+ var o,
46
+ r,
47
+ i = _objectWithoutPropertiesLoose(e, t);
48
+ if (Object.getOwnPropertySymbols) {
49
+ var n = Object.getOwnPropertySymbols(e);
50
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
51
+ }
52
+ return i;
53
+ }
54
+ function _objectWithoutPropertiesLoose(r, e) {
55
+ if (null == r) return {};
56
+ var t = {};
57
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
58
+ if (-1 !== e.indexOf(n)) continue;
59
+ t[n] = r[n];
60
+ }
61
+ return t;
62
+ }
63
+ function _toPrimitive(t, r) {
64
+ if ("object" != typeof t || !t) return t;
65
+ var e = t[Symbol.toPrimitive];
66
+ if (void 0 !== e) {
67
+ var i = e.call(t, r || "default");
68
+ if ("object" != typeof i) return i;
69
+ throw new TypeError("@@toPrimitive must return a primitive value.");
70
+ }
71
+ return ("string" === r ? String : Number)(t);
72
+ }
73
+ function _toPropertyKey(t) {
74
+ var i = _toPrimitive(t, "string");
75
+ return "symbol" == typeof i ? i : i + "";
76
+ }
77
+
78
+ const _excluded = ["children"];
79
+
80
+ /** Disable state */
81
+
82
+ const DisabledStateContext = /*#__PURE__*/React__default.createContext({
83
+ state: null
84
+ });
85
+ /**
86
+ * Disabled state provider.
87
+ * All nested LumX Design System components inherit this disabled state.
88
+ */
89
+ function DisabledStateProvider(_ref) {
90
+ let {
91
+ children
92
+ } = _ref,
93
+ value = _objectWithoutProperties(_ref, _excluded);
94
+ return /*#__PURE__*/React__default.createElement(DisabledStateContext.Provider, {
95
+ value: value
96
+ }, children);
97
+ }
98
+
99
+ /**
100
+ * Get DisabledState context value
101
+ */
102
+ function useDisabledStateContext() {
103
+ return useContext(DisabledStateContext);
104
+ }
105
+
106
+ const EVENT_TYPES = ['mousedown', 'touchstart'];
107
+ function isClickAway(targets, refs) {
108
+ // The targets elements are not contained in any of the listed element references.
109
+ return !refs.some(ref => targets.some(target => {
110
+ var _ref$current;
111
+ return ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(target);
112
+ }));
113
+ }
114
+ /**
115
+ * Listen to clicks away from the given elements and callback the passed in function.
116
+ *
117
+ * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.
118
+ */
119
+ function useClickAway({
120
+ callback,
121
+ childrenRefs
122
+ }) {
123
+ useEffect(() => {
124
+ const {
125
+ current: currentRefs
126
+ } = childrenRefs;
127
+ if (!callback || !currentRefs || isEmpty(currentRefs)) {
128
+ return undefined;
129
+ }
130
+ const listener = evt => {
131
+ var _evt$composedPath;
132
+ const targets = [(_evt$composedPath = evt.composedPath) === null || _evt$composedPath === void 0 ? void 0 : _evt$composedPath.call(evt)[0], evt.target];
133
+ if (isClickAway(targets, currentRefs)) {
134
+ callback(evt);
135
+ }
136
+ };
137
+ EVENT_TYPES.forEach(evtType => document.addEventListener(evtType, listener));
138
+ return () => {
139
+ EVENT_TYPES.forEach(evtType => document.removeEventListener(evtType, listener));
140
+ };
141
+ }, [callback, childrenRefs]);
142
+ }
143
+
144
+ const ClickAwayAncestorContext = /*#__PURE__*/createContext(null);
145
+ /**
146
+ * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure
147
+ * we take into account both the DOM tree and the React tree to detect click away.
148
+ *
149
+ * @return the react component.
150
+ */
151
+ const ClickAwayProvider = ({
152
+ children,
153
+ callback,
154
+ childrenRefs,
155
+ parentRef
156
+ }) => {
157
+ const parentContext = useContext(ClickAwayAncestorContext);
158
+ const currentContext = useMemo(() => {
159
+ const context = {
160
+ childrenRefs: [],
161
+ /**
162
+ * Add element refs to the current context and propagate to the parent context.
163
+ */
164
+ addRefs(...newChildrenRefs) {
165
+ // Add element refs that should be considered as inside the click away context.
166
+ context.childrenRefs.push(...newChildrenRefs);
167
+ if (parentContext) {
168
+ // Also add then to the parent context
169
+ parentContext.addRefs(...newChildrenRefs);
170
+ if (parentRef) {
171
+ // The parent element is also considered as inside the parent click away context but not inside the current context
172
+ parentContext.addRefs(parentRef);
173
+ }
174
+ }
175
+ }
176
+ };
177
+ return context;
178
+ }, [parentContext, parentRef]);
179
+ useEffect(() => {
180
+ const {
181
+ current: currentRefs
182
+ } = childrenRefs;
183
+ if (!currentRefs) {
184
+ return;
185
+ }
186
+ currentContext.addRefs(...currentRefs);
187
+ }, [currentContext, childrenRefs]);
188
+ useClickAway({
189
+ callback,
190
+ childrenRefs: useRef(currentContext.childrenRefs)
191
+ });
192
+ return /*#__PURE__*/React__default.createElement(ClickAwayAncestorContext.Provider, {
193
+ value: currentContext
194
+ }, children);
195
+ };
196
+ ClickAwayProvider.displayName = 'ClickAwayProvider';
197
+
198
+ /**
199
+ * Portal initializing function.
200
+ * If it does not provide a container, the Portal children will render in classic React tree and not in a portal.
201
+ */
202
+
203
+ const PortalContext = /*#__PURE__*/React__default.createContext(() => ({
204
+ container: document.body
205
+ }));
206
+ /**
207
+ * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)
208
+ */
209
+ const PortalProvider = PortalContext.Provider;
210
+
211
+ /**
212
+ * Render children in a portal outside the current DOM position
213
+ * (defaults to `document.body` but can be customized with the PortalContextProvider)
214
+ */
215
+ const Portal = ({
216
+ children,
217
+ enabled = true
218
+ }) => {
219
+ const init = React__default.useContext(PortalContext);
220
+ const context = React__default.useMemo(() => {
221
+ return enabled ? init() : null;
222
+ },
223
+ // Only update on 'enabled'
224
+ // eslint-disable-next-line react-hooks/exhaustive-deps
225
+ [enabled]);
226
+ React__default.useLayoutEffect(() => {
227
+ return context === null || context === void 0 ? void 0 : context.teardown;
228
+ }, [context === null || context === void 0 ? void 0 : context.teardown, enabled]);
229
+ if (!(context !== null && context !== void 0 && context.container)) {
230
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
231
+ }
232
+ return /*#__PURE__*/createPortal(children, context.container);
233
+ };
234
+
235
+ export { ClickAwayProvider as C, DisabledStateProvider as D, Portal as P, _objectSpread2 as _, _objectWithoutProperties as a, _extends as b, PortalProvider as c, useDisabledStateContext as u };
236
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx"],"sourcesContent":["import React, { useContext } from 'react';\n\n/** Disable state */\ntype DisabledStateContextValue =\n | {\n state: 'disabled';\n }\n | { state: undefined | null };\n\nexport const DisabledStateContext = React.createContext<DisabledStateContextValue>({ state: null });\n\nexport type DisabledStateProviderProps = DisabledStateContextValue & {\n children: React.ReactNode;\n};\n\n/**\n * Disabled state provider.\n * All nested LumX Design System components inherit this disabled state.\n */\nexport function DisabledStateProvider({ children, ...value }: DisabledStateProviderProps) {\n return <DisabledStateContext.Provider value={value}>{children}</DisabledStateContext.Provider>;\n}\n\n/**\n * Get DisabledState context value\n */\nexport function useDisabledStateContext(): DisabledStateContextValue {\n return useContext(DisabledStateContext);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils/type';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(targets: HTMLElement[], refs: Array<RefObject<HTMLElement>>): boolean {\n // The targets elements are not contained in any of the listed element references.\n return !refs.some((ref) => targets.some((target) => ref?.current?.contains(target)));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements considered within the click away context (clicking outside them will trigger the click away callback).\n */\n childrenRefs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, childrenRefs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n if (isClickAway(targets, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, childrenRefs]);\n}\n","import React, { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\ninterface ContextValue {\n childrenRefs: Array<RefObject<HTMLElement>>;\n addRefs(...newChildrenRefs: Array<RefObject<HTMLElement>>): void;\n}\n\nconst ClickAwayAncestorContext = createContext<ContextValue | null>(null);\n\ninterface ClickAwayProviderProps extends ClickAwayParameters {\n /**\n * (Optional) Element that should be considered as part of the parent\n */\n parentRef?: RefObject<HTMLElement>;\n /**\n * Children\n */\n children?: React.ReactNode;\n}\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayProviderProps> = ({\n children,\n callback,\n childrenRefs,\n parentRef,\n}) => {\n const parentContext = useContext(ClickAwayAncestorContext);\n const currentContext = useMemo(() => {\n const context: ContextValue = {\n childrenRefs: [],\n /**\n * Add element refs to the current context and propagate to the parent context.\n */\n addRefs(...newChildrenRefs) {\n // Add element refs that should be considered as inside the click away context.\n context.childrenRefs.push(...newChildrenRefs);\n\n if (parentContext) {\n // Also add then to the parent context\n parentContext.addRefs(...newChildrenRefs);\n if (parentRef) {\n // The parent element is also considered as inside the parent click away context but not inside the current context\n parentContext.addRefs(parentRef);\n }\n }\n },\n };\n return context;\n }, [parentContext, parentRef]);\n\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!currentRefs) {\n return;\n }\n currentContext.addRefs(...currentRefs);\n }, [currentContext, childrenRefs]);\n\n useClickAway({ callback, childrenRefs: useRef(currentContext.childrenRefs) });\n return <ClickAwayAncestorContext.Provider value={currentContext}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n","import React from 'react';\n\ntype Container = DocumentFragment | Element;\n\n/**\n * Portal initializing function.\n * If it does not provide a container, the Portal children will render in classic React tree and not in a portal.\n */\nexport type PortalInit = () => {\n container?: Container;\n teardown?: () => void;\n};\n\nexport const PortalContext = React.createContext<PortalInit>(() => ({ container: document.body }));\n\nexport interface PortalProviderProps {\n children?: React.ReactNode;\n value: PortalInit;\n}\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider: React.FC<PortalProviderProps> = PortalContext.Provider;\n","import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalContext } from './PortalProvider';\n\nexport interface PortalProps {\n enabled?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalContextProvider)\n */\nexport const Portal: React.FC<PortalProps> = ({ children, enabled = true }) => {\n const init = React.useContext(PortalContext);\n const context = React.useMemo(\n () => {\n return enabled ? init() : null;\n },\n // Only update on 'enabled'\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [enabled],\n );\n\n React.useLayoutEffect(() => {\n return context?.teardown;\n }, [context?.teardown, enabled]);\n\n if (!context?.container) {\n return <>{children}</>;\n }\n return createPortal(children, context.container);\n};\n"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","_ref","children","value","_objectWithoutProperties","_excluded","createElement","Provider","useDisabledStateContext","useContext","EVENT_TYPES","isClickAway","targets","refs","some","ref","target","_ref$current","current","contains","useClickAway","callback","childrenRefs","useEffect","currentRefs","isEmpty","undefined","listener","evt","_evt$composedPath","composedPath","call","forEach","evtType","document","addEventListener","removeEventListener","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","useRef","displayName","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","Fragment","createPortal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAOO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAA4B;AAAEC,EAAAA,KAAK,EAAE,IAAA;AAAK,CAAC,CAAC,CAAA;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAAC,IAAA,EAAqD;EAAA,IAApD;AAAEC,MAAAA,QAAAA;AAA+C,KAAC,GAAAD,IAAA;AAAnCE,IAAAA,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACtD,EAAA,oBAAOR,cAAA,CAAAS,aAAA,CAACV,oBAAoB,CAACW,QAAQ,EAAA;AAACJ,IAAAA,KAAK,EAAEA,KAAAA;AAAM,GAAA,EAAED,QAAwC,CAAC,CAAA;AAClG,CAAA;;AAEA;AACA;AACA;AACO,SAASM,uBAAuBA,GAA8B;EACjE,OAAOC,UAAU,CAACb,oBAAoB,CAAC,CAAA;AAC3C;;ACtBA,MAAMc,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAE/C,SAASC,WAAWA,CAACC,OAAsB,EAAEC,IAAmC,EAAW;AACvF;EACA,OAAO,CAACA,IAAI,CAACC,IAAI,CAAEC,GAAG,IAAKH,OAAO,CAACE,IAAI,CAAEE,MAAM,IAAA;AAAA,IAAA,IAAAC,YAAA,CAAA;AAAA,IAAA,OAAKF,GAAG,KAAHA,IAAAA,IAAAA,GAAG,KAAAE,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,CAAAA,YAAA,GAAHF,GAAG,CAAEG,OAAO,MAAA,IAAA,IAAAD,YAAA,KAAZA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,YAAA,CAAcE,Q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A,OAAO,CAAEO,SAAS,CAAE,EAAA;IACrB,oBAAOrD,cAAA,CAAAS,aAAA,CAAAT,cAAA,CAAA6D,QAAA,EAAGxD,IAAAA,EAAAA,QAAW,CAAC,CAAA;AAC1B,GAAA;AACA,EAAA,oBAAOyD,YAAY,CAACzD,QAAQ,EAAEyC,OAAO,CAACO,SAAS,CAAC,CAAA;AACpD;;;;"}
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends, u as useDisabledStateContext, P as Portal, C as ClickAwayProvider } from './_internal/index.js';
1
2
  import * as React from 'react';
2
3
  import React__default, { useState, useEffect, useMemo, useRef, useCallback, Children, isValidElement, cloneElement, useLayoutEffect, createContext, useContext, useReducer } from 'react';
3
4
  import isBoolean from 'lodash/isBoolean';
@@ -11,7 +12,6 @@ import concat from 'lodash/concat';
11
12
  import dropRight from 'lodash/dropRight';
12
13
  import partition from 'lodash/partition';
13
14
  import reduce from 'lodash/reduce';
14
- import { Portal, ClickAwayProvider } from './utils/index.js';
15
15
  import memoize from 'lodash/memoize';
16
16
  import isFunction from 'lodash/isFunction';
17
17
  import castArray from 'lodash/castArray';
@@ -25,79 +25,6 @@ import take from 'lodash/take';
25
25
  import isObject from 'lodash/isObject';
26
26
  import set from 'lodash/set';
27
27
 
28
- function _defineProperty(e, r, t) {
29
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
30
- value: t,
31
- enumerable: !0,
32
- configurable: !0,
33
- writable: !0
34
- }) : e[r] = t, e;
35
- }
36
- function _extends() {
37
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
38
- for (var e = 1; e < arguments.length; e++) {
39
- var t = arguments[e];
40
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
41
- }
42
- return n;
43
- }, _extends.apply(null, arguments);
44
- }
45
- function ownKeys(e, r) {
46
- var t = Object.keys(e);
47
- if (Object.getOwnPropertySymbols) {
48
- var o = Object.getOwnPropertySymbols(e);
49
- r && (o = o.filter(function (r) {
50
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
51
- })), t.push.apply(t, o);
52
- }
53
- return t;
54
- }
55
- function _objectSpread2(e) {
56
- for (var r = 1; r < arguments.length; r++) {
57
- var t = null != arguments[r] ? arguments[r] : {};
58
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
59
- _defineProperty(e, r, t[r]);
60
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
61
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
62
- });
63
- }
64
- return e;
65
- }
66
- function _objectWithoutProperties(e, t) {
67
- if (null == e) return {};
68
- var o,
69
- r,
70
- i = _objectWithoutPropertiesLoose(e, t);
71
- if (Object.getOwnPropertySymbols) {
72
- var n = Object.getOwnPropertySymbols(e);
73
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
74
- }
75
- return i;
76
- }
77
- function _objectWithoutPropertiesLoose(r, e) {
78
- if (null == r) return {};
79
- var t = {};
80
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
81
- if (-1 !== e.indexOf(n)) continue;
82
- t[n] = r[n];
83
- }
84
- return t;
85
- }
86
- function _toPrimitive(t, r) {
87
- if ("object" != typeof t || !t) return t;
88
- var e = t[Symbol.toPrimitive];
89
- if (void 0 !== e) {
90
- var i = e.call(t, r || "default");
91
- if ("object" != typeof i) return i;
92
- throw new TypeError("@@toPrimitive must return a primitive value.");
93
- }
94
- return ("string" === r ? String : Number)(t);
95
- }
96
- function _toPropertyKey(t) {
97
- var i = _toPrimitive(t, "string");
98
- return "symbol" == typeof i ? i : i + "";
99
- }
100
-
101
28
  /**
102
29
  * See SCSS variable $lumx-color-palette
103
30
  */
@@ -858,8 +785,9 @@ function useDisableStateProps(props) {
858
785
  onChange
859
786
  } = props,
860
787
  otherProps = _objectWithoutProperties(props, _excluded$1s);
788
+ const disabledStateContext = useDisabledStateContext();
861
789
  const disabledStateProps = {
862
- disabled: isDisabled,
790
+ disabled: (disabledStateContext === null || disabledStateContext === void 0 ? void 0 : disabledStateContext.state) === 'disabled' || isDisabled,
863
791
  'aria-disabled': ariaDisabled === true || ariaDisabled === 'true'
864
792
  };
865
793
  const isAnyDisabled = disabledStateProps['aria-disabled'] || disabledStateProps.disabled;