@micromag/element-text-input 0.4.71 → 0.4.74

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 (2) hide show
  1. package/es/index.js +291 -85
  2. package/package.json +9 -7
package/es/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
+ import { c } from 'react/compiler-runtime';
3
2
  import classNames from 'classnames';
4
3
  import { useId } from 'react';
5
4
  import { usePlaceholderStyle } from '@micromag/core/hooks';
@@ -8,99 +7,306 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
7
 
9
8
  var styles = {"container":"micromag-element-text-input-container","element":"micromag-element-text-input-element"};
10
9
 
11
- function TextInput(_ref) {
12
- var _ref$label = _ref.label,
13
- label = _ref$label === void 0 ? null : _ref$label,
14
- _ref$labelOutside = _ref.labelOutside,
15
- labelOutside = _ref$labelOutside === void 0 ? false : _ref$labelOutside,
16
- _ref$labelClassName = _ref.labelClassName,
17
- labelClassName = _ref$labelClassName === void 0 ? null : _ref$labelClassName,
18
- _ref$textStyle = _ref.textStyle,
19
- textStyle = _ref$textStyle === void 0 ? null : _ref$textStyle,
20
- _ref$placeholderTextS = _ref.placeholderTextStyle,
21
- placeholderTextStyle = _ref$placeholderTextS === void 0 ? null : _ref$placeholderTextS,
22
- _ref$buttonStyle = _ref.buttonStyle,
23
- buttonStyle = _ref$buttonStyle === void 0 ? null : _ref$buttonStyle,
24
- _ref$labelOutsideStyl = _ref.labelOutsideStyle,
25
- labelOutsideStyle = _ref$labelOutsideStyl === void 0 ? null : _ref$labelOutsideStyl,
26
- _ref$margin = _ref.margin,
27
- margin = _ref$margin === void 0 ? null : _ref$margin,
28
- _ref$multiline = _ref.multiline,
29
- multiline = _ref$multiline === void 0 ? false : _ref$multiline,
30
- _ref$value = _ref.value,
31
- value = _ref$value === void 0 ? '' : _ref$value,
32
- _ref$onChange = _ref.onChange,
33
- onChange = _ref$onChange === void 0 ? null : _ref$onChange,
34
- _ref$onFocus = _ref.onFocus,
35
- onFocus = _ref$onFocus === void 0 ? null : _ref$onFocus,
36
- _ref$onBlur = _ref.onBlur,
37
- onBlur = _ref$onBlur === void 0 ? null : _ref$onBlur,
38
- _ref$required = _ref.required,
39
- required = _ref$required === void 0 ? false : _ref$required,
40
- _ref$disabled = _ref.disabled,
41
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
42
- _ref$focusable = _ref.focusable,
43
- focusable = _ref$focusable === void 0 ? true : _ref$focusable,
44
- _ref$className = _ref.className,
45
- className = _ref$className === void 0 ? null : _ref$className;
46
- var containerStyle = {};
47
- var labelStyle = {};
48
- var elementStyle = {};
49
- var placeholderStyle = {};
50
- var id = useId();
10
+ function TextInput(t0) {
11
+ const $ = c(56);
12
+ const {
13
+ label: t1,
14
+ labelOutside: t2,
15
+ labelClassName: t3,
16
+ textStyle: t4,
17
+ placeholderTextStyle: t5,
18
+ buttonStyle: t6,
19
+ labelOutsideStyle: t7,
20
+ margin: t8,
21
+ multiline: t9,
22
+ value: t10,
23
+ onChange: t11,
24
+ onFocus: t12,
25
+ onBlur: t13,
26
+ required: t14,
27
+ disabled: t15,
28
+ focusable: t16,
29
+ className: t17
30
+ } = t0;
31
+ const label = t1 === undefined ? null : t1;
32
+ const labelOutside = t2 === undefined ? false : t2;
33
+ const labelClassName = t3 === undefined ? null : t3;
34
+ const textStyle = t4 === undefined ? null : t4;
35
+ const placeholderTextStyle = t5 === undefined ? null : t5;
36
+ const buttonStyle = t6 === undefined ? null : t6;
37
+ const labelOutsideStyle = t7 === undefined ? null : t7;
38
+ const margin = t8 === undefined ? null : t8;
39
+ const multiline = t9 === undefined ? false : t9;
40
+ const value = t10 === undefined ? "" : t10;
41
+ const onChange = t11 === undefined ? null : t11;
42
+ const onFocus = t12 === undefined ? null : t12;
43
+ const onBlur = t13 === undefined ? null : t13;
44
+ const required = t14 === undefined ? false : t14;
45
+ const disabled = t15 === undefined ? false : t15;
46
+ const focusable = t16 === undefined ? true : t16;
47
+ const className = t17 === undefined ? null : t17;
48
+ let t18;
49
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
50
+ t18 = {};
51
+ $[0] = t18;
52
+ } else {
53
+ t18 = $[0];
54
+ }
55
+ let containerStyle = t18;
56
+ let t19;
57
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
58
+ t19 = {};
59
+ $[1] = t19;
60
+ } else {
61
+ t19 = $[1];
62
+ }
63
+ let labelStyle = t19;
64
+ let t20;
65
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
66
+ t20 = {};
67
+ $[2] = t20;
68
+ } else {
69
+ t20 = $[2];
70
+ }
71
+ let elementStyle = t20;
72
+ let t21;
73
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
74
+ t21 = {};
75
+ $[3] = t21;
76
+ } else {
77
+ t21 = $[3];
78
+ }
79
+ let placeholderStyle = t21;
80
+ const id = useId();
51
81
  if (margin !== null) {
52
- containerStyle = _objectSpread(_objectSpread({}, containerStyle), getStyleFromMargin(margin));
82
+ const t22 = containerStyle;
83
+ let t23;
84
+ if ($[4] !== margin) {
85
+ t23 = getStyleFromMargin(margin);
86
+ $[4] = margin;
87
+ $[5] = t23;
88
+ } else {
89
+ t23 = $[5];
90
+ }
91
+ let t24;
92
+ if ($[6] !== t23) {
93
+ t24 = {
94
+ ...t22,
95
+ ...t23
96
+ };
97
+ $[6] = t23;
98
+ $[7] = t24;
99
+ } else {
100
+ t24 = $[7];
101
+ }
102
+ containerStyle = t24;
53
103
  }
