@smuikit/core 0.1.0
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/dist/chunk-3SIG5GVW.mjs +94 -0
- package/dist/chunk-CG7MB4D7.mjs +139 -0
- package/dist/chunk-DEYVI3GG.js +37 -0
- package/dist/chunk-ECS4ZLAD.mjs +94 -0
- package/dist/chunk-EQR2S6TY.js +97 -0
- package/dist/chunk-IRJ3PEU4.mjs +35 -0
- package/dist/chunk-JTKA5LGK.mjs +35 -0
- package/dist/chunk-KQF35W7O.mjs +32 -0
- package/dist/chunk-KWFE67IV.js +56 -0
- package/dist/chunk-O7JRMYZ5.js +97 -0
- package/dist/chunk-OLRCZXKS.js +34 -0
- package/dist/chunk-Y34GDQYY.js +142 -0
- package/dist/chunk-YFNMWGC7.mjs +54 -0
- package/dist/chunk-YTHNCP77.js +44 -0
- package/dist/create-machine-DsOUIlfe.d.mts +30 -0
- package/dist/create-machine-DsOUIlfe.d.ts +30 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +119 -0
- package/dist/index.mjs +46 -0
- package/dist/machines/button/index.d.mts +44 -0
- package/dist/machines/button/index.d.ts +44 -0
- package/dist/machines/button/index.js +16 -0
- package/dist/machines/button/index.mjs +3 -0
- package/dist/machines/card/index.d.mts +17 -0
- package/dist/machines/card/index.d.ts +17 -0
- package/dist/machines/card/index.js +10 -0
- package/dist/machines/card/index.mjs +1 -0
- package/dist/machines/input/index.d.mts +48 -0
- package/dist/machines/input/index.d.ts +48 -0
- package/dist/machines/input/index.js +16 -0
- package/dist/machines/input/index.mjs +3 -0
- package/dist/machines/modal/index.d.mts +44 -0
- package/dist/machines/modal/index.d.ts +44 -0
- package/dist/machines/modal/index.js +15 -0
- package/dist/machines/modal/index.mjs +2 -0
- package/dist/machines/typography/index.d.mts +15 -0
- package/dist/machines/typography/index.d.ts +15 -0
- package/dist/machines/typography/index.js +10 -0
- package/dist/machines/typography/index.mjs +1 -0
- package/dist/types-DxOTxdrs.d.mts +9 -0
- package/dist/types-DxOTxdrs.d.ts +9 -0
- package/package.json +87 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKWFE67IV_js = require('./chunk-KWFE67IV.js');
|
|
4
|
+
|
|
5
|
+
// src/machines/modal/modal.machine.ts
|
|
6
|
+
function createModalMachine(initialContext) {
|
|
7
|
+
const id = `modal-${Date.now()}`;
|
|
8
|
+
return chunkKWFE67IV_js.createMachine({
|
|
9
|
+
id: "modal",
|
|
10
|
+
initial: "closed",
|
|
11
|
+
context: {
|
|
12
|
+
triggerId: `${id}-trigger`,
|
|
13
|
+
contentId: `${id}-content`,
|
|
14
|
+
titleId: `${id}-title`,
|
|
15
|
+
closeOnOverlayClick: true,
|
|
16
|
+
closeOnEscape: true,
|
|
17
|
+
trapFocus: true,
|
|
18
|
+
...initialContext
|
|
19
|
+
},
|
|
20
|
+
states: {
|
|
21
|
+
closed: {
|
|
22
|
+
on: {
|
|
23
|
+
OPEN: "open",
|
|
24
|
+
TOGGLE: "open"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
open: {
|
|
28
|
+
on: {
|
|
29
|
+
CLOSE: "closed",
|
|
30
|
+
TOGGLE: "closed",
|
|
31
|
+
ESCAPE: "closed",
|
|
32
|
+
OVERLAY_CLICK: "closed"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/machines/modal/modal.connect.ts
|
|
40
|
+
function connectModal(options) {
|
|
41
|
+
const { state, context, send, onOpenChange } = options;
|
|
42
|
+
const { triggerId, contentId, titleId, closeOnOverlayClick, closeOnEscape } = context;
|
|
43
|
+
const isOpen = state === "open";
|
|
44
|
+
function handleOpen() {
|
|
45
|
+
send({ type: "OPEN" });
|
|
46
|
+
onOpenChange?.(true);
|
|
47
|
+
}
|
|
48
|
+
function handleClose() {
|
|
49
|
+
send({ type: "CLOSE" });
|
|
50
|
+
onOpenChange?.(false);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
state,
|
|
54
|
+
isOpen,
|
|
55
|
+
triggerProps: {
|
|
56
|
+
id: triggerId,
|
|
57
|
+
"aria-haspopup": "dialog",
|
|
58
|
+
"aria-expanded": isOpen,
|
|
59
|
+
"aria-controls": isOpen ? contentId : void 0,
|
|
60
|
+
onClick: handleOpen
|
|
61
|
+
},
|
|
62
|
+
contentProps: {
|
|
63
|
+
id: contentId,
|
|
64
|
+
role: "dialog",
|
|
65
|
+
"aria-modal": true,
|
|
66
|
+
"aria-labelledby": titleId,
|
|
67
|
+
"data-state": state,
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
onKeyDown: (event) => {
|
|
70
|
+
if (!closeOnEscape) return;
|
|
71
|
+
const e = event;
|
|
72
|
+
if (e.key === "Escape") {
|
|
73
|
+
handleClose();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
overlayProps: {
|
|
78
|
+
"data-state": state,
|
|
79
|
+
"aria-hidden": true,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
if (closeOnOverlayClick) {
|
|
82
|
+
handleClose();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
closeProps: {
|
|
87
|
+
"aria-label": "Close",
|
|
88
|
+
onClick: handleClose
|
|
89
|
+
},
|
|
90
|
+
titleProps: {
|
|
91
|
+
id: titleId
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.connectModal = connectModal;
|
|
97
|
+
exports.createModalMachine = createModalMachine;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/machines/card/card.connect.ts
|
|
4
|
+
function connectCard(options = {}) {
|
|
5
|
+
const { variant = "elevated", padding = "md", interactive = false, onClick } = options;
|
|
6
|
+
return {
|
|
7
|
+
rootProps: {
|
|
8
|
+
"data-variant": variant,
|
|
9
|
+
"data-padding": padding,
|
|
10
|
+
...interactive ? {
|
|
11
|
+
role: "button",
|
|
12
|
+
tabIndex: 0,
|
|
13
|
+
onClick,
|
|
14
|
+
onKeyDown: (event) => {
|
|
15
|
+
const e = event;
|
|
16
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
17
|
+
onClick?.(event);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
} : {}
|
|
21
|
+
},
|
|
22
|
+
headerProps: {
|
|
23
|
+
"data-part": "header"
|
|
24
|
+
},
|
|
25
|
+
bodyProps: {
|
|
26
|
+
"data-part": "body"
|
|
27
|
+
},
|
|
28
|
+
footerProps: {
|
|
29
|
+
"data-part": "footer"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.connectCard = connectCard;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYTHNCP77_js = require('./chunk-YTHNCP77.js');
|
|
4
|
+
var chunkKWFE67IV_js = require('./chunk-KWFE67IV.js');
|
|
5
|
+
|
|
6
|
+
// src/machines/input/input.machine.ts
|
|
7
|
+
function createInputMachine(initialContext) {
|
|
8
|
+
const id = initialContext?.id || `input-${Date.now()}`;
|
|
9
|
+
return chunkKWFE67IV_js.createMachine({
|
|
10
|
+
id: "input",
|
|
11
|
+
initial: "idle",
|
|
12
|
+
context: {
|
|
13
|
+
value: "",
|
|
14
|
+
disabled: false,
|
|
15
|
+
readOnly: false,
|
|
16
|
+
required: false,
|
|
17
|
+
error: null,
|
|
18
|
+
placeholder: "",
|
|
19
|
+
label: "",
|
|
20
|
+
id,
|
|
21
|
+
...initialContext
|
|
22
|
+
},
|
|
23
|
+
states: {
|
|
24
|
+
idle: {
|
|
25
|
+
on: {
|
|
26
|
+
FOCUS: "focused",
|
|
27
|
+
CHANGE: {
|
|
28
|
+
target: "filled",
|
|
29
|
+
actions: (_ctx, event) => ({ value: event.value })
|
|
30
|
+
},
|
|
31
|
+
SET_ERROR: {
|
|
32
|
+
target: "error",
|
|
33
|
+
actions: (_ctx, event) => ({ error: event.error })
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
focused: {
|
|
38
|
+
on: {
|
|
39
|
+
BLUR: "idle",
|
|
40
|
+
CHANGE: {
|
|
41
|
+
target: "focused",
|
|
42
|
+
actions: (_ctx, event) => ({ value: event.value })
|
|
43
|
+
},
|
|
44
|
+
SET_ERROR: {
|
|
45
|
+
target: "error",
|
|
46
|
+
actions: (_ctx, event) => ({ error: event.error })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
filled: {
|
|
51
|
+
on: {
|
|
52
|
+
FOCUS: "focused",
|
|
53
|
+
CHANGE: {
|
|
54
|
+
target: "filled",
|
|
55
|
+
actions: (_ctx, event) => ({ value: event.value })
|
|
56
|
+
},
|
|
57
|
+
CLEAR: {
|
|
58
|
+
target: "idle",
|
|
59
|
+
actions: () => ({ value: "" })
|
|
60
|
+
},
|
|
61
|
+
SET_ERROR: {
|
|
62
|
+
target: "error",
|
|
63
|
+
actions: (_ctx, event) => ({ error: event.error })
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
error: {
|
|
68
|
+
on: {
|
|
69
|
+
FOCUS: "focused",
|
|
70
|
+
CHANGE: {
|
|
71
|
+
target: "error",
|
|
72
|
+
actions: (_ctx, event) => ({ value: event.value })
|
|
73
|
+
},
|
|
74
|
+
SET_ERROR: {
|
|
75
|
+
target: "error",
|
|
76
|
+
actions: (_ctx, event) => {
|
|
77
|
+
const err = event.error;
|
|
78
|
+
return err === null ? {} : { error: err };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/machines/input/input.connect.ts
|
|
88
|
+
function connectInput(options) {
|
|
89
|
+
const { state, context, send, onChange } = options;
|
|
90
|
+
const { value, disabled, readOnly, required, error, placeholder, id } = context;
|
|
91
|
+
const hasError = state === "error" || error !== null;
|
|
92
|
+
const errorId = `${id}-error`;
|
|
93
|
+
const labelId = `${id}-label`;
|
|
94
|
+
return {
|
|
95
|
+
state,
|
|
96
|
+
value,
|
|
97
|
+
hasError,
|
|
98
|
+
rootProps: {
|
|
99
|
+
"data-state": state,
|
|
100
|
+
"data-disabled": disabled ? "" : void 0
|
|
101
|
+
},
|
|
102
|
+
labelProps: {
|
|
103
|
+
id: labelId,
|
|
104
|
+
htmlFor: id
|
|
105
|
+
},
|
|
106
|
+
inputProps: {
|
|
107
|
+
id,
|
|
108
|
+
value,
|
|
109
|
+
disabled,
|
|
110
|
+
readOnly,
|
|
111
|
+
placeholder,
|
|
112
|
+
"aria-labelledby": labelId,
|
|
113
|
+
...chunkYTHNCP77_js.getAriaDisabled(disabled),
|
|
114
|
+
...chunkYTHNCP77_js.getAriaInvalid(hasError),
|
|
115
|
+
...chunkYTHNCP77_js.getAriaRequired(required),
|
|
116
|
+
...hasError ? { "aria-describedby": errorId } : {},
|
|
117
|
+
"data-state": state,
|
|
118
|
+
onFocus: () => {
|
|
119
|
+
if (disabled) return;
|
|
120
|
+
send({ type: "FOCUS" });
|
|
121
|
+
},
|
|
122
|
+
onBlur: () => {
|
|
123
|
+
send({ type: "BLUR" });
|
|
124
|
+
},
|
|
125
|
+
onChange: (event) => {
|
|
126
|
+
if (disabled || readOnly) return;
|
|
127
|
+
const val = event && typeof event === "object" && "target" in event ? event.target.value : String(event);
|
|
128
|
+
send({ type: "CHANGE", value: val });
|
|
129
|
+
onChange?.(val);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
errorProps: {
|
|
133
|
+
id: errorId,
|
|
134
|
+
role: "alert",
|
|
135
|
+
"aria-live": "polite",
|
|
136
|
+
style: { display: hasError ? "block" : "none" }
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
exports.connectInput = connectInput;
|
|
142
|
+
exports.createInputMachine = createInputMachine;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/create-machine.ts
|
|
2
|
+
function createMachine(config) {
|
|
3
|
+
let currentState = config.initial;
|
|
4
|
+
let context = { ...config.context };
|
|
5
|
+
let snapshot = { state: currentState, context };
|
|
6
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
let running = false;
|
|
8
|
+
function updateSnapshot() {
|
|
9
|
+
snapshot = { state: currentState, context };
|
|
10
|
+
}
|
|
11
|
+
function notify() {
|
|
12
|
+
for (const listener of listeners) {
|
|
13
|
+
listener();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
send(event) {
|
|
18
|
+
if (!running) return;
|
|
19
|
+
const stateConfig = config.states[currentState];
|
|
20
|
+
if (!stateConfig?.on) return;
|
|
21
|
+
const transition = stateConfig.on[event.type];
|
|
22
|
+
if (!transition) return;
|
|
23
|
+
if (typeof transition === "string") {
|
|
24
|
+
currentState = transition;
|
|
25
|
+
} else {
|
|
26
|
+
const t = transition;
|
|
27
|
+
currentState = t.target;
|
|
28
|
+
if (t.actions) {
|
|
29
|
+
context = { ...context, ...t.actions(context, event) };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
updateSnapshot();
|
|
33
|
+
notify();
|
|
34
|
+
},
|
|
35
|
+
subscribe(listener) {
|
|
36
|
+
listeners.add(listener);
|
|
37
|
+
return () => {
|
|
38
|
+
listeners.delete(listener);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
getSnapshot() {
|
|
42
|
+
return snapshot;
|
|
43
|
+
},
|
|
44
|
+
start() {
|
|
45
|
+
running = true;
|
|
46
|
+
},
|
|
47
|
+
stop() {
|
|
48
|
+
running = false;
|
|
49
|
+
listeners.clear();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { createMachine };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/accessibility.ts
|
|
4
|
+
function getAriaDisabled(disabled) {
|
|
5
|
+
if (!disabled) return {};
|
|
6
|
+
return {
|
|
7
|
+
"aria-disabled": true,
|
|
8
|
+
"data-disabled": ""
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function getAriaPressed(pressed) {
|
|
12
|
+
return { "aria-pressed": pressed };
|
|
13
|
+
}
|
|
14
|
+
function getAriaExpanded(expanded) {
|
|
15
|
+
return { "aria-expanded": expanded };
|
|
16
|
+
}
|
|
17
|
+
function getAriaInvalid(invalid) {
|
|
18
|
+
return { "aria-invalid": invalid };
|
|
19
|
+
}
|
|
20
|
+
function getAriaRequired(required) {
|
|
21
|
+
return { "aria-required": required };
|
|
22
|
+
}
|
|
23
|
+
function getAriaModal() {
|
|
24
|
+
return {
|
|
25
|
+
"aria-modal": true,
|
|
26
|
+
role: "dialog"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var idCounter = 0;
|
|
30
|
+
function generateId(prefix) {
|
|
31
|
+
return `${prefix}-${++idCounter}`;
|
|
32
|
+
}
|
|
33
|
+
function resetIdCounter() {
|
|
34
|
+
idCounter = 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.generateId = generateId;
|
|
38
|
+
exports.getAriaDisabled = getAriaDisabled;
|
|
39
|
+
exports.getAriaExpanded = getAriaExpanded;
|
|
40
|
+
exports.getAriaInvalid = getAriaInvalid;
|
|
41
|
+
exports.getAriaModal = getAriaModal;
|
|
42
|
+
exports.getAriaPressed = getAriaPressed;
|
|
43
|
+
exports.getAriaRequired = getAriaRequired;
|
|
44
|
+
exports.resetIdCounter = resetIdCounter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface MachineConfig<TState extends string, TContext, TEvent extends {
|
|
2
|
+
type: string;
|
|
3
|
+
}> {
|
|
4
|
+
id: string;
|
|
5
|
+
initial: TState;
|
|
6
|
+
context: TContext;
|
|
7
|
+
states: Record<TState, {
|
|
8
|
+
on?: Partial<Record<TEvent['type'], TState | {
|
|
9
|
+
target: TState;
|
|
10
|
+
actions?: (ctx: TContext, event: TEvent) => Partial<TContext>;
|
|
11
|
+
}>>;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
interface MachineService<TState extends string, TContext, TEvent extends {
|
|
15
|
+
type: string;
|
|
16
|
+
}> {
|
|
17
|
+
send: (event: TEvent) => void;
|
|
18
|
+
subscribe: (listener: () => void) => () => void;
|
|
19
|
+
getSnapshot: () => {
|
|
20
|
+
state: TState;
|
|
21
|
+
context: TContext;
|
|
22
|
+
};
|
|
23
|
+
start: () => void;
|
|
24
|
+
stop: () => void;
|
|
25
|
+
}
|
|
26
|
+
declare function createMachine<TState extends string, TContext extends object, TEvent extends {
|
|
27
|
+
type: string;
|
|
28
|
+
}>(config: MachineConfig<TState, TContext, TEvent>): MachineService<TState, TContext, TEvent>;
|
|
29
|
+
|
|
30
|
+
export { type MachineConfig as M, type MachineService as a, createMachine as c };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface MachineConfig<TState extends string, TContext, TEvent extends {
|
|
2
|
+
type: string;
|
|
3
|
+
}> {
|
|
4
|
+
id: string;
|
|
5
|
+
initial: TState;
|
|
6
|
+
context: TContext;
|
|
7
|
+
states: Record<TState, {
|
|
8
|
+
on?: Partial<Record<TEvent['type'], TState | {
|
|
9
|
+
target: TState;
|
|
10
|
+
actions?: (ctx: TContext, event: TEvent) => Partial<TContext>;
|
|
11
|
+
}>>;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
interface MachineService<TState extends string, TContext, TEvent extends {
|
|
15
|
+
type: string;
|
|
16
|
+
}> {
|
|
17
|
+
send: (event: TEvent) => void;
|
|
18
|
+
subscribe: (listener: () => void) => () => void;
|
|
19
|
+
getSnapshot: () => {
|
|
20
|
+
state: TState;
|
|
21
|
+
context: TContext;
|
|
22
|
+
};
|
|
23
|
+
start: () => void;
|
|
24
|
+
stop: () => void;
|
|
25
|
+
}
|
|
26
|
+
declare function createMachine<TState extends string, TContext extends object, TEvent extends {
|
|
27
|
+
type: string;
|
|
28
|
+
}>(config: MachineConfig<TState, TContext, TEvent>): MachineService<TState, TContext, TEvent>;
|
|
29
|
+
|
|
30
|
+
export { type MachineConfig as M, type MachineService as a, createMachine as c };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { M as MachineConfig, a as MachineService, c as createMachine } from './create-machine-DsOUIlfe.mjs';
|
|
2
|
+
import { E as ElementProps } from './types-DxOTxdrs.mjs';
|
|
3
|
+
export { P as PropTypes, S as Size, T as TypographyVariant, V as Variant } from './types-DxOTxdrs.mjs';
|
|
4
|
+
export { ButtonConnectOptions, ButtonConnectReturn, ButtonContext, ButtonEvent, ButtonMachineService, ButtonState, connectButton, createButtonMachine } from './machines/button/index.mjs';
|
|
5
|
+
export { InputConnectOptions, InputConnectReturn, InputContext, InputEvent, InputMachineService, InputState, connectInput, createInputMachine } from './machines/input/index.mjs';
|
|
6
|
+
export { ModalConnectOptions, ModalConnectReturn, ModalContext, ModalEvent, ModalMachineService, ModalState, connectModal, createModalMachine } from './machines/modal/index.mjs';
|
|
7
|
+
export { TypographyConnectOptions, TypographyConnectReturn, connectTypography } from './machines/typography/index.mjs';
|
|
8
|
+
export { CardConnectOptions, CardConnectReturn, connectCard } from './machines/card/index.mjs';
|
|
9
|
+
|
|
10
|
+
declare function mergeProps(...propsList: (ElementProps | undefined)[]): ElementProps;
|
|
11
|
+
|
|
12
|
+
declare function getAriaDisabled(disabled: boolean | undefined): ElementProps;
|
|
13
|
+
declare function getAriaPressed(pressed: boolean): ElementProps;
|
|
14
|
+
declare function getAriaExpanded(expanded: boolean): ElementProps;
|
|
15
|
+
declare function getAriaInvalid(invalid: boolean): ElementProps;
|
|
16
|
+
declare function getAriaRequired(required: boolean): ElementProps;
|
|
17
|
+
declare function getAriaModal(): ElementProps;
|
|
18
|
+
declare function generateId(prefix: string): string;
|
|
19
|
+
declare function resetIdCounter(): void;
|
|
20
|
+
|
|
21
|
+
type Platform = 'web' | 'react-native';
|
|
22
|
+
declare function detectPlatform(): Platform;
|
|
23
|
+
declare function isWeb(): boolean;
|
|
24
|
+
declare function isReactNative(): boolean;
|
|
25
|
+
|
|
26
|
+
export { ElementProps, detectPlatform, generateId, getAriaDisabled, getAriaExpanded, getAriaInvalid, getAriaModal, getAriaPressed, getAriaRequired, isReactNative, isWeb, mergeProps, resetIdCounter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { M as MachineConfig, a as MachineService, c as createMachine } from './create-machine-DsOUIlfe.js';
|
|
2
|
+
import { E as ElementProps } from './types-DxOTxdrs.js';
|
|
3
|
+
export { P as PropTypes, S as Size, T as TypographyVariant, V as Variant } from './types-DxOTxdrs.js';
|
|
4
|
+
export { ButtonConnectOptions, ButtonConnectReturn, ButtonContext, ButtonEvent, ButtonMachineService, ButtonState, connectButton, createButtonMachine } from './machines/button/index.js';
|
|
5
|
+
export { InputConnectOptions, InputConnectReturn, InputContext, InputEvent, InputMachineService, InputState, connectInput, createInputMachine } from './machines/input/index.js';
|
|
6
|
+
export { ModalConnectOptions, ModalConnectReturn, ModalContext, ModalEvent, ModalMachineService, ModalState, connectModal, createModalMachine } from './machines/modal/index.js';
|
|
7
|
+
export { TypographyConnectOptions, TypographyConnectReturn, connectTypography } from './machines/typography/index.js';
|
|
8
|
+
export { CardConnectOptions, CardConnectReturn, connectCard } from './machines/card/index.js';
|
|
9
|
+
|
|
10
|
+
declare function mergeProps(...propsList: (ElementProps | undefined)[]): ElementProps;
|
|
11
|
+
|
|
12
|
+
declare function getAriaDisabled(disabled: boolean | undefined): ElementProps;
|
|
13
|
+
declare function getAriaPressed(pressed: boolean): ElementProps;
|
|
14
|
+
declare function getAriaExpanded(expanded: boolean): ElementProps;
|
|
15
|
+
declare function getAriaInvalid(invalid: boolean): ElementProps;
|
|
16
|
+
declare function getAriaRequired(required: boolean): ElementProps;
|
|
17
|
+
declare function getAriaModal(): ElementProps;
|
|
18
|
+
declare function generateId(prefix: string): string;
|
|
19
|
+
declare function resetIdCounter(): void;
|
|
20
|
+
|
|
21
|
+
type Platform = 'web' | 'react-native';
|
|
22
|
+
declare function detectPlatform(): Platform;
|
|
23
|
+
declare function isWeb(): boolean;
|
|
24
|
+
declare function isReactNative(): boolean;
|
|
25
|
+
|
|
26
|
+
export { ElementProps, detectPlatform, generateId, getAriaDisabled, getAriaExpanded, getAriaInvalid, getAriaModal, getAriaPressed, getAriaRequired, isReactNative, isWeb, mergeProps, resetIdCounter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkEQR2S6TY_js = require('./chunk-EQR2S6TY.js');
|
|
4
|
+
var chunkY34GDQYY_js = require('./chunk-Y34GDQYY.js');
|
|
5
|
+
var chunkYTHNCP77_js = require('./chunk-YTHNCP77.js');
|
|
6
|
+
var chunkO7JRMYZ5_js = require('./chunk-O7JRMYZ5.js');
|
|
7
|
+
var chunkKWFE67IV_js = require('./chunk-KWFE67IV.js');
|
|
8
|
+
var chunkDEYVI3GG_js = require('./chunk-DEYVI3GG.js');
|
|
9
|
+
var chunkOLRCZXKS_js = require('./chunk-OLRCZXKS.js');
|
|
10
|
+
|
|
11
|
+
// src/utils/merge-props.ts
|
|
12
|
+
function mergeProps(...propsList) {
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const props of propsList) {
|
|
15
|
+
if (!props) continue;
|
|
16
|
+
for (const [key, value] of Object.entries(props)) {
|
|
17
|
+
if (value === void 0) continue;
|
|
18
|
+
const existing = result[key];
|
|
19
|
+
if (key.startsWith("on") && typeof existing === "function" && typeof value === "function") {
|
|
20
|
+
result[key] = (...args) => {
|
|
21
|
+
existing(...args);
|
|
22
|
+
value(...args);
|
|
23
|
+
};
|
|
24
|
+
} else if (key === "style" && typeof existing === "object" && typeof value === "object") {
|
|
25
|
+
result[key] = { ...existing, ...value };
|
|
26
|
+
} else {
|
|
27
|
+
result[key] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/utils/platform.ts
|
|
35
|
+
function detectPlatform() {
|
|
36
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
37
|
+
return "react-native";
|
|
38
|
+
}
|
|
39
|
+
return "web";
|
|
40
|
+
}
|
|
41
|
+
function isWeb() {
|
|
42
|
+
return detectPlatform() === "web";
|
|
43
|
+
}
|
|
44
|
+
function isReactNative() {
|
|
45
|
+
return detectPlatform() === "react-native";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Object.defineProperty(exports, "connectButton", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkEQR2S6TY_js.connectButton; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "createButtonMachine", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkEQR2S6TY_js.createButtonMachine; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "connectInput", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunkY34GDQYY_js.connectInput; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "createInputMachine", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkY34GDQYY_js.createInputMachine; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "generateId", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkYTHNCP77_js.generateId; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "getAriaDisabled", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkYTHNCP77_js.getAriaDisabled; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "getAriaExpanded", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunkYTHNCP77_js.getAriaExpanded; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "getAriaInvalid", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return chunkYTHNCP77_js.getAriaInvalid; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "getAriaModal", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkYTHNCP77_js.getAriaModal; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "getAriaPressed", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return chunkYTHNCP77_js.getAriaPressed; }
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "getAriaRequired", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return chunkYTHNCP77_js.getAriaRequired; }
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "resetIdCounter", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return chunkYTHNCP77_js.resetIdCounter; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "connectModal", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return chunkO7JRMYZ5_js.connectModal; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "createModalMachine", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return chunkO7JRMYZ5_js.createModalMachine; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "createMachine", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkKWFE67IV_js.createMachine; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "connectTypography", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return chunkDEYVI3GG_js.connectTypography; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "connectCard", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return chunkOLRCZXKS_js.connectCard; }
|
|
115
|
+
});
|
|
116
|
+
exports.detectPlatform = detectPlatform;
|
|
117
|
+
exports.isReactNative = isReactNative;
|
|
118
|
+
exports.isWeb = isWeb;
|
|
119
|
+
exports.mergeProps = mergeProps;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export { connectButton, createButtonMachine } from './chunk-3SIG5GVW.mjs';
|
|
2
|
+
export { connectInput, createInputMachine } from './chunk-CG7MB4D7.mjs';
|
|
3
|
+
export { generateId, getAriaDisabled, getAriaExpanded, getAriaInvalid, getAriaModal, getAriaPressed, getAriaRequired, resetIdCounter } from './chunk-IRJ3PEU4.mjs';
|
|
4
|
+
export { connectModal, createModalMachine } from './chunk-ECS4ZLAD.mjs';
|
|
5
|
+
export { createMachine } from './chunk-YFNMWGC7.mjs';
|
|
6
|
+
export { connectTypography } from './chunk-JTKA5LGK.mjs';
|
|
7
|
+
export { connectCard } from './chunk-KQF35W7O.mjs';
|
|
8
|
+
|
|
9
|
+
// src/utils/merge-props.ts
|
|
10
|
+
function mergeProps(...propsList) {
|
|
11
|
+
const result = {};
|
|
12
|
+
for (const props of propsList) {
|
|
13
|
+
if (!props) continue;
|
|
14
|
+
for (const [key, value] of Object.entries(props)) {
|
|
15
|
+
if (value === void 0) continue;
|
|
16
|
+
const existing = result[key];
|
|
17
|
+
if (key.startsWith("on") && typeof existing === "function" && typeof value === "function") {
|
|
18
|
+
result[key] = (...args) => {
|
|
19
|
+
existing(...args);
|
|
20
|
+
value(...args);
|
|
21
|
+
};
|
|
22
|
+
} else if (key === "style" && typeof existing === "object" && typeof value === "object") {
|
|
23
|
+
result[key] = { ...existing, ...value };
|
|
24
|
+
} else {
|
|
25
|
+
result[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/utils/platform.ts
|
|
33
|
+
function detectPlatform() {
|
|
34
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
35
|
+
return "react-native";
|
|
36
|
+
}
|
|
37
|
+
return "web";
|
|
38
|
+
}
|
|
39
|
+
function isWeb() {
|
|
40
|
+
return detectPlatform() === "web";
|
|
41
|
+
}
|
|
42
|
+
function isReactNative() {
|
|
43
|
+
return detectPlatform() === "react-native";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { detectPlatform, isReactNative, isWeb, mergeProps };
|