@mekari/pixel3-input 0.0.1-alpha.0 → 0.0.1

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,79 +0,0 @@
1
- import {
2
- inputAddonConnect,
3
- inputConnect,
4
- inputGroupConnect
5
- } from "./chunk-T766ACNL.mjs";
6
- import {
7
- inputAddonMachine,
8
- inputGroupMachine,
9
- inputMachine
10
- } from "./chunk-EF6JEV72.mjs";
11
- import {
12
- __name
13
- } from "./chunk-QZ7VFGWC.mjs";
14
-
15
- // src/modules/input.hooks.ts
16
- import { computed, ref } from "vue";
17
- import { useMachine } from "@xstate/vue";
18
- import { useId } from "@mekari/pixel3-utils";
19
- import { inputSlotRecipe, inputGroupSlotRecipe, inputAddonSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
20
- var useInput = /* @__PURE__ */ __name((props, emit) => {
21
- var _a;
22
- const context = ref(props);
23
- const {
24
- state,
25
- send
26
- } = useMachine(inputMachine({
27
- ...context.value,
28
- id: (_a = context.value.id) != null ? _a : `mp-input-${useId()}`,
29
- onInput(evt) {
30
- var _a2, _b;
31
- emit("update:modelValue", (_a2 = evt == null ? void 0 : evt.currentTarget) == null ? void 0 : _a2.value);
32
- emit("input", evt, (_b = evt == null ? void 0 : evt.currentTarget) == null ? void 0 : _b.value);
33
- },
34
- onChange(evt) {
35
- var _a2;
36
- emit("change", evt, (_a2 = evt == null ? void 0 : evt.currentTarget) == null ? void 0 : _a2.value);
37
- },
38
- onClear(evt) {
39
- emit("clear", evt);
40
- }
41
- }));
42
- const [inputProps] = inputSlotRecipe.splitVariantProps(context.value);
43
- const classes = inputSlotRecipe(inputProps);
44
- return computed(() => inputConnect(state.value, send, classes));
45
- }, "useInput");
46
- var useInputGroup = /* @__PURE__ */ __name((props) => {
47
- var _a;
48
- const context = ref(props);
49
- const {
50
- state,
51
- send
52
- } = useMachine(inputGroupMachine({
53
- ...context.value,
54
- id: (_a = context.value.id) != null ? _a : `mp-input-group-${useId()}`
55
- }));
56
- const [inputGroupProps] = inputGroupSlotRecipe.splitVariantProps(context.value);
57
- const classes = inputGroupSlotRecipe(inputGroupProps);
58
- return computed(() => inputGroupConnect(state.value, send, classes));
59
- }, "useInputGroup");
60
- var useInputAddon = /* @__PURE__ */ __name((props) => {
61
- var _a;
62
- const context = ref(props);
63
- const {
64
- state,
65
- send
66
- } = useMachine(inputAddonMachine({
67
- ...context.value,
68
- id: (_a = context.value.id) != null ? _a : `mp-input-addon-${useId()}`
69
- }));
70
- const [inputAddonProps] = inputAddonSlotRecipe.splitVariantProps(context.value);
71
- const classes = inputAddonSlotRecipe(inputAddonProps);
72
- return computed(() => inputAddonConnect(state.value, send, classes));
73
- }, "useInputAddon");
74
-
75
- export {
76
- useInput,
77
- useInputGroup,
78
- useInputAddon
79
- };
@@ -1,127 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-QZ7VFGWC.mjs";
4
-
5
- // src/modules/input.connects.ts
6
- import { cx } from "@mekari/pixel3-styled-system/css";
7
- function inputConnect(state, send, classes) {
8
- const {
9
- id,
10
- modelValue,
11
- placeholder,
12
- isReadOnly,
13
- isDisabled,
14
- isRequired,
15
- isInvalid,
16
- isFullWidth,
17
- isClearable,
18
- onInput,
19
- onChange,
20
- onClear
21
- } = state.context;
22
- return {
23
- modelValue,
24
- isReadOnly,
25
- isDisabled,
26
- isClearable,
27
- rootProps: {
28
- id,
29
- class: cx(classes.root, "group"),
30
- "data-is-full-width": isFullWidth,
31
- "data-pixel-component": "MpInput"
32
- },
33
- controlProps: {
34
- id: `${id}-control`,
35
- value: modelValue,
36
- placeholder,
37
- readonly: isReadOnly,
38
- disabled: isDisabled,
39
- required: isRequired,
40
- "data-value": modelValue,
41
- "data-is-full-width": isFullWidth,
42
- "aria-readonly": isReadOnly,
43
- "aria-disabled": isDisabled,
44
- "aria-invalid": isInvalid,
45
- "aria-required": isRequired,
46
- onInput(evt) {
47
- var _a;
48
- send({
49
- type: "SET_VALUE",
50
- value: (_a = evt == null ? void 0 : evt.currentTarget) == null ? void 0 : _a.value
51
- });
52
- if (onInput)
53
- onInput(evt);
54
- },
55
- onChange(evt) {
56
- var _a;
57
- send({
58
- type: "SET_VALUE",
59
- value: (_a = evt == null ? void 0 : evt.currentTarget) == null ? void 0 : _a.value
60
- });
61
- if (onChange)
62
- onChange(evt);
63
- },
64
- class: classes.control,
65
- "data-pixel-component": "MpInputControl"
66
- },
67
- clearProps: {
68
- id: `${id}-clear`,
69
- variant: "ghost",
70
- size: "sm",
71
- leftIcon: "reset",
72
- onClick(evt) {
73
- send({
74
- type: "SET_VALUE",
75
- value: null
76
- });
77
- if (onInput)
78
- onInput(evt);
79
- if (onClear)
80
- onClear(evt);
81
- },
82
- class: classes.clear,
83
- style: {
84
- "--mp-input--visibility": modelValue ? "visible" : "hidden",
85
- "--mp-input--opacity": modelValue ? "1" : "0"
86
- },
87
- "data-pixel-component": "MpInputClear"
88
- }
89
- };
90
- }
91
- __name(inputConnect, "inputConnect");
92
- function inputGroupConnect(state, send, classes) {
93
- const {
94
- id
95
- } = state.context;
96
- return {
97
- rootProps: {
98
- id,
99
- class: classes.root,
100
- "data-pixel-component": "MpInputGroup"
101
- }
102
- };
103
- }
104
- __name(inputGroupConnect, "inputGroupConnect");
105
- function inputAddonConnect(state, send, classes) {
106
- const {
107
- id,
108
- placement,
109
- hasBackground
110
- } = state.context;
111
- return {
112
- rootProps: {
113
- id,
114
- class: classes.root,
115
- "data-placement": placement,
116
- "data-has-background": hasBackground,
117
- "data-pixel-component": "MpInputAddon"
118
- }
119
- };
120
- }
121
- __name(inputAddonConnect, "inputAddonConnect");
122
-
123
- export {
124
- inputConnect,
125
- inputGroupConnect,
126
- inputAddonConnect
127
- };
@@ -1,48 +0,0 @@
1
- import * as xstate from 'xstate';
2
- import { InputDefinedContext, InputSize, InputVariant, InputGroupDefinedContext, InputGroupProps, InputAddonDefinedContext, InputAddonProps } from './input.types.mjs';
3
- import '@mekari/pixel3-utils';
4
-
5
- declare function inputMachine(context: InputDefinedContext): xstate.StateMachine<{
6
- id?: string | undefined;
7
- size?: InputSize | undefined;
8
- onChange?: ((evt: Event) => void) | undefined;
9
- onInput?: ((evt: Event) => void) | undefined;
10
- modelValue: string | number;
11
- variant?: InputVariant | undefined;
12
- placeholder?: string | undefined;
13
- isReadOnly?: boolean | undefined;
14
- isDisabled?: boolean | undefined;
15
- isRequired?: boolean | undefined;
16
- isInvalid?: boolean | undefined;
17
- isFullWidth?: boolean | undefined;
18
- isClearable?: boolean | undefined;
19
- onClear?: ((evt: Event) => void) | undefined;
20
- }, any, xstate.AnyEventObject, {
21
- value: any;
22
- context: {
23
- id?: string | undefined;
24
- size?: InputSize | undefined;
25
- onChange?: ((evt: Event) => void) | undefined;
26
- onInput?: ((evt: Event) => void) | undefined;
27
- modelValue: string | number;
28
- variant?: InputVariant | undefined;
29
- placeholder?: string | undefined;
30
- isReadOnly?: boolean | undefined;
31
- isDisabled?: boolean | undefined;
32
- isRequired?: boolean | undefined;
33
- isInvalid?: boolean | undefined;
34
- isFullWidth?: boolean | undefined;
35
- isClearable?: boolean | undefined;
36
- onClear?: ((evt: Event) => void) | undefined;
37
- };
38
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
39
- declare function inputGroupMachine(context: InputGroupDefinedContext): xstate.StateMachine<Pick<Partial<InputGroupProps>, "id"> & Omit<InputGroupProps, "id">, any, xstate.AnyEventObject, {
40
- value: any;
41
- context: Pick<Partial<InputGroupProps>, "id"> & Omit<InputGroupProps, "id">;
42
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
43
- declare function inputAddonMachine(context: InputAddonDefinedContext): xstate.StateMachine<Pick<Partial<InputAddonProps>, "id"> & Omit<InputAddonProps, "id">, any, xstate.AnyEventObject, {
44
- value: any;
45
- context: Pick<Partial<InputAddonProps>, "id"> & Omit<InputAddonProps, "id">;
46
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
47
-
48
- export { inputAddonMachine, inputGroupMachine, inputMachine };
@@ -1,48 +0,0 @@
1
- import * as xstate from 'xstate';
2
- import { InputDefinedContext, InputSize, InputVariant, InputGroupDefinedContext, InputGroupProps, InputAddonDefinedContext, InputAddonProps } from './input.types.js';
3
- import '@mekari/pixel3-utils';
4
-
5
- declare function inputMachine(context: InputDefinedContext): xstate.StateMachine<{
6
- id?: string | undefined;
7
- size?: InputSize | undefined;
8
- onChange?: ((evt: Event) => void) | undefined;
9
- onInput?: ((evt: Event) => void) | undefined;
10
- modelValue: string | number;
11
- variant?: InputVariant | undefined;
12
- placeholder?: string | undefined;
13
- isReadOnly?: boolean | undefined;
14
- isDisabled?: boolean | undefined;
15
- isRequired?: boolean | undefined;
16
- isInvalid?: boolean | undefined;
17
- isFullWidth?: boolean | undefined;
18
- isClearable?: boolean | undefined;
19
- onClear?: ((evt: Event) => void) | undefined;
20
- }, any, xstate.AnyEventObject, {
21
- value: any;
22
- context: {
23
- id?: string | undefined;
24
- size?: InputSize | undefined;
25
- onChange?: ((evt: Event) => void) | undefined;
26
- onInput?: ((evt: Event) => void) | undefined;
27
- modelValue: string | number;
28
- variant?: InputVariant | undefined;
29
- placeholder?: string | undefined;
30
- isReadOnly?: boolean | undefined;
31
- isDisabled?: boolean | undefined;
32
- isRequired?: boolean | undefined;
33
- isInvalid?: boolean | undefined;
34
- isFullWidth?: boolean | undefined;
35
- isClearable?: boolean | undefined;
36
- onClear?: ((evt: Event) => void) | undefined;
37
- };
38
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
39
- declare function inputGroupMachine(context: InputGroupDefinedContext): xstate.StateMachine<Pick<Partial<InputGroupProps>, "id"> & Omit<InputGroupProps, "id">, any, xstate.AnyEventObject, {
40
- value: any;
41
- context: Pick<Partial<InputGroupProps>, "id"> & Omit<InputGroupProps, "id">;
42
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
43
- declare function inputAddonMachine(context: InputAddonDefinedContext): xstate.StateMachine<Pick<Partial<InputAddonProps>, "id"> & Omit<InputAddonProps, "id">, any, xstate.AnyEventObject, {
44
- value: any;
45
- context: Pick<Partial<InputAddonProps>, "id"> & Omit<InputAddonProps, "id">;
46
- }, xstate.BaseActionObject, xstate.ServiceMap, xstate.ResolveTypegenMeta<xstate.TypegenDisabled, xstate.AnyEventObject, xstate.BaseActionObject, xstate.ServiceMap>>;
47
-
48
- export { inputAddonMachine, inputGroupMachine, inputMachine };
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/modules/input.machines.ts
22
- var input_machines_exports = {};
23
- __export(input_machines_exports, {
24
- inputAddonMachine: () => inputAddonMachine,
25
- inputGroupMachine: () => inputGroupMachine,
26
- inputMachine: () => inputMachine
27
- });
28
- module.exports = __toCommonJS(input_machines_exports);
29
- var import_xstate = require("xstate");
30
- function inputMachine(context) {
31
- return (0, import_xstate.createMachine)({
32
- /** @xstate-layout N4IgpgJg5mDOIC5QEsB2AHArgFwMQGUBRAFQH0A1AQQBkBVQgbQAYBdRUdAe1mW2U9TsQAD0QBGAEwA6JrLnz5AdgA0IAJ7iJAXy2q0WPMQCaABUIUa9ZmyQguPPgKGiEEiYqkBWT00UAOADZPRQBmPwAWAE4Av1UNBDExEKlwzxCxTzFw8IDIiT9FAJ1dEFROCDghfRwhe15+QVsXEICpQrFFCXDfMKjcuPEklLSMrJy8gqLioA */
33
- id: "input",
34
- context: {
35
- modelValue: "",
36
- ...context
37
- },
38
- on: {
39
- SET_VALUE: {
40
- actions: "setValue"
41
- }
42
- },
43
- predictableActionArguments: true
44
- }, {
45
- actions: {
46
- setValue(ctx, evt) {
47
- set.value(ctx, evt.value);
48
- }
49
- }
50
- });
51
- }
52
- __name(inputMachine, "inputMachine");
53
- var set = {
54
- value(ctx, value) {
55
- ctx.modelValue = value;
56
- }
57
- };
58
- function inputGroupMachine(context) {
59
- return (0, import_xstate.createMachine)({
60
- /** @xstate-layout N4IgpgJg5mDOIC5gF8A0IB2B7CdGgEMA3AgFwICcBaKCrAVwAd8RGtYBLUjrDFgD0QBGAEzoAnsJHIZyIA */
61
- id: "input-group",
62
- context,
63
- predictableActionArguments: true
64
- });
65
- }
66
- __name(inputGroupMachine, "inputGroupMachine");
67
- function inputAddonMachine(context) {
68
- return (0, import_xstate.createMachine)({
69
- /** @xstate-layout N4IgpgJg5mDOIC5gF8A0IB2B7CdGgEsMAHAVwBcBaAQwgiw3xGK1gPIIaYA9EBGAEzoAnvwHIJyIA */
70
- id: "input-addon",
71
- context,
72
- predictableActionArguments: true
73
- });
74
- }
75
- __name(inputAddonMachine, "inputAddonMachine");
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- inputAddonMachine,
79
- inputGroupMachine,
80
- inputMachine
81
- });
@@ -1,11 +0,0 @@
1
- import {
2
- inputAddonMachine,
3
- inputGroupMachine,
4
- inputMachine
5
- } from "../chunk-EF6JEV72.mjs";
6
- import "../chunk-QZ7VFGWC.mjs";
7
- export {
8
- inputAddonMachine,
9
- inputGroupMachine,
10
- inputMachine
11
- };