54
104
  if (labelOutsideStyle !== null) {
55
- labelStyle = _objectSpread(_objectSpread({}, labelStyle), getStyleFromText(labelOutsideStyle));
105
+ const t22 = labelStyle;
106
+ let t23;
107
+ if ($[8] !== labelOutsideStyle) {
108
+ t23 = getStyleFromText(labelOutsideStyle);
109
+ $[8] = labelOutsideStyle;
110
+ $[9] = t23;
111
+ } else {
112
+ t23 = $[9];
113
+ }
114
+ let t24;
115
+ if ($[10] !== t23) {
116
+ t24 = {
117
+ ...t22,
118
+ ...t23
119
+ };
120
+ $[10] = t23;
121
+ $[11] = t24;
122
+ } else {
123
+ t24 = $[11];
124
+ }
125
+ labelStyle = t24;
56
126
  }
57
127
  if (textStyle !== null) {
58
- elementStyle = _objectSpread(_objectSpread({}, elementStyle), getStyleFromText(textStyle));
128
+ const t22 = elementStyle;
129
+ let t23;
130
+ if ($[12] !== textStyle) {
131
+ t23 = getStyleFromText(textStyle);
132
+ $[12] = textStyle;
133
+ $[13] = t23;
134
+ } else {
135
+ t23 = $[13];
136
+ }
137
+ let t24;
138
+ if ($[14] !== t23) {
139
+ t24 = {
140
+ ...t22,
141
+ ...t23
142
+ };
143
+ $[14] = t23;
144
+ $[15] = t24;
145
+ } else {
146
+ t24 = $[15];
147
+ }
148
+ elementStyle = t24;
59
149
  }
60
150
  if (buttonStyle !== null) {
61
- elementStyle = _objectSpread(_objectSpread({}, elementStyle), getStyleFromBox(buttonStyle));
151
+ const t22 = elementStyle;
152
+ let t23;
153
+ if ($[16] !== buttonStyle) {
154
+ t23 = getStyleFromBox(buttonStyle);
155
+ $[16] = buttonStyle;
156
+ $[17] = t23;
157
+ } else {
158
+ t23 = $[17];
159
+ }
160
+ let t24;
161
+ if ($[18] !== elementStyle || $[19] !== t23) {
162
+ t24 = {
163
+ ...t22,
164
+ ...t23
165
+ };
166
+ $[18] = elementStyle;
167
+ $[19] = t23;
168
+ $[20] = t24;
169
+ } else {
170
+ t24 = $[20];
171
+ }
172
+ elementStyle = t24;
62
173
  }
