@clayui/provider
Advanced tools
+24
-16
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var DataClient_exports = {}; | ||
| __export(DataClient_exports, { | ||
| DataClient: () => DataClient | ||
| }); | ||
| exports.DataClient = void 0; | ||
| var _LRUCache = require("./LRUCache"); | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| module.exports = __toCommonJS(DataClient_exports); | ||
| var import_LRUCache = require("./LRUCache"); | ||
| class DataClient { | ||
| constructor() { | ||
| let { | ||
| storageMaxSize | ||
| } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
| this.cache = new _LRUCache.LRUCache(storageMaxSize); | ||
| constructor({ storageMaxSize } = {}) { | ||
| this.cache = new import_LRUCache.LRUCache(storageMaxSize); | ||
| this.currentPromises = {}; | ||
@@ -57,2 +66,1 @@ this.cursors = {}; | ||
| } | ||
| exports.DataClient = DataClient; |
+22
-23
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| var _exportNames = { | ||
| __UNSTABLE_DataClient: true | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| Object.defineProperty(exports, "__UNSTABLE_DataClient", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _DataClient.DataClient; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| __UNSTABLE_DataClient: () => import_DataClient.DataClient | ||
| }); | ||
| var _Provider = require("./Provider"); | ||
| Object.keys(_Provider).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
| if (key in exports && exports[key] === _Provider[key]) return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _Provider[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _DataClient = require("./DataClient"); | ||
| module.exports = __toCommonJS(src_exports); | ||
| __reExport(src_exports, require("./Provider"), module.exports); | ||
| var import_DataClient = require("./DataClient"); |
+27
-19
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var LRUCache_exports = {}; | ||
| __export(LRUCache_exports, { | ||
| LRUCache: () => LRUCache | ||
| }); | ||
| exports.LRUCache = void 0; | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| module.exports = __toCommonJS(LRUCache_exports); | ||
| const DEFAULT_MAX_SIZE = 20; | ||
| class LRUCache { | ||
| constructor() { | ||
| let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAX_SIZE; | ||
| constructor(maxSize = DEFAULT_MAX_SIZE) { | ||
| if (maxSize <= 0) { | ||
| throw new TypeError('LRUCache: max must be a non-negative number'); | ||
| throw new TypeError("LRUCache: max must be a non-negative number"); | ||
| } | ||
| this._maxSize = maxSize; | ||
| this._storage = new Map(); | ||
| this._storage = /* @__PURE__ */ new Map(); | ||
| } | ||
| reset() { | ||
| this._storage = new Map(); | ||
| this._storage = /* @__PURE__ */ new Map(); | ||
| return this._storage; | ||
@@ -42,6 +53,4 @@ } | ||
| while (count) { | ||
| const { | ||
| value | ||
| } = iterator.next(); | ||
| this._storage.delete(value); | ||
| const { value: value2 } = iterator.next(); | ||
| this._storage.delete(value2); | ||
| count--; | ||
@@ -53,2 +62,1 @@ } | ||
| } | ||
| exports.LRUCache = LRUCache; |
+66
-49
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.useProvider = exports.Provider = void 0; | ||
| var _icon = require("@clayui/icon"); | ||
| var _react = _interopRequireWildcard(require("react")); | ||
| var _DataClient = require("./DataClient"); | ||
| var _useReducedMotion = require("./useReducedMotion"); | ||
| function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
| function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| const Context = /*#__PURE__*/_react.default.createContext({}); | ||
| Context.displayName = 'ClayProviderContext'; | ||
| const Provider = _ref => { | ||
| let { | ||
| children, | ||
| reducedMotion = 'user', | ||
| spritemap, | ||
| storageMaxSize = 20, | ||
| theme, | ||
| ...otherProps | ||
| } = _ref; | ||
| // Use `useMemo` to instantiate the DataClient only once and when | ||
| // updating the property. | ||
| const client = (0, _react.useMemo)(() => new _DataClient.DataClient({ | ||
| storageMaxSize | ||
| }), [storageMaxSize]); | ||
| const isReducedMotion = (0, _useReducedMotion.useReducedMotion)(reducedMotion); | ||
| return /*#__PURE__*/_react.default.createElement(Context.Provider, { | ||
| value: { | ||
| client, | ||
| prefersReducedMotion: isReducedMotion, | ||
| theme, | ||
| ...otherProps | ||
| } | ||
| }, /*#__PURE__*/_react.default.createElement(_icon.ClayIconSpriteContext.Provider, { | ||
| value: spritemap | ||
| }, theme ? /*#__PURE__*/_react.default.createElement("div", { | ||
| className: theme | ||
| }, children) : children)); | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| exports.Provider = Provider; | ||
| const useProvider = () => { | ||
| return (0, _react.useContext)(Context); | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| exports.useProvider = useProvider; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var Provider_exports = {}; | ||
| __export(Provider_exports, { | ||
| Provider: () => Provider, | ||
| useProvider: () => useProvider | ||
| }); | ||
| module.exports = __toCommonJS(Provider_exports); | ||
| var import_icon = require("@clayui/icon"); | ||
| var import_react = __toESM(require("react")); | ||
| var import_DataClient = require("./DataClient"); | ||
| var import_useReducedMotion = require("./useReducedMotion"); | ||
| const Context = import_react.default.createContext({}); | ||
| Context.displayName = "ClayProviderContext"; | ||
| function Provider({ | ||
| children, | ||
| reducedMotion = "user", | ||
| spritemap, | ||
| storageMaxSize = 20, | ||
| theme, | ||
| ...otherProps | ||
| }) { | ||
| const client = (0, import_react.useMemo)( | ||
| () => new import_DataClient.DataClient({ storageMaxSize }), | ||
| [storageMaxSize] | ||
| ); | ||
| const isReducedMotion = (0, import_useReducedMotion.useReducedMotion)(reducedMotion); | ||
| return /* @__PURE__ */ import_react.default.createElement( | ||
| Context.Provider, | ||
| { | ||
| value: { | ||
| client, | ||
| prefersReducedMotion: isReducedMotion, | ||
| theme, | ||
| ...otherProps | ||
| } | ||
| }, | ||
| /* @__PURE__ */ import_react.default.createElement(import_icon.ClayIconSpriteContext.Provider, { value: spritemap }, theme ? /* @__PURE__ */ import_react.default.createElement("div", { className: theme }, children) : children) | ||
| ); | ||
| } | ||
| function useProvider() { | ||
| return (0, import_react.useContext)(Context); | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var useReducedMotion_exports = {}; | ||
| __export(useReducedMotion_exports, { | ||
| useReducedMotion: () => useReducedMotion | ||
| }); | ||
| exports.useReducedMotion = useReducedMotion; | ||
| var _react = require("react"); | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| module.exports = __toCommonJS(useReducedMotion_exports); | ||
| var import_react = require("react"); | ||
| function useReducedMotion(mode) { | ||
| const [reduceMotion, setReduceMotion] = (0, _react.useState)(false); | ||
| (0, _react.useEffect)(() => { | ||
| const [reduceMotion, setReduceMotion] = (0, import_react.useState)(false); | ||
| (0, import_react.useEffect)(() => { | ||
| switch (mode) { | ||
| case 'always': | ||
| case "always": | ||
| setReduceMotion(true); | ||
| break; | ||
| case 'never': | ||
| case "never": | ||
| break; | ||
| default: | ||
| { | ||
| if (window.matchMedia) { | ||
| const motionMediaQuery = window.matchMedia('(prefers-reduced-motion)'); | ||
| const setReducedMotionPreferences = mediaQuery => setReduceMotion(mediaQuery.matches); | ||
| motionMediaQuery.addEventListener('change', setReducedMotionPreferences); | ||
| return () => { | ||
| motionMediaQuery.removeEventListener('change', setReducedMotionPreferences); | ||
| }; | ||
| } else { | ||
| setReduceMotion(false); | ||
| } | ||
| break; | ||
| default: { | ||
| if (window.matchMedia) { | ||
| const motionMediaQuery = window.matchMedia( | ||
| "(prefers-reduced-motion)" | ||
| ); | ||
| const setReducedMotionPreferences = (mediaQuery) => setReduceMotion(mediaQuery.matches); | ||
| motionMediaQuery.addEventListener( | ||
| "change", | ||
| setReducedMotionPreferences | ||
| ); | ||
| return () => { | ||
| motionMediaQuery.removeEventListener( | ||
| "change", | ||
| setReducedMotionPreferences | ||
| ); | ||
| }; | ||
| } else { | ||
| setReduceMotion(false); | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| }, []); | ||
| return reduceMotion; | ||
| } | ||
| } |
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com | ||
| * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
| */ | ||
@@ -5,0 +5,0 @@ import { LRUCache } from './LRUCache'; |
@@ -1,11 +0,4 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| import { LRUCache } from "./LRUCache.js"; | ||
| export class DataClient { | ||
| constructor() { | ||
| let { | ||
| storageMaxSize | ||
| } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
| import { LRUCache } from "./LRUCache"; | ||
| class DataClient { | ||
| constructor({ storageMaxSize } = {}) { | ||
| this.cache = new LRUCache(storageMaxSize); | ||
@@ -49,2 +42,5 @@ this.currentPromises = {}; | ||
| } | ||
| } | ||
| } | ||
| export { | ||
| DataClient | ||
| }; |
+5
-6
@@ -1,6 +0,5 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| export * from "./Provider.js"; | ||
| export { DataClient as __UNSTABLE_DataClient } from "./DataClient.js"; | ||
| export * from "./Provider"; | ||
| import { DataClient } from "./DataClient"; | ||
| export { | ||
| DataClient as __UNSTABLE_DataClient | ||
| }; |
+11
-16
@@ -1,18 +0,12 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| const DEFAULT_MAX_SIZE = 20; | ||
| export class LRUCache { | ||
| constructor() { | ||
| let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAX_SIZE; | ||
| class LRUCache { | ||
| constructor(maxSize = DEFAULT_MAX_SIZE) { | ||
| if (maxSize <= 0) { | ||
| throw new TypeError('LRUCache: max must be a non-negative number'); | ||
| throw new TypeError("LRUCache: max must be a non-negative number"); | ||
| } | ||
| this._maxSize = maxSize; | ||
| this._storage = new Map(); | ||
| this._storage = /* @__PURE__ */ new Map(); | ||
| } | ||
| reset() { | ||
| this._storage = new Map(); | ||
| this._storage = /* @__PURE__ */ new Map(); | ||
| return this._storage; | ||
@@ -36,6 +30,4 @@ } | ||
| while (count) { | ||
| const { | ||
| value | ||
| } = iterator.next(); | ||
| this._storage.delete(value); | ||
| const { value: value2 } = iterator.next(); | ||
| this._storage.delete(value2); | ||
| count--; | ||
@@ -46,2 +38,5 @@ } | ||
| } | ||
| } | ||
| } | ||
| export { | ||
| LRUCache | ||
| }; |
+37
-40
@@ -1,42 +0,39 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| import { ClayIconSpriteContext } from '@clayui/icon'; | ||
| import React, { useContext, useMemo } from 'react'; | ||
| import { DataClient } from "./DataClient.js"; | ||
| import { useReducedMotion } from "./useReducedMotion.js"; | ||
| const Context = /*#__PURE__*/React.createContext({}); | ||
| Context.displayName = 'ClayProviderContext'; | ||
| export const Provider = _ref => { | ||
| let { | ||
| children, | ||
| reducedMotion = 'user', | ||
| spritemap, | ||
| storageMaxSize = 20, | ||
| theme, | ||
| ...otherProps | ||
| } = _ref; | ||
| // Use `useMemo` to instantiate the DataClient only once and when | ||
| // updating the property. | ||
| const client = useMemo(() => new DataClient({ | ||
| storageMaxSize | ||
| }), [storageMaxSize]); | ||
| import { ClayIconSpriteContext } from "@clayui/icon"; | ||
| import React, { useContext, useMemo } from "react"; | ||
| import { DataClient } from "./DataClient"; | ||
| import { useReducedMotion } from "./useReducedMotion"; | ||
| const Context = React.createContext({}); | ||
| Context.displayName = "ClayProviderContext"; | ||
| function Provider({ | ||
| children, | ||
| reducedMotion = "user", | ||
| spritemap, | ||
| storageMaxSize = 20, | ||
| theme, | ||
| ...otherProps | ||
| }) { | ||
| const client = useMemo( | ||
| () => new DataClient({ storageMaxSize }), | ||
| [storageMaxSize] | ||
| ); | ||
| const isReducedMotion = useReducedMotion(reducedMotion); | ||
| return /*#__PURE__*/React.createElement(Context.Provider, { | ||
| value: { | ||
| client, | ||
| prefersReducedMotion: isReducedMotion, | ||
| theme, | ||
| ...otherProps | ||
| } | ||
| }, /*#__PURE__*/React.createElement(ClayIconSpriteContext.Provider, { | ||
| value: spritemap | ||
| }, theme ? /*#__PURE__*/React.createElement("div", { | ||
| className: theme | ||
| }, children) : children)); | ||
| return /* @__PURE__ */ React.createElement( | ||
| Context.Provider, | ||
| { | ||
| value: { | ||
| client, | ||
| prefersReducedMotion: isReducedMotion, | ||
| theme, | ||
| ...otherProps | ||
| } | ||
| }, | ||
| /* @__PURE__ */ React.createElement(ClayIconSpriteContext.Provider, { value: spritemap }, theme ? /* @__PURE__ */ React.createElement("div", { className: theme }, children) : children) | ||
| ); | ||
| } | ||
| function useProvider() { | ||
| return useContext(Context); | ||
| } | ||
| export { | ||
| Provider, | ||
| useProvider | ||
| }; | ||
| export const useProvider = () => { | ||
| return useContext(Context); | ||
| }; |
@@ -1,33 +0,38 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| import { useEffect, useState } from 'react'; | ||
| export function useReducedMotion(mode) { | ||
| import { useEffect, useState } from "react"; | ||
| function useReducedMotion(mode) { | ||
| const [reduceMotion, setReduceMotion] = useState(false); | ||
| useEffect(() => { | ||
| switch (mode) { | ||
| case 'always': | ||
| case "always": | ||
| setReduceMotion(true); | ||
| break; | ||
| case 'never': | ||
| case "never": | ||
| break; | ||
| default: | ||
| { | ||
| if (window.matchMedia) { | ||
| const motionMediaQuery = window.matchMedia('(prefers-reduced-motion)'); | ||
| const setReducedMotionPreferences = mediaQuery => setReduceMotion(mediaQuery.matches); | ||
| motionMediaQuery.addEventListener('change', setReducedMotionPreferences); | ||
| return () => { | ||
| motionMediaQuery.removeEventListener('change', setReducedMotionPreferences); | ||
| }; | ||
| } else { | ||
| setReduceMotion(false); | ||
| } | ||
| break; | ||
| default: { | ||
| if (window.matchMedia) { | ||
| const motionMediaQuery = window.matchMedia( | ||
| "(prefers-reduced-motion)" | ||
| ); | ||
| const setReducedMotionPreferences = (mediaQuery) => setReduceMotion(mediaQuery.matches); | ||
| motionMediaQuery.addEventListener( | ||
| "change", | ||
| setReducedMotionPreferences | ||
| ); | ||
| return () => { | ||
| motionMediaQuery.removeEventListener( | ||
| "change", | ||
| setReducedMotionPreferences | ||
| ); | ||
| }; | ||
| } else { | ||
| setReduceMotion(false); | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| }, []); | ||
| return reduceMotion; | ||
| } | ||
| } | ||
| export { | ||
| useReducedMotion | ||
| }; |
+2
-2
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com | ||
| * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
| */ | ||
| export * from './Provider'; | ||
| export { DataClient as __UNSTABLE_DataClient } from './DataClient'; |
| /** | ||
| * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com | ||
| * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
| */ | ||
@@ -5,0 +5,0 @@ export declare class LRUCache<K, V> { |
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com | ||
| * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
| */ | ||
@@ -35,4 +35,4 @@ import React from 'react'; | ||
| } | ||
| export declare const Provider: ({ children, reducedMotion, spritemap, storageMaxSize, theme, ...otherProps }: IProviderProps) => JSX.Element; | ||
| export declare const useProvider: () => IProviderContext; | ||
| export declare function Provider({ children, reducedMotion, spritemap, storageMaxSize, theme, ...otherProps }: IProviderProps): React.JSX.Element; | ||
| export declare function useProvider(): IProviderContext; | ||
| export {}; |
| /** | ||
| * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com> | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| * SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com | ||
| * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 | ||
| */ | ||
| export declare function useReducedMotion(mode: 'user' | 'always' | 'never'): boolean; |
+29
-22
| { | ||
| "name": "@clayui/provider", | ||
| "version": "3.144.1", | ||
| "browserslist": [ | ||
| "extends browserslist-config-clay" | ||
| ], | ||
| "dependencies": { | ||
| "@clayui/icon": "^3.157.0-alpha.1" | ||
| }, | ||
| "description": "ClayProvider component in React", | ||
| "license": "BSD-3-Clause", | ||
| "repository": "https://github.com/liferay/clay", | ||
| "main": "lib/cjs/index.js", | ||
| "types": "lib/index.d.ts", | ||
| "ts:main": "src/index.ts", | ||
| "files": [ | ||
| "lib" | ||
| ], | ||
| "scripts": { | ||
| "build": "yarn build:cjs && yarn build:esm", | ||
| "build:cjs": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib/cjs --extensions .ts,.tsx", | ||
| "build:esm": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib/esm --extensions .ts,.tsx --env-name esm", | ||
| "buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json", | ||
| "test": "jest --config ../../jest.config.js" | ||
| }, | ||
| "keywords": [ | ||
@@ -24,14 +16,29 @@ "clay", | ||
| ], | ||
| "dependencies": { | ||
| "@clayui/icon": "^3.144.1" | ||
| }, | ||
| "license": "BSD-3-Clause", | ||
| "main": "lib/cjs/index.js", | ||
| "name": "@clayui/provider", | ||
| "peerDependencies": { | ||
| "@clayui/css": "3.x", | ||
| "@clayui/css": "^3.157.0-alpha.1", | ||
| "react": "^16.0.0 || ^17.0.0 || ^18.0.0", | ||
| "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0" | ||
| }, | ||
| "browserslist": [ | ||
| "extends browserslist-config-clay" | ||
| ], | ||
| "gitHead": "96b1e589bb0777fb30d4fbe050ce7670c8061fe5" | ||
| "repository": "https://github.com/liferay/clay", | ||
| "scripts": { | ||
| "build": "yarn build:cjs && yarn build:esm", | ||
| "build:cjs": "cross-env NODE_ENV=production node ../build-package-esbuild.js --format=cjs --outdir=lib/cjs", | ||
| "build:esm": "cross-env NODE_ENV=production node ../build-package-esbuild.js --format=esm --outdir=lib/esm", | ||
| "buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json", | ||
| "test": "jest --config ../../jest.config.js" | ||
| }, | ||
| "version": "3.157.0-alpha.1", | ||
| "module": "lib/esm/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./lib/index.d.ts", | ||
| "import": "./lib/esm/index.js", | ||
| "require": "./lib/cjs/index.js" | ||
| } | ||
| }, | ||
| "types": "lib/index.d.ts", | ||
| "ts:main": "src/index.tsx" | ||
| } |
+2
-2
@@ -9,6 +9,6 @@ # `@clayui/provider` | ||
| - [Documentation](https://clayui.com/docs/components/provider.html) | ||
| - [Documentation](https://clayui.com/docs/components/provider.html) | ||
| ## Contribute | ||
| We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve. | ||
| We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Copyleft License
LicenseCopyleft license information was found.
Mixed license
LicensePackage contains multiple licenses.
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Non-permissive License
LicenseA license not known to be considered permissive was found.
18340
16.63%526
13.85%3
Infinity%70
-30%2
100%13
-7.14%1
Infinity%