@zonos/amino 4.4.2 → 4.4.3
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
|
-
"use strict";var e=require("../../../_tslib-fe391a2e.js"),r=require("react/jsx-runtime"),t=require("../../checkbox/Checkbox.js"),n=require("../../text/Text.js"),s=require("../../../styles/constants/theme.js"),i=require("../../../utils/hooks/useStorage.js"),a=require("styled-components");function c(e){return e&&e.__esModule?e:{default:e}}require("react"),require("framer-motion"),require("../../../icons/CheckmarkIcon.js"),require("../../../icons/icon-base/_IconBase.js"),require("../../../utils/getTestId.js"),require("../../../utils/storage.js"),require("swr"),require("../../../utils/hooks/useSwr.js");var l,o,u,h=c(a),m=h.default(n.Text)(l||(l=e.__makeTemplateObject(["\n font-size: ",";\n"],["\n font-size: ",";\n"])),s.theme.space16),d=h.default.div(o||(o=e.__makeTemplateObject(["\n label {\n /* Align checkbox with list item */\n display: flex;\n align-items: center;\n }\n"],["\n label {\n /* Align checkbox with list item */\n display: flex;\n align-items: center;\n }\n"]))),x=h.default.div(u||(u=e.__makeTemplateObject(["\n margin-left: ",";\n margin-top: ",";\n"],["\n margin-left: ",";\n margin-top: ",";\n"])),s.theme.space24,s.theme.space24);exports.MdxProgressCheckbox=function(n){var s=n.pathname,a=n.checkboxKey,c=n.children,l=n.xlabel;a||console.warn("A unique progress checkbox key is required to track progress");var o="".concat(s,"-").concat(a),u=e.__read(i.useStorage({key:o,type:"local"
|
|
1
|
+
"use strict";var e=require("../../../_tslib-fe391a2e.js"),r=require("react/jsx-runtime"),t=require("../../checkbox/Checkbox.js"),n=require("../../text/Text.js"),s=require("../../../styles/constants/theme.js"),i=require("../../../utils/hooks/useStorage.js"),a=require("styled-components");function c(e){return e&&e.__esModule?e:{default:e}}require("react"),require("framer-motion"),require("../../../icons/CheckmarkIcon.js"),require("../../../icons/icon-base/_IconBase.js"),require("../../../utils/getTestId.js"),require("../../../utils/storage.js"),require("swr"),require("../../../utils/hooks/useSwr.js");var l,o,u,h=c(a),m=h.default(n.Text)(l||(l=e.__makeTemplateObject(["\n font-size: ",";\n"],["\n font-size: ",";\n"])),s.theme.space16),d=h.default.div(o||(o=e.__makeTemplateObject(["\n label {\n /* Align checkbox with list item */\n display: flex;\n align-items: center;\n }\n"],["\n label {\n /* Align checkbox with list item */\n display: flex;\n align-items: center;\n }\n"]))),x=h.default.div(u||(u=e.__makeTemplateObject(["\n margin-left: ",";\n margin-top: ",";\n"],["\n margin-left: ",";\n margin-top: ",";\n"])),s.theme.space24,s.theme.space24);exports.MdxProgressCheckbox=function(n){var s=n.pathname,a=n.checkboxKey,c=n.children,l=n.xlabel;a||console.warn("A unique progress checkbox key is required to track progress");var o="".concat(s,"-").concat(a),u=e.__read(i.useStorage({defaultValue:"",key:o,type:"local"}),2),h=u[0],b=u[1];return r.jsxs(d,{children:[r.jsx(t.Checkbox,{checked:!!h,labelComponent:r.jsx(m,e.__assign({type:"bold-label"},{children:l})),label:l,onChange:function(){return b(h?"":"checked")}}),r.jsx(x,{children:c})]})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zonos/amino",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.3",
|
|
4
4
|
"description": "Core UI components for Amino",
|
|
5
5
|
"repository": "git@github.com:Zonos/amino.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"not op_mini all"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {},
|
|
15
|
-
"devDependencies": {},
|
|
16
15
|
"dependencies": {
|
|
17
16
|
"@dnd-kit/core": "^5.0.3",
|
|
18
17
|
"@dnd-kit/modifiers": "^5.0.0",
|
|
@@ -33,8 +32,10 @@
|
|
|
33
32
|
"react-simple-maps": "^3.0.0",
|
|
34
33
|
"react-split-it": "^2.0.0",
|
|
35
34
|
"topojson-client": "^3.1.0",
|
|
36
|
-
"uuid": "^8.3.2"
|
|
35
|
+
"uuid": "^8.3.2",
|
|
36
|
+
"zod": "^3.21.4"
|
|
37
37
|
},
|
|
38
|
+
"devDependencies": {},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@emotion/react": "^11.x",
|
|
40
41
|
"@emotion/styled": "^11.x",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./useStorage.js");require("../storage.js"),require("swr"),require("./useSwr.js");exports.useCurrentSchema=function(r){return e.useStorage({
|
|
1
|
+
"use strict";var e=require("./useStorage.js");require("../storage.js"),require("swr"),require("./useSwr.js");exports.useCurrentSchema=function(r){return e.useStorage({defaultValue:r,key:"amino:current-schema",type:"session"})};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type StorageProps } from '../storage';
|
|
2
2
|
type AminoLocalStorageKey = 'current-schema';
|
|
3
3
|
/** Storage key that's being used in Amino */
|
|
4
4
|
export type AminoStorageKey = `amino:${AminoLocalStorageKey}` | (string & Record<never, never>);
|
|
5
|
-
type Props<TValue extends unknown, TKey extends AminoStorageKey> = {
|
|
6
|
-
type: StorageType;
|
|
7
|
-
key: TKey;
|
|
8
|
-
/**
|
|
9
|
-
* @param json - If true, the value will be set/parsed as JSON
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
json?: boolean;
|
|
5
|
+
type Props<TValue extends unknown, TKey extends AminoStorageKey> = StorageProps<TValue, TKey> & {
|
|
13
6
|
defaultValue: TValue;
|
|
14
7
|
};
|
|
15
8
|
type Return<T> = [value: T, setValue: (value: T) => void];
|
|
16
|
-
export declare const useStorage: <TValue extends unknown, TKey extends AminoStorageKey = AminoStorageKey>({ defaultValue, key, type,
|
|
9
|
+
export declare const useStorage: <TValue extends unknown, TKey extends AminoStorageKey = AminoStorageKey>({ defaultValue, json, key, type, }: Props<TValue, TKey>) => Return<TValue>;
|
|
17
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../storage.js"),r=require("./useSwr.js");require("swr");exports.useStorage=function(t){var u=t.defaultValue,n=t.
|
|
1
|
+
"use strict";var e=require("../storage.js"),r=require("./useSwr.js");require("swr");exports.useStorage=function(t){var u=t.defaultValue,n=t.json,s=t.key,a=t.type,o=r.useSwr(s,(function(){return e.getStorageItem({type:a,key:s,json:n})||null})).data;return[null!=o?o:u,function(r){return e.setStorageItem({type:a,key:s,value:r,json:n})}]};
|
package/utils/storage.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import type { Schema } from 'zod';
|
|
1
2
|
export type StorageType = 'session' | 'local';
|
|
2
|
-
export type StorageProps = {
|
|
3
|
+
export type StorageProps<Value, Key extends string = string> = {
|
|
3
4
|
type: StorageType;
|
|
4
|
-
key:
|
|
5
|
+
key: Key;
|
|
5
6
|
/**
|
|
6
7
|
* @param json - If true, the value will be set/parsed as JSON
|
|
7
|
-
*
|
|
8
|
+
* Set the schema for runtime validation of values.
|
|
9
|
+
* @default undefined
|
|
8
10
|
*/
|
|
9
|
-
json?:
|
|
11
|
+
json?: {
|
|
12
|
+
schema: Schema<Value>;
|
|
13
|
+
};
|
|
10
14
|
};
|
|
11
|
-
type SetProps<Value> = StorageProps & {
|
|
15
|
+
type SetProps<Value> = StorageProps<Value> & {
|
|
12
16
|
value: Value;
|
|
13
17
|
};
|
|
14
|
-
export declare const getStorageItem: <Value extends unknown>({ type, key, json, }: StorageProps) => Value | null;
|
|
18
|
+
export declare const getStorageItem: <Value extends unknown>({ type, key, json, }: StorageProps<Value, string>) => Value | null;
|
|
15
19
|
export declare const setStorageItem: <Value extends unknown>({ type, key, json, value, }: SetProps<Value>) => void;
|
|
16
20
|
export {};
|
package/utils/storage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("swr");exports.getStorageItem=function(e){var t=e.type,r=e.key,s=e.json,
|
|
1
|
+
"use strict";var e=require("swr");exports.getStorageItem=function(e){var t=e.type,r=e.key,s=e.json,a=("session"===t?sessionStorage:localStorage).getItem(r);if(!a)return null;if(s)try{var n=JSON.parse(a),o=s.schema.safeParse(n);return o.success?o.data:null}catch(e){return null}return a},exports.setStorageItem=function(t){var r=t.type,s=t.key,a=t.json,n=t.value,o="session"===r?sessionStorage:localStorage,u=a?JSON.stringify(n):String(n);o.setItem(s,u),e.mutate(s,n)};
|