63
174
  if (placeholderTextStyle !== null) {
64
- placeholderStyle = _objectSpread(_objectSpread({}, placeholderStyle), getStyleFromText(placeholderTextStyle));
175
+ const t22 = placeholderStyle;
176
+ let t23;
177
+ if ($[21] !== placeholderTextStyle) {
178
+ t23 = getStyleFromText(placeholderTextStyle);
179
+ $[21] = placeholderTextStyle;
180
+ $[22] = t23;
181
+ } else {
182
+ t23 = $[22];
183
+ }
184
+ let t24;
185
+ if ($[23] !== t23) {
186
+ t24 = {
187
+ ...t22,
188
+ ...t23
189
+ };
190
+ $[23] = t23;
191
+ $[24] = t24;
192
+ } else {
193
+ t24 = $[24];
194
+ }
195
+ placeholderStyle = t24;
196
+ }
197
+ const t22 = !labelOutside;
198
+ let t23;
199
+ if ($[25] !== className || $[26] !== t22) {
200
+ t23 = classNames([styles.container, className, {
201
+ [styles.element]: t22
202
+ }, className]);
203
+ $[25] = className;
204
+ $[26] = t22;
205
+ $[27] = t23;
206
+ } else {
207
+ t23 = $[27];
208
+ }
209
+ let t24;
210
+ if ($[28] !== containerStyle || $[29] !== t23) {
211
+ t24 = {
212
+ className: t23,
213
+ style: containerStyle
214
+ };
215
+ $[28] = containerStyle;
216
+ $[29] = t23;
217
+ $[30] = t24;
218
+ } else {
219
+ t24 = $[30];
220
+ }
221
+ const containerProps = t24;
222
+ const t25 = !labelOutside ? containerProps : null;
223
+ const t26 = !labelOutside ? label : undefined;
224
+ let t27;
225
+ if ($[31] !== disabled || $[32] !== elementStyle || $[33] !== onBlur || $[34] !== onChange || $[35] !== onFocus || $[36] !== required || $[37] !== t25 || $[38] !== t26 || $[39] !== value) {
226
+ t27 = {
227
+ className: styles.element,
228
+ ...t25,
229
+ style: elementStyle,
230
+ placeholder: t26,
231
+ value,
232
+ onChange,
233
+ onFocus,
234
+ onBlur,
235
+ required,
236
+ disabled
237
+ };
238
+ $[31] = disabled;
239
+ $[32] = elementStyle;
240
+ $[33] = onBlur;
241
+ $[34] = onChange;
242
+ $[35] = onFocus;
243
+ $[36] = required;
244
+ $[37] = t25;
245
+ $[38] = t26;
246
+ $[39] = value;
247
+ $[40] = t27;
248
+ } else {
249
+ t27 = $[40];
250
+ }
251
+ const elementProps = t27;
252
+ let t28;
253
+ if ($[41] !== elementProps || $[42] !== focusable || $[43] !== id || $[44] !== multiline) {
254
+ t28 = multiline ? /*#__PURE__*/jsx("textarea", {
255
+ ...elementProps,
256
+ tabIndex: focusable ? 0 : -1,
257
+ id: `input-${id}`
258
+ }) : /*#__PURE__*/jsx("input", {
259
+ ...elementProps,
260
+ type: "text",
261
+ tabIndex: focusable ? 0 : -1,
262
+ id: `input-${id}`
263
+ });
264
+ $[41] = elementProps;
265
+ $[42] = focusable;
266
+ $[43] = id;
267
+ $[44] = multiline;
268
+ $[45] = t28;
269
+ } else {
270
+ t28 = $[45];
271
+ }
272
+ const element = t28;
273
+ const placeholderStyles = usePlaceholderStyle(`#input-${id}`, placeholderStyle);
274
+ let t29;
275
+ if ($[46] !== placeholderStyles) {
276
+ t29 = placeholderStyles !== null ? /*#__PURE__*/jsx("style", {
277
+ type: "text/css",
278
+ children: placeholderStyles
279
+ }) : null;
280
+ $[46] = placeholderStyles;
281
+ $[47] = t29;
282
+ } else {
283
+ t29 = $[47];
284
+ }
285
+ const placeholderStyleElement = t29;
286
+ let t30;
287
+ if ($[48] !== containerProps || $[49] !== element || $[50] !== label || $[51] !== labelClassName || $[52] !== labelOutside || $[53] !== labelStyle || $[54] !== placeholderStyleElement) {
288
+ t30 = !labelOutside ? /*#__PURE__*/jsxs(Fragment, {
289
+ children: [element, placeholderStyleElement]
290
+ }) : /*#__PURE__*/jsxs("label", {
291
+ ...containerProps,
292
+ children: [/*#__PURE__*/jsx("div", {
293
+ className: labelClassName,
294
+ style: labelStyle,
295
+ children: label
296
+ }), element, placeholderStyleElement]
297
+ });
298
+ $[48] = containerProps;
299
+ $[49] = element;
300
+ $[50] = label;
301
+ $[51] = labelClassName;
302
+ $[52] = labelOutside;
303
+ $[53] = labelStyle;
304
+ $[54] = placeholderStyleElement;
305
+ $[55] = t30;
306
+ } else {
307
+ t30 = $[55];
65
308
  }
