@lerianstudio/sindarian-ui 1.0.0-beta.18 → 1.0.0-beta.19

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 +1 @@
1
- {"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;AAMD,eAAO,MAAM,UAAU,2BAMtB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,KAAK,CAAC,iBAAiB,4CAgBpE,CAAA"}
1
+ {"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;AAMD,eAAO,MAAM,UAAU,2BAMtB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,KAAK,CAAC,iBAAiB,4CAgBpE,CAAA"}
@@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SidebarProvider = exports.useSidebar = void 0;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const storage_1 = require("../../../lib/storage");
9
10
  const react_1 = __importDefault(require("react"));
10
11
  const SidebarContext = react_1.default.createContext(undefined);
11
12
  const useSidebar = () => {
@@ -17,7 +18,7 @@ const useSidebar = () => {
17
18
  };
18
19
  exports.useSidebar = useSidebar;
19
20
  const SidebarProvider = ({ children }) => {
20
- const [collapsed, setCollapsed] = react_1.default.useState(localStorage.getItem('sidebar-collapsed') === 'true');
21
+ const [collapsed, setCollapsed] = react_1.default.useState((0, storage_1.getStorage)('sidebar-collapsed', false));
21
22
  const toggleSidebar = () => setCollapsed((collapsed) => !collapsed);
22
23
  react_1.default.useEffect(() => {
23
24
  localStorage.setItem('sidebar-collapsed', JSON.stringify(collapsed));
@@ -0,0 +1,2 @@
1
+ export declare function getStorageObject(key: string, defaultValue: any): any;
2
+ //# sourceMappingURL=get-storage-object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-storage-object.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/get-storage-object.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAa9D"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStorageObject = getStorageObject;
4
+ const get_storage_1 = require("./get-storage");
5
+ const lodash_1 = require("lodash");
6
+ function getStorageObject(key, defaultValue) {
7
+ try {
8
+ const dataString = (0, get_storage_1.getStorage)(key, defaultValue);
9
+ const isNilOrEmpty = (0, lodash_1.isNil)(dataString) || (0, lodash_1.isEmpty)(dataString);
10
+ return isNilOrEmpty ? {} : JSON.parse(dataString);
11
+ }
12
+ catch (error) {
13
+ // Only log errors when not in test environment
14
+ if (process.env.NODE_ENV !== 'test') {
15
+ console.error(error);
16
+ }
17
+ return defaultValue;
18
+ }
19
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getStorage(key: string, defaultValue: any): any;
2
+ //# sourceMappingURL=get-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-storage.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/get-storage.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAYxD"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStorage = getStorage;
4
+ const isServer = typeof window === 'undefined';
5
+ function getStorage(key, defaultValue) {
6
+ if (isServer) {
7
+ return defaultValue;
8
+ }
9
+ let value;
10
+ try {
11
+ value = localStorage.getItem(key) || undefined;
12
+ }
13
+ catch (e) {
14
+ // Unsupported
15
+ }
16
+ return value || defaultValue;
17
+ }
@@ -0,0 +1,3 @@
1
+ export * from './get-storage';
2
+ export * from './get-storage-object';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-storage"), exports);
18
+ __exportStar(require("./get-storage-object"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerianstudio/sindarian-ui",
3
- "version": "1.0.0-beta.18",
3
+ "version": "1.0.0-beta.19",
4
4
  "description": "Sindarian UI - A UI library for Midaz Console",
5
5
  "license": "ISC",
6
6
  "author": {