@minutemailer/kit 1.0.3 → 1.0.5

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.
Files changed (63) hide show
  1. package/components/ui/alert.js +1 -1
  2. package/components/ui/avatar.js +1 -1
  3. package/components/ui/button.js +1 -1
  4. package/components/ui/checkbox.js +1 -1
  5. package/components/ui/dropdown-menu.js +1 -1
  6. package/components/ui/input.js +1 -1
  7. package/components/ui/label.js +1 -1
  8. package/components/ui/separator.js +1 -1
  9. package/components/ui/sheet.js +1 -1
  10. package/components/ui/sidebar.d.ts +4 -4
  11. package/components/ui/sidebar.js +8 -8
  12. package/components/ui/skeleton.js +1 -1
  13. package/components/ui/tooltip.js +1 -1
  14. package/icons/index.js +129 -261
  15. package/package.json +19 -21
  16. package/state/index.js +52 -64
  17. package/store/index.js +3 -6
  18. package/store/useSelector.d.ts +1 -1
  19. package/utils/index.js +6 -15
  20. package/icons/index.js.map +0 -7
  21. package/state/index.js.map +0 -7
  22. package/state/index.test.d.ts +0 -1
  23. package/state/index.test.js +0 -126
  24. package/store/index.js.map +0 -7
  25. package/store/store.test.d.ts +0 -12
  26. package/store/store.test.js +0 -51
  27. package/stories/Alert.stories.d.ts +0 -12
  28. package/stories/Alert.stories.js +0 -29
  29. package/stories/Button.stories.d.ts +0 -17
  30. package/stories/Button.stories.js +0 -61
  31. package/stories/Checkbox.stories.d.ts +0 -14
  32. package/stories/Checkbox.stories.js +0 -37
  33. package/stories/Input.stories.d.ts +0 -14
  34. package/stories/Input.stories.js +0 -31
  35. package/stories/Label.stories.d.ts +0 -9
  36. package/stories/Label.stories.js +0 -12
  37. package/stories/Separator.stories.d.ts +0 -10
  38. package/stories/Separator.stories.js +0 -13
  39. package/stories/Sidebar.stories.d.ts +0 -9
  40. package/stories/Sidebar.stories.js +0 -53
  41. package/stories/Skeleton.stories.d.ts +0 -9
  42. package/stories/Skeleton.stories.js +0 -10
  43. package/stories/Sonner.stories.d.ts +0 -11
  44. package/stories/Sonner.stories.js +0 -22
  45. package/stories/Todo.d.ts +0 -1
  46. package/stories/Todo.js +0 -75
  47. package/stories/Tooltip.stories.d.ts +0 -9
  48. package/stories/Tooltip.stories.js +0 -11
  49. package/stories/TrafficLights.d.ts +0 -3
  50. package/stories/TrafficLights.js +0 -37
  51. package/utils/capitalize/index.test.d.ts +0 -1
  52. package/utils/capitalize/index.test.js +0 -10
  53. package/utils/choice/index.test.d.ts +0 -1
  54. package/utils/choice/index.test.js +0 -21
  55. package/utils/index.js.map +0 -7
  56. package/utils/objToQuery/index.test.d.ts +0 -1
  57. package/utils/objToQuery/index.test.js +0 -17
  58. package/utils/replacePlaceholders/index.test.d.ts +0 -1
  59. package/utils/replacePlaceholders/index.test.js +0 -19
  60. package/utils/strToDate/index.test.d.ts +0 -1
  61. package/utils/strToDate/index.test.js +0 -45
  62. package/utils/zeroPad/index.test.d.ts +0 -1
  63. package/utils/zeroPad/index.test.js +0 -12