66
- var containerProps = {
67
- className: classNames([styles.container, className, _defineProperty({}, styles.element, !labelOutside), className]),
68
- style: containerStyle
69
- };
70
- var elementProps = _objectSpread(_objectSpread({
71
- className: styles.element
72
- }, !labelOutside ? containerProps : null), {}, {
73
- style: elementStyle,
74
- placeholder: !labelOutside ? label : undefined,
75
- value: value,
76
- onChange: onChange,
77
- onFocus: onFocus,
78
- onBlur: onBlur,
79
- required: required,
80
- disabled: disabled
81
- });
82
- var element = multiline ? /*#__PURE__*/jsx("textarea", _objectSpread(_objectSpread({}, elementProps), {}, {
83
- tabIndex: focusable ? 0 : -1,
84
- id: "input-".concat(id)
85
- })) : /*#__PURE__*/jsx("input", _objectSpread(_objectSpread({}, elementProps), {}, {
86
- type: "text",
87
- tabIndex: focusable ? 0 : -1,
88
- id: "input-".concat(id)
89
- }));
90
- var placeholderStyles = usePlaceholderStyle("#input-".concat(id), placeholderStyle);
91
- var placeholderStyleElement = placeholderStyles !== null ? /*#__PURE__*/jsx("style", {
92
- type: "text/css",
93
- children: placeholderStyles
94
- }) : null;
95
- return !labelOutside ? /*#__PURE__*/jsxs(Fragment, {
96
- children: [element, placeholderStyleElement]
97
- }) : /*#__PURE__*/jsxs("label", _objectSpread(_objectSpread({}, containerProps), {}, {
98
- children: [/*#__PURE__*/jsx("div", {
99
- className: labelClassName,
100
- style: labelStyle,
101
- children: label
102
- }), element, placeholderStyleElement]
103
- }));
309
+ return t30;
104
310
  }
105
311
 
106
312
  export { TextInput as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-text-input",
3
- "version": "0.4.71",
3
+ "version": "0.4.74",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -32,9 +32,11 @@
32
32
  "license": "ISC",
33
33
  "type": "module",
34
34
  "module": "es/index.js",
35
+ "style": "./assets/css/styles.css",
35
36
  "exports": {
36
37
  ".": {
37
38
  "types": "./es/index.d.ts",
39
+ "style": "./assets/css/styles.css",
38
40
  "import": "./es/index.js"
39
41
  },
40
42
  "./assets/css/styles": "./assets/css/styles.css",
@@ -51,16 +53,16 @@
51
53
  "build": "../../scripts/prepare-package.sh --types"
52
54
  },
53
55
  "devDependencies": {
54
- "react": "^18.3.0 || ^19.0.0",
55
- "react-dom": "^18.3.0 || ^19.0.0"
56
+ "react": "^19.0.0",
57
+ "react-dom": "^19.0.0"
56
58
  },
57
59
  "peerDependencies": {
58
- "react": "^18.3.0 || ^19.0.0",
59
- "react-dom": "^18.3.0 || ^19.0.0"
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0"
60
62
  },
61
63
  "dependencies": {
62
64
  "@babel/runtime": "^7.28.6",
63
- "@micromag/core": "^0.4.71",
65
+ "@micromag/core": "^0.4.74",
64
66
  "classnames": "^2.2.6",
65
67
  "react-helmet": "^6.1.0"
66
68
  },
@@ -68,6 +70,6 @@
68
70
  "access": "public",
69
71
  "registry": "https://registry.npmjs.org/"
70
72
  },
71
- "gitHead": "9101554bc5761e32b4a002a10d26800608c69773",
73
+ "gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
72
74
  "types": "es/index.d.ts"
73
75
  }