@mekari/pixel3-airene-chat-input 0.0.1-dev.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/airene-chat-input.d.mts +99 -0
- package/dist/airene-chat-input.d.ts +99 -0
- package/dist/airene-chat-input.js +254 -0
- package/dist/airene-chat-input.mjs +9 -0
- package/dist/chunk-2K4QROIN.mjs +34 -0
- package/dist/chunk-4PYKLJPU.mjs +50 -0
- package/dist/chunk-KPLBIBRE.mjs +162 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +256 -0
- package/dist/index.mjs +9 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/airene-chat-input.hooks.d.mts +13 -0
- package/dist/modules/airene-chat-input.hooks.d.ts +13 -0
- package/dist/modules/airene-chat-input.hooks.js +183 -0
- package/dist/modules/airene-chat-input.hooks.mjs +7 -0
- package/dist/modules/airene-chat-input.props.d.mts +50 -0
- package/dist/modules/airene-chat-input.props.d.ts +50 -0
- package/dist/modules/airene-chat-input.props.js +75 -0
- package/dist/modules/airene-chat-input.props.mjs +9 -0
- package/package.json +42 -0
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
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/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
MpAireneChatInput: () => MpAireneChatInput
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/airene-chat-input.tsx
|
|
29
|
+
var import_vue2 = require("vue");
|
|
30
|
+
var import_vue3 = require("vue");
|
|
31
|
+
var import_pixel3_icon = require("@mekari/pixel3-icon");
|
|
32
|
+
|
|
33
|
+
// src/modules/airene-chat-input.hooks.ts
|
|
34
|
+
var import_vue = require("vue");
|
|
35
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
36
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
37
|
+
var import_tokens = require("@mekari/pixel3-styled-system/tokens");
|
|
38
|
+
function useAireneChatInput(props, emit, slots) {
|
|
39
|
+
const {
|
|
40
|
+
id,
|
|
41
|
+
modelValue,
|
|
42
|
+
placeholder,
|
|
43
|
+
maxlength,
|
|
44
|
+
ariaLabel,
|
|
45
|
+
ariaLabelledBy,
|
|
46
|
+
isReadOnly,
|
|
47
|
+
isDisabled,
|
|
48
|
+
isInvalid,
|
|
49
|
+
isRequired,
|
|
50
|
+
isForceFocus
|
|
51
|
+
} = (0, import_vue.toRefs)(props);
|
|
52
|
+
const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "airene-chat-input").value;
|
|
53
|
+
const input = (0, import_vue.ref)();
|
|
54
|
+
const inputHeight = (0, import_vue.ref)("20px");
|
|
55
|
+
const rounded = (0, import_vue.ref)("full");
|
|
56
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
57
|
+
return {
|
|
58
|
+
"data-pixel-component": "MpAireneChatInput",
|
|
59
|
+
id: getId,
|
|
60
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().root,
|
|
61
|
+
disabled: isDisabled.value || void 0,
|
|
62
|
+
"data-invalid": isInvalid.value || void 0,
|
|
63
|
+
style: {
|
|
64
|
+
borderRadius: import_tokens.token.var(`radii.${rounded.value}`)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const wrapperAttrs = (0, import_vue.computed)(() => {
|
|
69
|
+
return {
|
|
70
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().wrapper
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
const inputAttrs = (0, import_vue.computed)(() => {
|
|
74
|
+
return {
|
|
75
|
+
ref: input,
|
|
76
|
+
id: `${getId}--input`,
|
|
77
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().input,
|
|
78
|
+
value: modelValue.value,
|
|
79
|
+
placeholder: placeholder.value,
|
|
80
|
+
rows: "1",
|
|
81
|
+
autocomplete: "off",
|
|
82
|
+
spellcheck: "false",
|
|
83
|
+
maxlength: maxlength == null ? void 0 : maxlength.value,
|
|
84
|
+
disabled: isDisabled.value,
|
|
85
|
+
readonly: isReadOnly.value,
|
|
86
|
+
required: isRequired.value,
|
|
87
|
+
"aria-label": ariaLabel == null ? void 0 : ariaLabel.value,
|
|
88
|
+
"aria-labelledby": ariaLabelledBy == null ? void 0 : ariaLabelledBy.value,
|
|
89
|
+
"aria-readonly": (isReadOnly == null ? void 0 : isReadOnly.value) || void 0,
|
|
90
|
+
"aria-required": (isRequired == null ? void 0 : isRequired.value) || void 0,
|
|
91
|
+
"aria-invalid": isInvalid.value || void 0,
|
|
92
|
+
style: {
|
|
93
|
+
height: inputHeight.value
|
|
94
|
+
},
|
|
95
|
+
onInput: handleInput,
|
|
96
|
+
onChange: handleChange,
|
|
97
|
+
onFocus: handleFocus,
|
|
98
|
+
onBlur: handleBlur,
|
|
99
|
+
onKeydown: handleKeydown,
|
|
100
|
+
onClick: handleSelectAllText
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
const buttonAttrs = (0, import_vue.computed)(() => {
|
|
104
|
+
return {
|
|
105
|
+
name: "sent",
|
|
106
|
+
variant: isActive.value ? "fill" : "outline",
|
|
107
|
+
color: isActive.value ? "icon.brand" : "icon.default",
|
|
108
|
+
onClick: handleClick
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const isActive = (0, import_vue.computed)(() => {
|
|
112
|
+
return modelValue.value.length > 0;
|
|
113
|
+
});
|
|
114
|
+
const hasChildren = (0, import_vue.computed)(() => {
|
|
115
|
+
return slots.default && slots.default().length > 0;
|
|
116
|
+
});
|
|
117
|
+
function handleInput(e) {
|
|
118
|
+
const target = e.target;
|
|
119
|
+
emit("input", target.value, e);
|
|
120
|
+
emit("update:modelValue", target.value);
|
|
121
|
+
handleAdjustInputHeight();
|
|
122
|
+
}
|
|
123
|
+
__name(handleInput, "handleInput");
|
|
124
|
+
function handleChange(e) {
|
|
125
|
+
const target = e.target;
|
|
126
|
+
emit("change", target.value, e);
|
|
127
|
+
}
|
|
128
|
+
__name(handleChange, "handleChange");
|
|
129
|
+
function handleAdjustInputHeight() {
|
|
130
|
+
inputHeight.value = "auto";
|
|
131
|
+
(0, import_vue.nextTick)(() => {
|
|
132
|
+
const height = input.value.scrollHeight;
|
|
133
|
+
inputHeight.value = `${height}px`;
|
|
134
|
+
rounded.value = height >= 40 || hasChildren.value ? "xl" : "full";
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
__name(handleAdjustInputHeight, "handleAdjustInputHeight");
|
|
138
|
+
function handleSelectAllText(e) {
|
|
139
|
+
const target = e.target;
|
|
140
|
+
const textLabel = target.value;
|
|
141
|
+
if (textLabel) {
|
|
142
|
+
target.setSelectionRange(0, textLabel.length);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
__name(handleSelectAllText, "handleSelectAllText");
|
|
146
|
+
function handleFocus(e) {
|
|
147
|
+
emit("focus", e);
|
|
148
|
+
}
|
|
149
|
+
__name(handleFocus, "handleFocus");
|
|
150
|
+
function handleBlur(e) {
|
|
151
|
+
emit("blur", e);
|
|
152
|
+
}
|
|
153
|
+
__name(handleBlur, "handleBlur");
|
|
154
|
+
function handleKeydown(e) {
|
|
155
|
+
emit("keydown", e);
|
|
156
|
+
}
|
|
157
|
+
__name(handleKeydown, "handleKeydown");
|
|
158
|
+
function handleClick(e) {
|
|
159
|
+
if (isDisabled.value)
|
|
160
|
+
return;
|
|
161
|
+
emit("click", e);
|
|
162
|
+
}
|
|
163
|
+
__name(handleClick, "handleClick");
|
|
164
|
+
(0, import_vue.watch)(() => modelValue.value, (newValue) => {
|
|
165
|
+
if (newValue) {
|
|
166
|
+
handleAdjustInputHeight();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
(0, import_vue.watchEffect)(() => {
|
|
170
|
+
var _a;
|
|
171
|
+
if (isForceFocus.value) {
|
|
172
|
+
(_a = input.value) == null ? void 0 : _a.focus();
|
|
173
|
+
}
|
|
174
|
+
if (hasChildren.value) {
|
|
175
|
+
rounded.value = "xl";
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
rootAttrs,
|
|
180
|
+
inputAttrs,
|
|
181
|
+
buttonAttrs,
|
|
182
|
+
wrapperAttrs,
|
|
183
|
+
isActive
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
__name(useAireneChatInput, "useAireneChatInput");
|
|
187
|
+
|
|
188
|
+
// src/modules/airene-chat-input.props.ts
|
|
189
|
+
var aireneChatInputProps = {
|
|
190
|
+
id: {
|
|
191
|
+
type: String,
|
|
192
|
+
default: ""
|
|
193
|
+
},
|
|
194
|
+
modelValue: {
|
|
195
|
+
type: String,
|
|
196
|
+
default: ""
|
|
197
|
+
},
|
|
198
|
+
placeholder: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: "Ask something..."
|
|
201
|
+
},
|
|
202
|
+
maxlength: {
|
|
203
|
+
type: String
|
|
204
|
+
},
|
|
205
|
+
ariaLabel: {
|
|
206
|
+
type: String
|
|
207
|
+
},
|
|
208
|
+
ariaLabelledBy: {
|
|
209
|
+
type: String
|
|
210
|
+
},
|
|
211
|
+
isReadOnly: {
|
|
212
|
+
type: Boolean,
|
|
213
|
+
default: false
|
|
214
|
+
},
|
|
215
|
+
isDisabled: {
|
|
216
|
+
type: Boolean,
|
|
217
|
+
default: false
|
|
218
|
+
},
|
|
219
|
+
isInvalid: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
default: false
|
|
222
|
+
},
|
|
223
|
+
isRequired: {
|
|
224
|
+
type: Boolean,
|
|
225
|
+
default: false
|
|
226
|
+
},
|
|
227
|
+
isForceFocus: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
default: false
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// src/airene-chat-input.tsx
|
|
234
|
+
var MpAireneChatInput = (0, import_vue3.defineComponent)({
|
|
235
|
+
name: "MpSkeleton",
|
|
236
|
+
props: aireneChatInputProps,
|
|
237
|
+
setup(props, {
|
|
238
|
+
slots,
|
|
239
|
+
emit
|
|
240
|
+
}) {
|
|
241
|
+
const {
|
|
242
|
+
rootAttrs,
|
|
243
|
+
wrapperAttrs,
|
|
244
|
+
inputAttrs,
|
|
245
|
+
buttonAttrs
|
|
246
|
+
} = useAireneChatInput(props, emit, slots);
|
|
247
|
+
return () => {
|
|
248
|
+
const children = slots.default && slots.default();
|
|
249
|
+
return (0, import_vue2.createVNode)("div", rootAttrs.value, [(0, import_vue2.createVNode)("div", wrapperAttrs.value, [(0, import_vue2.createVNode)("textarea", inputAttrs.value, null), children]), (0, import_vue2.createVNode)(import_pixel3_icon.MpIcon, buttonAttrs.value, null)]);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
254
|
+
0 && (module.exports = {
|
|
255
|
+
MpAireneChatInput
|
|
256
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/airene-chat-input.hooks.ts":{"bytes":4389,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/airene-chat-input.props.ts":{"bytes":1344,"imports":[],"format":"esm"},"src/airene-chat-input.tsx":{"bytes":941,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-icon","kind":"import-statement","external":true},{"path":"src/modules/airene-chat-input.hooks.ts","kind":"import-statement","original":"./modules/airene-chat-input.hooks"},{"path":"src/modules/airene-chat-input.props.ts","kind":"import-statement","original":"./modules/airene-chat-input.props"}],"format":"esm"},"src/index.ts":{"bytes":141,"imports":[{"path":"src/airene-chat-input.tsx","kind":"import-statement","original":"./airene-chat-input"}],"format":"esm"}},"outputs":{"dist/airene-chat-input.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-icon","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/airene-chat-input.tsx","inputs":{"src/airene-chat-input.tsx":{"bytesInOutput":972},"src/modules/airene-chat-input.hooks.ts":{"bytesInOutput":4659},"src/modules/airene-chat-input.props.ts":{"bytesInOutput":617}},"bytes":7394},"dist/index.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-icon","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":139},"src/airene-chat-input.tsx":{"bytesInOutput":791},"src/modules/airene-chat-input.hooks.ts":{"bytesInOutput":4659},"src/modules/airene-chat-input.props.ts":{"bytesInOutput":617}},"bytes":7369},"dist/modules/airene-chat-input.hooks.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/airene-chat-input.hooks.ts","inputs":{"src/modules/airene-chat-input.hooks.ts":{"bytesInOutput":4860}},"bytes":5904},"dist/modules/airene-chat-input.props.js":{"imports":[],"exports":[],"entryPoint":"src/modules/airene-chat-input.props.ts","inputs":{"src/modules/airene-chat-input.props.ts":{"bytesInOutput":977}},"bytes":1956}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/airene-chat-input.hooks.ts":{"bytes":4389,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/airene-chat-input.props.ts":{"bytes":1344,"imports":[],"format":"esm"},"src/airene-chat-input.tsx":{"bytes":941,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-icon","kind":"import-statement","external":true},{"path":"src/modules/airene-chat-input.hooks.ts","kind":"import-statement","original":"./modules/airene-chat-input.hooks"},{"path":"src/modules/airene-chat-input.props.ts","kind":"import-statement","original":"./modules/airene-chat-input.props"}],"format":"esm"},"src/index.ts":{"bytes":141,"imports":[{"path":"src/airene-chat-input.tsx","kind":"import-statement","original":"./airene-chat-input"}],"format":"esm"}},"outputs":{"dist/airene-chat-input.mjs":{"imports":[{"path":"dist/chunk-2K4QROIN.mjs","kind":"import-statement"},{"path":"dist/chunk-KPLBIBRE.mjs","kind":"import-statement"},{"path":"dist/chunk-4PYKLJPU.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpAireneChatInput"],"entryPoint":"src/airene-chat-input.tsx","inputs":{},"bytes":185},"dist/index.mjs":{"imports":[{"path":"dist/chunk-2K4QROIN.mjs","kind":"import-statement"},{"path":"dist/chunk-KPLBIBRE.mjs","kind":"import-statement"},{"path":"dist/chunk-4PYKLJPU.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpAireneChatInput"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":185},"dist/chunk-2K4QROIN.mjs":{"imports":[{"path":"dist/chunk-KPLBIBRE.mjs","kind":"import-statement"},{"path":"dist/chunk-4PYKLJPU.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-icon","kind":"import-statement","external":true}],"exports":["MpAireneChatInput"],"inputs":{"src/airene-chat-input.tsx":{"bytesInOutput":702}},"bytes":889},"dist/modules/airene-chat-input.hooks.mjs":{"imports":[{"path":"dist/chunk-KPLBIBRE.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["useAireneChatInput"],"entryPoint":"src/modules/airene-chat-input.hooks.ts","inputs":{},"bytes":127},"dist/chunk-KPLBIBRE.mjs":{"imports":[{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/tokens","kind":"import-statement","external":true}],"exports":["useAireneChatInput"],"inputs":{"src/modules/airene-chat-input.hooks.ts":{"bytesInOutput":4388}},"bytes":4514},"dist/modules/airene-chat-input.props.mjs":{"imports":[{"path":"dist/chunk-4PYKLJPU.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["aireneChatInputEmit","aireneChatInputProps"],"entryPoint":"src/modules/airene-chat-input.props.ts","inputs":{},"bytes":177},"dist/chunk-4PYKLJPU.mjs":{"imports":[],"exports":["aireneChatInputEmit","aireneChatInputProps"],"inputs":{"src/modules/airene-chat-input.props.ts":{"bytesInOutput":722}},"bytes":823},"dist/chunk-QZ7VFGWC.mjs":{"imports":[],"exports":["__name"],"inputs":{},"bytes":151}}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Slots, HTMLAttributes } from 'vue';
|
|
3
|
+
import { AireneChatInputProps, AireneChatInputEmits } from './airene-chat-input.props.mjs';
|
|
4
|
+
|
|
5
|
+
declare function useAireneChatInput(props: AireneChatInputProps, emit: AireneChatInputEmits, slots: Slots): {
|
|
6
|
+
rootAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
7
|
+
inputAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
8
|
+
buttonAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
9
|
+
wrapperAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
10
|
+
isActive: vue.ComputedRef<boolean>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useAireneChatInput };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Slots, HTMLAttributes } from 'vue';
|
|
3
|
+
import { AireneChatInputProps, AireneChatInputEmits } from './airene-chat-input.props.js';
|
|
4
|
+
|
|
5
|
+
declare function useAireneChatInput(props: AireneChatInputProps, emit: AireneChatInputEmits, slots: Slots): {
|
|
6
|
+
rootAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
7
|
+
inputAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
8
|
+
buttonAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
9
|
+
wrapperAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
10
|
+
isActive: vue.ComputedRef<boolean>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useAireneChatInput };
|
|
@@ -0,0 +1,183 @@
|
|
|
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/airene-chat-input.hooks.ts
|
|
22
|
+
var airene_chat_input_hooks_exports = {};
|
|
23
|
+
__export(airene_chat_input_hooks_exports, {
|
|
24
|
+
useAireneChatInput: () => useAireneChatInput
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(airene_chat_input_hooks_exports);
|
|
27
|
+
var import_vue = require("vue");
|
|
28
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
29
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
30
|
+
var import_tokens = require("@mekari/pixel3-styled-system/tokens");
|
|
31
|
+
function useAireneChatInput(props, emit, slots) {
|
|
32
|
+
const {
|
|
33
|
+
id,
|
|
34
|
+
modelValue,
|
|
35
|
+
placeholder,
|
|
36
|
+
maxlength,
|
|
37
|
+
ariaLabel,
|
|
38
|
+
ariaLabelledBy,
|
|
39
|
+
isReadOnly,
|
|
40
|
+
isDisabled,
|
|
41
|
+
isInvalid,
|
|
42
|
+
isRequired,
|
|
43
|
+
isForceFocus
|
|
44
|
+
} = (0, import_vue.toRefs)(props);
|
|
45
|
+
const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "airene-chat-input").value;
|
|
46
|
+
const input = (0, import_vue.ref)();
|
|
47
|
+
const inputHeight = (0, import_vue.ref)("20px");
|
|
48
|
+
const rounded = (0, import_vue.ref)("full");
|
|
49
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
50
|
+
return {
|
|
51
|
+
"data-pixel-component": "MpAireneChatInput",
|
|
52
|
+
id: getId,
|
|
53
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().root,
|
|
54
|
+
disabled: isDisabled.value || void 0,
|
|
55
|
+
"data-invalid": isInvalid.value || void 0,
|
|
56
|
+
style: {
|
|
57
|
+
borderRadius: import_tokens.token.var(`radii.${rounded.value}`)
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const wrapperAttrs = (0, import_vue.computed)(() => {
|
|
62
|
+
return {
|
|
63
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().wrapper
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const inputAttrs = (0, import_vue.computed)(() => {
|
|
67
|
+
return {
|
|
68
|
+
ref: input,
|
|
69
|
+
id: `${getId}--input`,
|
|
70
|
+
class: (0, import_recipes.aireneInputSlotRecipe)().input,
|
|
71
|
+
value: modelValue.value,
|
|
72
|
+
placeholder: placeholder.value,
|
|
73
|
+
rows: "1",
|
|
74
|
+
autocomplete: "off",
|
|
75
|
+
spellcheck: "false",
|
|
76
|
+
maxlength: maxlength == null ? void 0 : maxlength.value,
|
|
77
|
+
disabled: isDisabled.value,
|
|
78
|
+
readonly: isReadOnly.value,
|
|
79
|
+
required: isRequired.value,
|
|
80
|
+
"aria-label": ariaLabel == null ? void 0 : ariaLabel.value,
|
|
81
|
+
"aria-labelledby": ariaLabelledBy == null ? void 0 : ariaLabelledBy.value,
|
|
82
|
+
"aria-readonly": (isReadOnly == null ? void 0 : isReadOnly.value) || void 0,
|
|
83
|
+
"aria-required": (isRequired == null ? void 0 : isRequired.value) || void 0,
|
|
84
|
+
"aria-invalid": isInvalid.value || void 0,
|
|
85
|
+
style: {
|
|
86
|
+
height: inputHeight.value
|
|
87
|
+
},
|
|
88
|
+
onInput: handleInput,
|
|
89
|
+
onChange: handleChange,
|
|
90
|
+
onFocus: handleFocus,
|
|
91
|
+
onBlur: handleBlur,
|
|
92
|
+
onKeydown: handleKeydown,
|
|
93
|
+
onClick: handleSelectAllText
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
const buttonAttrs = (0, import_vue.computed)(() => {
|
|
97
|
+
return {
|
|
98
|
+
name: "sent",
|
|
99
|
+
variant: isActive.value ? "fill" : "outline",
|
|
100
|
+
color: isActive.value ? "icon.brand" : "icon.default",
|
|
101
|
+
onClick: handleClick
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
const isActive = (0, import_vue.computed)(() => {
|
|
105
|
+
return modelValue.value.length > 0;
|
|
106
|
+
});
|
|
107
|
+
const hasChildren = (0, import_vue.computed)(() => {
|
|
108
|
+
return slots.default && slots.default().length > 0;
|
|
109
|
+
});
|
|
110
|
+
function handleInput(e) {
|
|
111
|
+
const target = e.target;
|
|
112
|
+
emit("input", target.value, e);
|
|
113
|
+
emit("update:modelValue", target.value);
|
|
114
|
+
handleAdjustInputHeight();
|
|
115
|
+
}
|
|
116
|
+
__name(handleInput, "handleInput");
|
|
117
|
+
function handleChange(e) {
|
|
118
|
+
const target = e.target;
|
|
119
|
+
emit("change", target.value, e);
|
|
120
|
+
}
|
|
121
|
+
__name(handleChange, "handleChange");
|
|
122
|
+
function handleAdjustInputHeight() {
|
|
123
|
+
inputHeight.value = "auto";
|
|
124
|
+
(0, import_vue.nextTick)(() => {
|
|
125
|
+
const height = input.value.scrollHeight;
|
|
126
|
+
inputHeight.value = `${height}px`;
|
|
127
|
+
rounded.value = height >= 40 || hasChildren.value ? "xl" : "full";
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
__name(handleAdjustInputHeight, "handleAdjustInputHeight");
|
|
131
|
+
function handleSelectAllText(e) {
|
|
132
|
+
const target = e.target;
|
|
133
|
+
const textLabel = target.value;
|
|
134
|
+
if (textLabel) {
|
|
135
|
+
target.setSelectionRange(0, textLabel.length);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__name(handleSelectAllText, "handleSelectAllText");
|
|
139
|
+
function handleFocus(e) {
|
|
140
|
+
emit("focus", e);
|
|
141
|
+
}
|
|
142
|
+
__name(handleFocus, "handleFocus");
|
|
143
|
+
function handleBlur(e) {
|
|
144
|
+
emit("blur", e);
|
|
145
|
+
}
|
|
146
|
+
__name(handleBlur, "handleBlur");
|
|
147
|
+
function handleKeydown(e) {
|
|
148
|
+
emit("keydown", e);
|
|
149
|
+
}
|
|
150
|
+
__name(handleKeydown, "handleKeydown");
|
|
151
|
+
function handleClick(e) {
|
|
152
|
+
if (isDisabled.value)
|
|
153
|
+
return;
|
|
154
|
+
emit("click", e);
|
|
155
|
+
}
|
|
156
|
+
__name(handleClick, "handleClick");
|
|
157
|
+
(0, import_vue.watch)(() => modelValue.value, (newValue) => {
|
|
158
|
+
if (newValue) {
|
|
159
|
+
handleAdjustInputHeight();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
(0, import_vue.watchEffect)(() => {
|
|
163
|
+
var _a;
|
|
164
|
+
if (isForceFocus.value) {
|
|
165
|
+
(_a = input.value) == null ? void 0 : _a.focus();
|
|
166
|
+
}
|
|
167
|
+
if (hasChildren.value) {
|
|
168
|
+
rounded.value = "xl";
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
rootAttrs,
|
|
173
|
+
inputAttrs,
|
|
174
|
+
buttonAttrs,
|
|
175
|
+
wrapperAttrs,
|
|
176
|
+
isActive
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
__name(useAireneChatInput, "useAireneChatInput");
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
useAireneChatInput
|
|
183
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const aireneChatInputProps: {
|
|
4
|
+
id: {
|
|
5
|
+
type: PropType<string>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: PropType<string>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
placeholder: {
|
|
13
|
+
type: PropType<string>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
maxlength: {
|
|
17
|
+
type: PropType<string>;
|
|
18
|
+
};
|
|
19
|
+
ariaLabel: {
|
|
20
|
+
type: PropType<string>;
|
|
21
|
+
};
|
|
22
|
+
ariaLabelledBy: {
|
|
23
|
+
type: PropType<string>;
|
|
24
|
+
};
|
|
25
|
+
isReadOnly: {
|
|
26
|
+
type: PropType<boolean>;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
isDisabled: {
|
|
30
|
+
type: PropType<boolean>;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
isInvalid: {
|
|
34
|
+
type: PropType<boolean>;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
isRequired: {
|
|
38
|
+
type: PropType<boolean>;
|
|
39
|
+
default: boolean;
|
|
40
|
+
};
|
|
41
|
+
isForceFocus: {
|
|
42
|
+
type: PropType<boolean>;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare const aireneChatInputEmit: readonly ["change", "input", "keydown", "focus", "blur", "click", "update:modelValue"];
|
|
47
|
+
type AireneChatInputProps = ExtractPropTypes<typeof aireneChatInputProps>;
|
|
48
|
+
type AireneChatInputEmits = (event: (typeof aireneChatInputEmit)[number], value?: unknown, value2?: unknown) => void;
|
|
49
|
+
|
|
50
|
+
export { AireneChatInputEmits, AireneChatInputProps, aireneChatInputEmit, aireneChatInputProps };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const aireneChatInputProps: {
|
|
4
|
+
id: {
|
|
5
|
+
type: PropType<string>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: PropType<string>;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
placeholder: {
|
|
13
|
+
type: PropType<string>;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
maxlength: {
|
|
17
|
+
type: PropType<string>;
|
|
18
|
+
};
|
|
19
|
+
ariaLabel: {
|
|
20
|
+
type: PropType<string>;
|
|
21
|
+
};
|
|
22
|
+
ariaLabelledBy: {
|
|
23
|
+
type: PropType<string>;
|
|
24
|
+
};
|
|
25
|
+
isReadOnly: {
|
|
26
|
+
type: PropType<boolean>;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
isDisabled: {
|
|
30
|
+
type: PropType<boolean>;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
isInvalid: {
|
|
34
|
+
type: PropType<boolean>;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
isRequired: {
|
|
38
|
+
type: PropType<boolean>;
|
|
39
|
+
default: boolean;
|
|
40
|
+
};
|
|
41
|
+
isForceFocus: {
|
|
42
|
+
type: PropType<boolean>;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
declare const aireneChatInputEmit: readonly ["change", "input", "keydown", "focus", "blur", "click", "update:modelValue"];
|
|
47
|
+
type AireneChatInputProps = ExtractPropTypes<typeof aireneChatInputProps>;
|
|
48
|
+
type AireneChatInputEmits = (event: (typeof aireneChatInputEmit)[number], value?: unknown, value2?: unknown) => void;
|
|
49
|
+
|
|
50
|
+
export { AireneChatInputEmits, AireneChatInputProps, aireneChatInputEmit, aireneChatInputProps };
|