package/state/index.js CHANGED
@@ -1,65 +1,53 @@
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(
52
- () => setCurrentContext(selector(context))
53
- );
54
- }, []);
55
- return currentContext;
56
- },
57
- getContext() {
58
- return context;
59
- }
60
- };
1
+ import { useEffect, useState } from 'react';
2
+ export function createMachine(transitions, actions, initialContext, initialState = 'IDLE') {
3
+ const listeners = 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(`Machine transition: ${state} -> ${nextState} (${action}, ${input})`);
24
+ const previousState = state;
25
+ if (actions[action]) {
26
+ context = actions[action].call(this, context, input) || context;
27
+ }
28
+ state = nextState;
29
+ listeners.forEach((listener) => listener(state, previousState, context));
30
+ },
31
+ can(action) {
32
+ const transition = transitions[state];
33
+ return !!transition.on[action];
34
+ },
35
+ useCurrentState() {
36
+ const [currentState, setCurrentState] = useState(state);
37
+ useEffect(() => {
38
+ return this.subscribe(() => setCurrentState(state));
39
+ }, []);
40
+ return currentState;
41
+ },
42
+ useCurrentContext(selector) {
43
+ const [currentContext, setCurrentContext] = useState(() => selector(context));
44
+ useEffect(() => {
45
+ return this.subscribe(() => setCurrentContext(selector(context)));
46
+ }, []);
47
+ return currentContext;
48
+ },
49
+ getContext() {
50
+ return context;
51
+ },
52
+ };
61
53
  }
62
- export {
63
- createMachine
64
- };
65
- //# sourceMappingURL=index.js.map
package/store/index.js CHANGED
@@ -1,6 +1,3 @@
1
- export * from "./store";
2
- import { useSelector } from "./useSelector";
3
- export {
4
- useSelector
5
- };
6
- //# sourceMappingURL=index.js.map
1
+ // Reexport all from the store modules
2
+ export * from './store';
3
+ export { useSelector } from './useSelector';
@@ -1,2 +1,2 @@
1
- import type { Store } from '@/store';
1
+ import type { Store } from '../store';
2
2
  export declare function useSelector<T, S>(store: Store<T>, selector: (state: T) => S): S;
