@minutemailer/kit 0.1.2 → 0.1.4
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.
- package/icons/AlertFilled.js +1 -1
- package/icons/Images.js +1 -1
- package/package.json +3 -3
- package/state/index.js +62 -52
- package/state/index.js.map +7 -0
package/icons/AlertFilled.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
const SvgAlertFilled = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", ...props, children: [_jsx("path", { fill: "
|
|
2
|
+
const SvgAlertFilled = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", ...props, children: [_jsx("path", { fill: "currentColor", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M14.347 2.882a.75.75 0 0 0 .47.589c3.079 1.199 5.303 4.307 5.303 7.983v6c0 .948.319 1.829.857 2.523H3.022a4.1 4.1 0 0 0 .858-2.523v-6c0-3.677 2.22-6.785 5.3-7.983a.75.75 0 0 0 .47-.59C9.831 1.65 10.838.75 12 .75c1.161 0 2.165.898 2.347 2.132" }), _jsx("mask", { id: "alert_filled_svg__a", fill: "#fff", children: _jsx("path", { fillRule: "evenodd", d: "M14.609 20.727c0 1.807-1.403 3.272-3.13 3.272-1.732 0-3.131-1.465-3.131-3.272", clipRule: "evenodd" }) }), _jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M14.609 20.727c0 1.807-1.403 3.272-3.13 3.272-1.732 0-3.131-1.465-3.131-3.272", clipRule: "evenodd" }), _jsx("path", { fill: "currentColor", d: "M16.109 20.727a1.5 1.5 0 1 0-3 0zm-6.261 0a1.5 1.5 0 1 0-3 0zm3.26 0c0 1.042-.792 1.772-1.63 1.772v3c2.618 0 4.63-2.2 4.63-4.772zm-1.63 1.772c-.84 0-1.63-.729-1.63-1.772h-3c0 2.571 2.008 4.772 4.63 4.772z", mask: "url(#alert_filled_svg__a)" })] }));
|
|
3
3
|
export default SvgAlertFilled;
|
package/icons/Images.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
const SvgImages = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 26 26", ...props, children: [_jsx("path", { stroke: "
|
|
2
|
+
const SvgImages = (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 26 26", ...props, children: [_jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", d: "M25 6.217V23a2 2 0 0 1-2 2H6.217" }), _jsx("path", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", d: "M22.913 3.087v17.826a2 2 0 0 1-2 2H3.087" }), _jsx("path", { stroke: "currentColor", strokeLinejoin: "round", strokeWidth: 1.5, d: "M20.826 18.826a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h15.826a2 2 0 0 1 2 2z", clipRule: "evenodd" }), _jsx("path", { stroke: "currentColor", strokeLinejoin: "round", d: "m18.217 16.652-3.13-8.348-4.174 6.261-2.609-3.13-3.13 5.217" }), _jsx("path", { stroke: "currentColor", strokeLinejoin: "round", d: "M8.304 5.696a1.565 1.565 0 1 1-3.13 0 1.565 1.565 0 0 1 3.13 0Z", clipRule: "evenodd" }), _jsx("path", { stroke: "currentColor", strokeLinejoin: "round", d: "M20.826 16.652H1" })] }));
|
|
3
3
|
export default SvgImages;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minutemailer/kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Minutemailer UI Kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Minutemailer",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
"./utils": "./utils/index.js",
|
|
10
10
|
"./icons": "./icons/index.js",
|
|
11
|
-
"./store": "./store/index.js"
|
|
11
|
+
"./store": "./store/index.js",
|
|
12
|
+
"./state": "./state/index.js"
|
|
12
13
|
},
|
|
13
14
|
"sideEffects": false,
|
|
14
15
|
"scripts": {
|
|
@@ -35,7 +36,6 @@
|
|
|
35
36
|
"@storybook/test": "^8.6.2",
|
|
36
37
|
"@storybook/theming": "^8.6.3",
|
|
37
38
|
"@svgr/cli": "^8.1.0",
|
|
38
|
-
"@testing-library/react": "^16.2.0",
|
|
39
39
|
"@vitest/coverage-v8": "^3.0.7",
|
|
40
40
|
"esbuild": "^0.25.0",
|
|
41
41
|
"react": "^18.0.0",
|
package/state/index.js
CHANGED
|
@@ -1,53 +1,63 @@
|
|
|
1
|
-
import { useEffect, useState } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
function createMachine(transitions, actions, initialContext, initialState = "IDLE") {
|
|
3
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4
|
+
let state = initialState;
|
|
5
|
+
let context = initialContext;
|
|
6
|
+
return {
|
|
7
|
+
subscribe(listener) {
|
|
8
|
+
listeners.add(listener);
|
|
9
|
+
return () => listeners.delete(listener);
|
|
10
|
+
},
|
|
11
|
+
destroy() {
|
|
12
|
+
listeners.clear();
|
|
13
|
+
state = initialState;
|
|
14
|
+
context = initialContext;
|
|
15
|
+
},
|
|
16
|
+
action(action, input) {
|
|
17
|
+
const transition = transitions[state];
|
|
18
|
+
const nextState = transition.on[action];
|
|
19
|
+
if (!nextState) {
|
|
20
|
+
console.warn("Invalid transition", state, action);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(
|
|
24
|
+
`Machine transition: ${state} -> ${nextState} (${action}, ${input})`
|
|
25
|
+
);
|
|
26
|
+
const previousState = state;
|
|
27
|
+
if (actions[action]) {
|
|
28
|
+
context = actions[action].call(this, context, input) || context;
|
|
29
|
+
}
|
|
30
|
+
state = nextState;
|
|
31
|
+
listeners.forEach(
|
|
32
|
+
(listener) => listener(state, previousState, context)
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
can(action) {
|
|
36
|
+
const transition = transitions[state];
|
|
37
|
+
return !!transition.on[action];
|
|
38
|
+
},
|
|
39
|
+
useCurrentState() {
|
|
40
|
+
const [currentState, setCurrentState] = useState(state);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
return this.subscribe(() => setCurrentState(state));
|
|
43
|
+
}, []);
|
|
44
|
+
return currentState;
|
|
45
|
+
},
|
|
46
|
+
useCurrentContext(selector) {
|
|
47
|
+
const [currentContext, setCurrentContext] = useState(
|
|
48
|
+
() => selector(context)
|
|
49
|
+
);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
return this.subscribe(() => setCurrentContext(selector(context)));
|
|
52
|
+
}, []);
|
|
53
|
+
return currentContext;
|
|
54
|
+
},
|
|
55
|
+
getContext() {
|
|
56
|
+
return context;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
53
59
|
}
|
|
60
|
+
export {
|
|
61
|
+
createMachine
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/state/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState } from 'react';\n\ninterface StateMachine<TContext> {\n subscribe: (listener: StateChange<TContext>) => () => void;\n destroy: () => void;\n action: (action: string, input?: any) => void;\n can: (action: string) => boolean;\n useCurrentState: () => string;\n useCurrentContext: <TSelected = any>(selector: (context: TContext) => TSelected) => TSelected;\n getContext: () => TContext;\n}\n\ninterface Transitions {\n [state: string]: {\n on: {\n [action: string]: string;\n };\n };\n}\n\ninterface Actions {\n [action: string]: (context: any, input?: any) => any;\n}\n\ntype StateChange<TContext> = (state: string, previousState: string, context: TContext) => void;\n\nexport function createMachine<TContext = any>(\n transitions: Transitions,\n actions: Actions,\n initialContext: TContext,\n initialState = 'IDLE',\n): StateMachine<TContext> {\n const listeners = new Set<StateChange<TContext>>();\n let state = initialState;\n let context = initialContext;\n\n return {\n subscribe(listener: StateChange<TContext>): (() => void) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n\n destroy(): void {\n listeners.clear();\n state = initialState;\n context = initialContext;\n },\n\n action(action: string, input?: any): void {\n const transition = transitions[state];\n const nextState = transition.on[action];\n\n if (!nextState) {\n console.warn('Invalid transition', state, action);\n return;\n }\n\n console.log(\n `Machine transition: ${state} -> ${nextState} (${action}, ${input})`,\n );\n\n const previousState = state;\n\n if (actions[action]) {\n context = actions[action].call(this, context, input) || context;\n }\n\n state = nextState;\n listeners.forEach((listener) =>\n listener(state, previousState, context),\n );\n },\n\n can(action: string): boolean {\n const transition = transitions[state];\n return !!transition.on[action];\n },\n\n useCurrentState(): string {\n const [currentState, setCurrentState] = useState<string>(state);\n\n useEffect(() => {\n return this.subscribe(() => setCurrentState(state));\n }, []);\n\n return currentState;\n },\n\n useCurrentContext<TSelected = any>(selector: (context: TContext) => TSelected): TSelected {\n const [currentContext, setCurrentContext] = useState<TSelected>(() =>\n selector(context),\n );\n\n useEffect(() => {\n return this.subscribe(() => setCurrentContext(selector(context)));\n }, []);\n\n return currentContext;\n },\n\n getContext(): TContext {\n return context;\n },\n };\n}"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,gBAAgB;AA0B7B,SAAS,cACZ,aACA,SACA,gBACA,eAAe,QACO;AACtB,QAAM,YAAY,oBAAI,IAA2B;AACjD,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,SAAO;AAAA,IACH,UAAU,UAA+C;AACrD,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM,UAAU,OAAO,QAAQ;AAAA,IAC1C;AAAA,IAEA,UAAgB;AACZ,gBAAU,MAAM;AAChB,cAAQ;AACR,gBAAU;AAAA,IACd;AAAA,IAEA,OAAO,QAAgB,OAAmB;AACtC,YAAM,aAAa,YAAY,KAAK;AACpC,YAAM,YAAY,WAAW,GAAG,MAAM;AAEtC,UAAI,CAAC,WAAW;AACZ,gBAAQ,KAAK,sBAAsB,OAAO,MAAM;AAChD;AAAA,MACJ;AAEA,cAAQ;AAAA,QACJ,uBAAuB,KAAK,OAAO,SAAS,KAAK,MAAM,KAAK,KAAK;AAAA,MACrE;AAEA,YAAM,gBAAgB;AAEtB,UAAI,QAAQ,MAAM,GAAG;AACjB,kBAAU,QAAQ,MAAM,EAAE,KAAK,MAAM,SAAS,KAAK,KAAK;AAAA,MAC5D;AAEA,cAAQ;AACR,gBAAU;AAAA,QAAQ,CAAC,aACf,SAAS,OAAO,eAAe,OAAO;AAAA,MAC1C;AAAA,IACJ;AAAA,IAEA,IAAI,QAAyB;AACzB,YAAM,aAAa,YAAY,KAAK;AACpC,aAAO,CAAC,CAAC,WAAW,GAAG,MAAM;AAAA,IACjC;AAAA,IAEA,kBAA0B;AACtB,YAAM,CAAC,cAAc,eAAe,IAAI,SAAiB,KAAK;AAE9D,gBAAU,MAAM;AACZ,eAAO,KAAK,UAAU,MAAM,gBAAgB,KAAK,CAAC;AAAA,MACtD,GAAG,CAAC,CAAC;AAEL,aAAO;AAAA,IACX;AAAA,IAEA,kBAAmC,UAAuD;AACtF,YAAM,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,QAAoB,MAC5D,SAAS,OAAO;AAAA,MACpB;AAEA,gBAAU,MAAM;AACZ,eAAO,KAAK,UAAU,MAAM,kBAAkB,SAAS,OAAO,CAAC,CAAC;AAAA,MACpE,GAAG,CAAC,CAAC;AAEL,aAAO;AAAA,IACX;AAAA,IAEA,aAAuB;AACnB,aAAO;AAAA,IACX;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|