package/utils/index.js CHANGED
@@ -1,15 +1,6 @@
1
- import { default as default2 } from "./strToDate";
2
- import { default as default3 } from "./zeroPad";
3
- import { default as default4 } from "./replacePlaceholders";
4
- import { default as default5 } from "./choice";
5
- import { default as default6 } from "./capitalize";
6
- import { default as default7 } from "./objToQuery";
7
- export {
8
- default6 as capitalize,
9
- default5 as choice,
10
- default7 as objToQuery,
11
- default4 as replacePlaceholders,
12
- default2 as strToDate,
13
- default3 as zeroPad
14
- };
15
- //# sourceMappingURL=index.js.map
1
+ export { default as strToDate } from './strToDate';
2
+ export { default as zeroPad } from './zeroPad';
3
+ export { default as replacePlaceholders } from './replacePlaceholders';
4
+ export { default as choice } from './choice';
5
+ export { default as capitalize } from './capitalize';
6
+ export { default as objToQuery } from './objToQuery';
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/icons/index.ts"],
4
- "sourcesContent": ["export { default as Alert } from './Alert';\nexport { default as AlertFilled } from './AlertFilled';\nexport { default as Arrow } from './Arrow';\nexport { default as ArrowDown } from './ArrowDown';\nexport { default as Attachment } from './Attachment';\nexport { default as Automate } from './Automate';\nexport { default as Bold } from './Bold';\nexport { default as BorderBottom } from './BorderBottom';\nexport { default as BorderLeft } from './BorderLeft';\nexport { default as BorderRight } from './BorderRight';\nexport { default as BorderTop } from './BorderTop';\nexport { default as BottomAlign } from './BottomAlign';\nexport { default as BottomLeftCorner } from './BottomLeftCorner';\nexport { default as BottomRightCorner } from './BottomRightCorner';\nexport { default as Button } from './Button';\nexport { default as Calendar } from './Calendar';\nexport { default as Center } from './Center';\nexport { default as Check } from './Check';\nexport { default as CheckFilled } from './CheckFilled';\nexport { default as Checkmark } from './Checkmark';\nexport { default as Chevron } from './Chevron';\nexport { default as ChevronDown } from './ChevronDown';\nexport { default as ChevronLeft } from './ChevronLeft';\nexport { default as ChevronUp } from './ChevronUp';\nexport { default as Close } from './Close';\nexport { default as CloseBold } from './CloseBold';\nexport { default as CloseCircle } from './CloseCircle';\nexport { default as Column1 } from './Column1';\nexport { default as Column12 } from './Column12';\nexport { default as Column13 } from './Column13';\nexport { default as Column2 } from './Column2';\nexport { default as Column21 } from './Column21';\nexport { default as Column3 } from './Column3';\nexport { default as Column31 } from './Column31';\nexport { default as Column4 } from './Column4';\nexport { default as Contacts } from './Contacts';\nexport { default as Crop } from './Crop';\nexport { default as Divider } from './Divider';\nexport { default as Download } from './Download';\nexport { default as Duplicate } from './Duplicate';\nexport { default as Email } from './Email';\nexport { default as Feedback } from './Feedback';\nexport { default as File } from './File';\nexport { default as Filter } from './Filter';\nexport { default as Flip } from './Flip';\nexport { default as Flop } from './Flop';\nexport { default as Form } from './Form';\nexport { default as Gift } from './Gift';\nexport { default as HeartRound } from './HeartRound';\nexport { default as Home } from './Home';\nexport { default as HorisontalCenter } from './HorisontalCenter';\nexport { default as Image } from './Image';\nexport { default as Images } from './Images';\nexport { default as Info } from './Info';\nexport { default as Integrations } from './Integrations';\nexport { default as Italics } from './Italics';\nexport { default as Justified } from './Justified';\nexport { default as LeftAlign } from './LeftAlign';\nexport { default as Left } from './Left';\nexport { default as LetterSpacing } from './LetterSpacing';\nexport { default as LineHeight } from './LineHeight';\nexport { default as LineThickness } from './LineThickness';\nexport { default as Link } from './Link';\nexport { default as List } from './List';\nexport { default as ListMenu } from './ListMenu';\nexport { default as ListNumbered } from './ListNumbered';\nexport { default as Location } from './Location';\nexport { default as LockChain } from './LockChain';\nexport { default as Locked } from './Locked';\nexport { default as Logo } from './Logo';\nexport { default as Logout } from './Logout';\nexport { default as Lowercase } from './Lowercase';\nexport { default as Magic } from './Magic';\nexport { default as MarginBottom } from './MarginBottom';\nexport { default as MarginLeft } from './MarginLeft';\nexport { default as MarginRight } from './MarginRight';\nexport { default as MarginTop } from './MarginTop';\nexport { default as Menu } from './Menu';\nexport { default as Minus } from './Minus';\nexport { default as MinusBold } from './MinusBold';\nexport { default as More } from './More';\nexport { default as Move } from './Move';\nexport { default as MoveDirections } from './MoveDirections';\nexport { default as MoveVertical } from './MoveVertical';\nexport { default as Openclose } from './Openclose';\nexport { default as Pen } from './Pen';\nexport { default as Phone } from './Phone';\nexport { default as Plane } from './Plane';\nexport { default as PlaneOutline } from './PlaneOutline';\nexport { default as Plus } from './Plus';\nexport { default as PlusBold } from './PlusBold';\nexport { default as PlusCircle } from './PlusCircle';\nexport { default as Result } from './Result';\nexport { default as RightAlign } from './RightAlign';\nexport { default as Right } from './Right';\nexport { default as Rotate } from './Rotate';\nexport { default as Search } from './Search';\nexport { default as Settings } from './Settings';\nexport { default as Sms } from './Sms';\nexport { default as Spacing } from './Spacing';\nexport { default as Spinner } from './Spinner';\nexport { default as StarFilled } from './StarFilled';\nexport { default as StarOutline } from './StarOutline';\nexport { default as Stars } from './Stars';\nexport { default as Stats } from './Stats';\nexport { default as Stop } from './Stop';\nexport { default as Strikethrough } from './Strikethrough';\nexport { default as Support } from './Support';\nexport { default as Tags } from './Tags';\nexport { default as Team } from './Team';\nexport { default as Text } from './Text';\nexport { default as Thumbsdown } from './Thumbsdown';\nexport { default as Thumbsup } from './Thumbsup';\nexport { default as TopAlign } from './TopAlign';\nexport { default as TopLeftCorner } from './TopLeftCorner';\nexport { default as TopRightCorner } from './TopRightCorner';\nexport { default as Trash } from './Trash';\nexport { default as Underscore } from './Underscore';\nexport { default as Unlink } from './Unlink';\nexport { default as UnlockChain } from './UnlockChain';\nexport { default as Unlocked } from './Unlocked';\nexport { default as Upload } from './Upload';\nexport { default as Uppercase } from './Uppercase';\nexport { default as VerticalCenter } from './VerticalCenter';\nexport { default as Video } from './Video';\nexport { default as Warning } from './Warning';\nexport { default as Website } from './Website';\nexport { default as Width } from './Width';\nexport { default as Write } from './Write';\n"],
5
- "mappings": "AAAA,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAwB;AACjC,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAA+B;AACxC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAmC;AAC5C,SAAoB,WAAXA,iBAAoC;AAC7C,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAAwB;AACjC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAAwB;AACjC,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA4B;AACrC,SA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B,WAAXA,kBAA0B;AACnC,SAAoB,WAAXA,kBAA0B;AACnC,SAAoB,WAAXA,kBAAwB;AACjC,SAAoB,WAAXA,kBAAwB;",
6
- "names": ["default"]
7
- }
@@ -1,7 +0,0 @@
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>(\n selector: (context: TContext) => TSelected,\n ) => 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> = (\n state: string,\n previousState: string,\n context: TContext,\n) => 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>(\n selector: (context: TContext) => TSelected,\n ): TSelected {\n const [currentContext, setCurrentContext] = useState<TSelected>(\n () => selector(context),\n );\n\n useEffect(() => {\n return this.subscribe(() =>\n setCurrentContext(selector(context)),\n );\n }, []);\n\n return currentContext;\n },\n\n getContext(): TContext {\n return context;\n },\n };\n}\n"],
5
- "mappings": "AAAA,SAAS,WAAW,gBAAgB;AAgC7B,SAAS,cACZ,aACA,SACA,gBACA,eAAe,QACO;AACtB,QAAM,YAAY,oBAAI,IAA2B;AACjD,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,SAAO;AAAA,IACH,UAAU,UAA6C;AACnD,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,kBACI,UACS;AACT,YAAM,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,QACxC,MAAM,SAAS,OAAO;AAAA,MAC1B;AAEA,gBAAU,MAAM;AACZ,eAAO,KAAK;AAAA,UAAU,MAClB,kBAAkB,SAAS,OAAO,CAAC;AAAA,QACvC;AAAA,MACJ,GAAG,CAAC,CAAC;AAEL,aAAO;AAAA,IACX;AAAA,IAEA,aAAuB;AACnB,aAAO;AAAA,IACX;AAAA,EACJ;AACJ;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,126 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { createMachine } from './';
3
- // Mock timers for testing timeouts
4
- vi.useFakeTimers();
5
- describe('State Machine', () => {
6
- // Test machine setup
7
- const transitions = {
8
- STATE1: { on: { NEXT: 'STATE2', RESET: 'STATE1' } },
9
- STATE2: { on: { NEXT: 'STATE3', RESET: 'STATE1' } },
10
- STATE3: { on: { NEXT: 'STATE1', RESET: 'STATE1' } },
11
- };
12
- const actions = {
13
- NEXT: (context) => ({
14
- count: context.count + 1,
15
- }),
16
- RESET: () => ({ count: 0 }),
17
- };
18
- let machine;
19
- beforeEach(() => {
20
- machine = createMachine(transitions, actions, { count: 0 }, 'STATE1');
21
- });
22
- it('should initialize with the correct context', () => {
23
- expect(machine.getContext()).toEqual({ count: 0 });
24
- });
25
- it('should transition to the next state when action is triggered', () => {
26
- let currentState = 'STATE1';
27
- // Subscribe to state changes
28
- const unsubscribe = machine['subscribe']((newState) => {
29
- currentState = newState;
30
- });
31
- machine.action('NEXT');
32
- expect(currentState).toBe('STATE2');
33
- unsubscribe();
34
- });
35
- it('should update context when action is triggered', () => {
36
- let count = 0;
37
- // Subscribe to context changes
38
- const unsubscribe = machine['subscribe']((_, __, context) => {
39
- count = context.count;
40
- });
41
- machine.action('NEXT');
42
- expect(count).toBe(1);
43
- unsubscribe();
44
- });
45
- it('should check if an action is valid for the current state', () => {
46
- expect(machine.can('NEXT')).toBe(true);
47
- expect(machine.can('INVALID')).toBe(false);
48
- machine.action('NEXT');
49
- // Now in STATE2
50
- expect(machine.can('NEXT')).toBe(true);
51
- expect(machine.can('RESET')).toBe(true);
52
- });
53
- it('should warn when invalid transition is attempted', () => {
54
- const consoleSpy = vi
55
- .spyOn(console, 'warn')
56
- .mockImplementation(() => { });
57
- machine.action('INVALID_ACTION');
58
- expect(consoleSpy).toHaveBeenCalledWith('Invalid transition', 'STATE1', 'INVALID_ACTION');
59
- consoleSpy.mockRestore();
60
- });
61
- it('should reset to initial state when destroy is called', () => {
62
- let currentState = 'STATE1';
63
- let currentContext = { count: 0 };
64
- const unsubscribe = machine['subscribe']((newState, _, context) => {
65
- currentState = newState;
66
- currentContext = context;
67
- });
68
- machine.action('NEXT');
69
- machine.action('NEXT');
70
- // Now in STATE3 with count 2
71
- expect(currentState).toBe('STATE3');
72
- expect(currentContext.count).toBe(2);
73
- machine.destroy();
74
- // Direct check with getContext() since destroy clears subscribers
75
- expect(machine.getContext()).toEqual({ count: 0 });
76
- unsubscribe();
77
- });
78
- it('should log transitions to console', () => {
79
- const consoleSpy = vi
80
- .spyOn(console, 'log')
81
- .mockImplementation(() => { });
82
- machine.action('NEXT', 'test-input');
83
- expect(consoleSpy).toHaveBeenCalledWith('Machine transition: STATE1 -> STATE2 (NEXT, test-input)');
84
- consoleSpy.mockRestore();
85
- });
86
- it('should notify subscribers when state changes', () => {
87
- const mockListener = vi.fn();
88
- const unsubscribe = machine['subscribe'](mockListener);
89
- machine.action('NEXT');
90
- expect(mockListener).toHaveBeenCalledWith('STATE2', 'STATE1', {
91
- count: 1,
92
- });
93
- // Test unsubscribe
94
- unsubscribe();
95
- machine.action('NEXT');
96
- // Should have been called only once despite two actions
97
- expect(mockListener).toHaveBeenCalledTimes(1);
98
- });
99
- it('should handle context updates with nested objects', () => {
100
- const complexMachine = createMachine({ STATE1: { on: { UPDATE: 'STATE1' } } }, {
101
- UPDATE: (ctx) => ({
102
- ...ctx,
103
- user: { ...ctx.user, age: ctx.user.age + 1 },
104
- }),
105
- }, { user: { name: 'Test', age: 30 }, settings: { theme: 'dark' } }, 'STATE1');
106
- let name = '';
107
- let age = 0;
108
- let theme = '';
109
- const unsubscribe = complexMachine['subscribe']((_, __, context) => {
110
- name = context.user.name;
111
- age = context.user.age;
112
- theme = context.settings.theme;
113
- });
114
- // Initial values from initialization
115
- expect(complexMachine.getContext()).toEqual({
116
- user: { name: 'Test', age: 30 },
117
- settings: { theme: 'dark' },
118
- });
119
- complexMachine.action('UPDATE');
120
- // Only age should change
121
- expect(name).toBe('Test');
122
- expect(age).toBe(31);
123
- expect(theme).toBe('dark');
124
- unsubscribe();
125
- });
126
- });
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/index.ts"],
4
- "sourcesContent": ["// Reexport all from the store modules\nexport * from './store';\nexport { useSelector } from './useSelector';\n"],
5
- "mappings": "AACA,cAAc;AACd,SAAS,mBAAmB;",
6
- "names": []
7
- }
@@ -1,12 +0,0 @@
1
- import { Store } from './store';
2
- interface TestStore {
3
- todos: Array<{
4
- id: string;
5
- text: string;
6
- completed: boolean;
7
- }>;
8
- completed: number;
9
- total: number;
10
- }
11
- export declare function createStoreInstance(): Store<TestStore>;
12
- export {};
@@ -1,51 +0,0 @@
1
- import { assert, assertType, test } from 'vitest';
2
- import { createStore } from './store';
3
- const initialState = {
4
- todos: [],
5
- completed: 0,
6
- total: 0,
7
- };
8
- const uniqueId = () => Math.random().toString(36).substring(2, 15);
9
- const reducer = (state, action) => {
10
- if (action.type === 'ADD_TODO') {
11
- return {
12
- ...state,
13
- todos: [
14
- ...state.todos,
15
- { id: uniqueId(), text: action.value, completed: false },
16
- ],
17
- total: state.total + 1,
18
- };
19
- }
20
- if (action.type === 'COMPLETE_TODO') {
21
- return {
22
- ...state,
23
- todos: state.todos.map((todo) => todo.id === action.value ? { ...todo, completed: true } : todo),
24
- completed: state.completed + 1,
25
- };
26
- }
27
- if (action.type === 'UNCOMPLETE_TODO') {
28
- return {
29
- ...state,
30
- todos: state.todos.map((todo) => todo.id === action.value ? { ...todo, completed: false } : todo),
31
- completed: state.completed - 1,
32
- };
33
- }
34
- return state;
35
- };
36
- export function createStoreInstance() {
37
- return createStore('todos', initialState, reducer, () => true, () => { });
38
- }
39
- test('createStore returns store', () => {
40
- const store = createStoreInstance();
41
- assertType(store);
42
- });
43
- test('store.getState returns state', () => {
44
- const store = createStoreInstance();
45
- assert.equal(store.getState(), initialState);
46
- });
47
- test('store.select returns state', () => {
48
- const store = createStoreInstance();
49
- const scope = store.select(({ total }) => total);
50
- assert.equal(scope, initialState.total);
51
- });
@@ -1,12 +0,0 @@
1
- import type { StoryObj } from '@storybook/react-vite';
2
- import { Alert } from '@/components/ui/alert';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Alert;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Default: Story;
10
- export declare const Destructive: Story;
11
- export declare const WithoutIcon: Story;
12
- export declare const WithoutTitle: Story;
@@ -1,29 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
3
- import { AlertTriangle, Info, Trash } from 'lucide-react';
4
- const meta = {
5
- title: 'WIP/Alert',
6
- component: Alert,
7
- };
8
- export default meta;
9
- export const Default = {
10
- args: {
11
- children: (_jsxs(_Fragment, { children: [_jsx(Info, {}), _jsx(AlertTitle, { children: "Heads up!" }), _jsx(AlertDescription, { children: "This is a default alert \u2014 check it out!" })] })),
12
- },
13
- };
14
- export const Destructive = {
15
- args: {
16
- variant: 'destructive',
17
- children: (_jsxs(_Fragment, { children: [_jsx(AlertTriangle, {}), _jsx(AlertTitle, { children: "Something went wrong" }), _jsx(AlertDescription, { children: "Your action could not be completed. Please try again." })] })),
18
- },
19
- };
20
- export const WithoutIcon = {
21
- args: {
22
- children: (_jsxs(_Fragment, { children: [_jsx(AlertTitle, { children: "Notice" }), _jsx(AlertDescription, { children: "This alert renders without an icon and still aligns nicely." })] })),
23
- },
24
- };
25
- export const WithoutTitle = {
26
- args: {
27
- children: (_jsxs(_Fragment, { children: [_jsx(Trash, {}), _jsx(AlertTitle, { children: "This Alert has a title and an icon. No description." })] })),
28
- },
29
- };
@@ -1,17 +0,0 @@
1
- import type { StoryObj } from '@storybook/react-vite';
2
- import { Button } from '@/components/ui/button';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Button;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Primary: Story;
10
- export declare const Secondary: Story;
11
- export declare const Destructive: Story;
12
- export declare const Outline: Story;
13
- export declare const Ghost: Story;
14
- export declare const Link: Story;
15
- export declare const Small: Story;
16
- export declare const Large: Story;
17
- export declare const Icon: Story;
@@ -1,61 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Button } from '@/components/ui/button';
3
- import { Plus } from 'lucide-react';
4
- const meta = {
5
- title: 'UI/Button',
6
- component: Button,
7
- };
8
- export default meta;
9
- export const Primary = {
10
- args: {
11
- children: 'Button',
12
- },
13
- };
14
- export const Secondary = {
15
- args: {
16
- variant: 'secondary',
17
- children: 'Button',
18
- },
19
- };
20
- export const Destructive = {
21
- args: {
22
- variant: 'destructive',
23
- children: 'Button',
24
- },
25
- };
26
- export const Outline = {
27
- args: {
28
- variant: 'outline',
29
- children: 'Button',
30
- },
31
- };
32
- export const Ghost = {
33
- args: {
34
- variant: 'ghost',
35
- children: 'Button',
36
- },
37
- };
38
- export const Link = {
39
- args: {
40
- variant: 'link',
41
- children: 'Button',
42
- },
43
- };
44
- export const Small = {
45
- args: {
46
- size: 'sm',
47
- children: 'Button',
48
- },
49
- };
50
- export const Large = {
51
- args: {
52
- size: 'lg',
53
- children: 'Button',
54
- },
55
- };
56
- export const Icon = {
57
- args: {
58
- size: 'icon',
59
- children: _jsx(Plus, {}),
60
- },
61
- };
@@ -1,14 +0,0 @@
1
- import type { StoryObj } from '@storybook/react-vite';
2
- import { Checkbox } from '@/components/ui/checkbox';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Checkbox;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Default: Story;
10
- export declare const Checked: Story;
11
- export declare const Disabled: Story;
12
- export declare const DisabledChecked: Story;
13
- export declare const WithLabel: Story;
14
- export declare const Controlled: Story;
@@ -1,37 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { Checkbox } from '@/components/ui/checkbox';
4
- import { Label } from '@/components/ui/label';
5
- const meta = {
6
- title: 'WIP/Checkbox',
7
- component: Checkbox,
8
- };
9
- export default meta;
10
- export const Default = {
11
- args: {},
12
- };
13
- export const Checked = {
14
- args: {
15
- defaultChecked: true,
16
- },
17
- };
18
- export const Disabled = {
19
- args: {
20
- disabled: true,
21
- },
22
- };
23
- export const DisabledChecked = {
24
- args: {
25
- disabled: true,
26
- defaultChecked: true,
27
- },
28
- };
29
- export const WithLabel = {
30
- render: (args) => (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Checkbox, { ...args, id: "terms" }), _jsx(Label, { htmlFor: "terms", children: "Accept terms and conditions" })] })),
31
- };
32
- export const Controlled = {
33
- render: (args) => {
34
- const [checked, setChecked] = React.useState(false);
35
- return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Checkbox, { ...args, checked: checked, onCheckedChange: (v) => setChecked(Boolean(v)), "aria-label": checked ? 'Checked' : 'Unchecked', id: "controlled" }), _jsx(Label, { htmlFor: "controlled", children: checked ? 'Checked' : 'Unchecked' })] }));
36
- },
37
- };
@@ -1,14 +0,0 @@
1
- import type { StoryObj } from '@storybook/react-vite';
2
- import { Input } from '@/components/ui/input';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Input;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Default: Story;
10
- export declare const Disabled: Story;
11
- export declare const File: Story;
12
- export declare const WithPlaceholder: Story;
13
- export declare const WithLabel: Story;
14
- export declare const WithButton: Story;
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Label } from '@/components/ui/label';
3
- import { Input } from '@/components/ui/input';
4
- import { Button } from '@/components/ui/button';
5
- const meta = {
6
- title: 'WIP/Input',
7
- component: Input,
8
- };
9
- export default meta;
10
- export const Default = {
11
- args: {},
12
- };
13
- export const Disabled = {
14
- args: {
15
- disabled: true,
16
- },
17
- };
18
- export const File = {
19
- render: (args) => (_jsxs("div", { className: "grid w-full max-w-sm items-center gap-3", children: [_jsx(Label, { htmlFor: "picture", children: "Picture" }), _jsx(Input, { ...args, type: "file", id: "picture" })] })),
20
- };
21
- export const WithPlaceholder = {
22
- args: {
23
- placeholder: 'Type something...',
24
- },
25
- };
26
- export const WithLabel = {
27
- render: (args) => (_jsxs("div", { className: "grid w-full max-w-sm items-center gap-3", children: [_jsx(Label, { htmlFor: "email", children: "Email" }), _jsx(Input, { ...args, id: "email" })] })),
28
- };
29
- export const WithButton = {
30
- render: (args) => (_jsxs("div", { className: "flex w-full max-w-sm items-center gap-2", children: [_jsx(Input, { type: "email", placeholder: "Email" }), _jsx(Button, { type: "button", variant: "outline", children: "Subscribe" })] })),
31
- };
@@ -1,9 +0,0 @@
1
- import type { StoryObj } from '@storybook/react-vite';
2
- import { Label } from '@/components/ui/label';
3
- declare const meta: {
4
- title: string;
5
- component: typeof Label;
6
- };
7
- export default meta;
8
- type Story = StoryObj<typeof meta>;
9
- export declare const Default: Story;