@telefonica/mistica 13.5.0 → 13.6.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.
package/dist/menu.js CHANGED
@@ -4,16 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>Y
7
+ get: ()=>rt
8
8
  });
9
9
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
10
  const _classnames = /*#__PURE__*/ _interopRequireDefault(require("classnames"));
11
- const _dynamic = require("@vanilla-extract/dynamic");
12
11
  const _keyCodesJs = require("./utils/key-codes.js");
13
12
  const _domJs = require("./utils/dom.js");
14
13
  const _overlayJs = /*#__PURE__*/ _interopRequireDefault(require("./overlay.js"));
15
14
  const _menuCssMisticaJs = require("./menu.css-mistica.js");
16
- const _sprinklesCssMisticaJs = require("./sprinkles.css-mistica.js");
15
+ const _hooksJs = require("./hooks.js");
16
+ const _portalJs = require("./portal.js");
17
+ const _dynamic = require("@vanilla-extract/dynamic");
17
18
  const _jsxRuntimeJs = require("./_virtual/jsx-runtime.js");
18
19
  function _interopRequireDefault(obj) {
19
20
  return obj && obj.__esModule ? obj : {
@@ -111,102 +112,105 @@ function _objectSpreadProps(target, source) {
111
112
  }
112
113
  return target;
113
114
  }
114
- const h = 416, Y = (param)=>{
115
- let { renderTarget: I , renderMenu: b , width: l , position: d = "left" , dataAttributes: v } = param;
116
- const [t, i] = _react.useState(!1), [a, w] = _react.useState(null), [u, y] = _react.useState(null), [H, x] = _react.useState(!1), [r, c] = _react.useState(null);
115
+ const J = 350, f = 400, v = 12, rt = (param)=>{
116
+ let { renderTarget: y , renderMenu: A , width: c = J , position: O = "left" , dataAttributes: P } = param;
117
+ const [e, i] = _react.useState(!1), [a, M] = _react.useState(null), [u, C] = _react.useState(null), [T, w] = _react.useState(!1), [s, m] = _react.useState(null), p = (0, _hooksJs.useWindowSize)();
117
118
  _react.useEffect(()=>{
118
- var M;
119
+ var I;
119
120
  const o = a == null ? void 0 : a.getBoundingClientRect();
120
- if (!u || !o || !t) {
121
- x(!1);
121
+ if (!u || !o || !e) {
122
+ w(!1);
122
123
  return;
123
124
  }
124
- const n = 12, { top: f , width: O , height: C } = o, m = f + C, P = (M = parseInt(window.getComputedStyle(u).getPropertyValue("height"))) != null ? M : 0, p = d === "left" ? "auto" : `calc(100% - ${O}px)`;
125
- if (m + P + n > window.innerHeight) {
126
- const T = window.innerHeight - m;
127
- f > T ? c({
128
- right: p,
129
- bottom: "100%",
130
- top: "auto",
131
- maxHeight: Math.min(f, h),
132
- transformOrigin: "center bottom"
133
- }) : c({
134
- top: "100%",
135
- bottom: "auto",
136
- right: p,
137
- maxHeight: Math.min(window.innerHeight - m - n, h),
138
- transformOrigin: "center top"
139
- });
140
- } else c({
141
- top: "100%",
125
+ const { top: n , width: $ , left: E , bottom: d } = o, g = (I = parseInt(window.getComputedStyle(u).getPropertyValue("height"))) != null ? I : 0, l = O === "left" ? E : E + $ - c, h = p.height - d - v, x = n - v, L = h > g, R = x > g;
126
+ L ? m({
127
+ left: l,
128
+ top: `${d}px`,
129
+ bottom: "auto",
130
+ maxHeight: f,
131
+ transformOrigin: "center top"
132
+ }) : R ? m({
133
+ left: l,
134
+ top: `${n - g}px`,
135
+ bottom: "auto",
136
+ maxHeight: f,
137
+ transformOrigin: "center bottom"
138
+ }) : h > x ? m({
139
+ left: l,
140
+ top: `${d}px`,
142
141
  bottom: "auto",
143
- right: p,
144
- maxHeight: Math.min(window.innerHeight - m - n, h),
142
+ maxHeight: Math.min(h, f),
145
143
  transformOrigin: "center top"
144
+ }) : m({
145
+ left: l,
146
+ top: "auto",
147
+ bottom: `${p.height - n}px`,
148
+ maxHeight: Math.min(x, f),
149
+ transformOrigin: "center bottom"
146
150
  });
147
- let g;
148
- return t && (g = requestAnimationFrame(()=>{
149
- x(!0);
151
+ let S;
152
+ return e && (S = requestAnimationFrame(()=>{
153
+ w(!0);
150
154
  })), ()=>{
151
- g && cancelAnimationFrame(g);
155
+ S && cancelAnimationFrame(S);
152
156
  };
153
157
  }, [
154
- d,
155
- t,
158
+ O,
159
+ e,
156
160
  u,
157
161
  a,
158
- l
162
+ c,
163
+ p
159
164
  ]);
160
- const A = _react.useMemo(()=>({
161
- ref: w,
165
+ const D = _react.useMemo(()=>({
166
+ ref: M,
162
167
  onPress: ()=>{
163
- i(!t);
168
+ i(!e);
164
169
  }
165
170
  }), [
166
- w,
167
- t,
171
+ M,
172
+ e,
168
173
  i
169
- ]), E = _react.useMemo(()=>({
170
- ref: y,
171
- className: (0, _classnames.default)(_menuCssMisticaJs.menuContainer, H ? _menuCssMisticaJs.showItems : _menuCssMisticaJs.hideItems),
174
+ ]), F = _react.useMemo(()=>({
175
+ ref: C,
176
+ className: (0, _classnames.default)(_menuCssMisticaJs.menuContainer, T ? _menuCssMisticaJs.showItems : _menuCssMisticaJs.hideItems),
172
177
  close: ()=>{
173
178
  i(!1);
174
179
  }
175
180
  }), [
176
- H
181
+ T
177
182
  ]);
178
183
  return _react.useEffect(()=>{
179
184
  const o = (n)=>{
180
- t && (n.keyCode === _keyCodesJs.TAB && (0, _domJs.cancelEvent)(n), n.keyCode === _keyCodesJs.ESC && i(!1));
185
+ e && (n.keyCode === _keyCodesJs.TAB && (0, _domJs.cancelEvent)(n), n.keyCode === _keyCodesJs.ESC && i(!1));
181
186
  };
182
187
  return document.addEventListener("keydown", o, !1), ()=>{
183
188
  document.removeEventListener("keydown", o, !1);
184
189
  };
185
- }), /* @__PURE__ */ (0, _jsxRuntimeJs.jsxs)("div", _objectSpreadProps(_objectSpread({
186
- className: (0, _sprinklesCssMisticaJs.sprinkles)({
187
- position: "relative"
188
- }),
189
- style: _objectSpread({}, (0, _dynamic.assignInlineVars)(_objectSpread({
190
- [_menuCssMisticaJs.vars.width]: l ? `${l}px` : "100%"
191
- }, r ? {
192
- [_menuCssMisticaJs.vars.top]: r.top,
193
- [_menuCssMisticaJs.vars.bottom]: r.bottom,
194
- [_menuCssMisticaJs.vars.right]: r.right,
195
- [_menuCssMisticaJs.vars.transformOrigin]: r.transformOrigin,
196
- [_menuCssMisticaJs.vars.maxHeight]: `${r.maxHeight}px`
197
- } : {})))
198
- }, (0, _domJs.getPrefixedDataAttributes)(v, "Menu")), {
190
+ }), /* @__PURE__ */ (0, _jsxRuntimeJs.jsxs)("div", _objectSpreadProps(_objectSpread({}, (0, _domJs.getPrefixedDataAttributes)(P, "Menu")), {
199
191
  children: [
200
- t ? /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)(_overlayJs.default, {
201
- onPress: (o)=>{
202
- (0, _domJs.cancelEvent)(o), i(!1);
203
- },
204
- disableScroll: !0
205
- }) : null,
206
- I(_objectSpreadProps(_objectSpread({}, A), {
207
- isMenuOpen: t
192
+ y(_objectSpreadProps(_objectSpread({}, D), {
193
+ isMenuOpen: e
208
194
  })),
209
- t ? b(E) : null
195
+ e ? /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)(_portalJs.Portal, {
196
+ children: /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)(_overlayJs.default, {
197
+ onPress: (o)=>{
198
+ (0, _domJs.cancelEvent)(o), i(!1);
199
+ },
200
+ disableScroll: !0,
201
+ children: /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)("div", {
202
+ style: _objectSpread({}, (0, _dynamic.assignInlineVars)(_objectSpread({}, s ? {
203
+ [_menuCssMisticaJs.vars.top]: s.top,
204
+ [_menuCssMisticaJs.vars.bottom]: s.bottom,
205
+ [_menuCssMisticaJs.vars.left]: `${s.left}px`,
206
+ [_menuCssMisticaJs.vars.transformOrigin]: s.transformOrigin,
207
+ [_menuCssMisticaJs.vars.maxHeight]: `${s.maxHeight}px`,
208
+ [_menuCssMisticaJs.vars.width]: `${c}px`
209
+ } : {}))),
210
+ children: A(F)
211
+ })
212
+ })
213
+ }) : null
210
214
  ]
211
215
  }));
212
216
  };
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "PACKAGE_VERSION", {
6
6
  enumerable: true,
7
7
  get: ()=>o
8
8
  });
9
- const o = "13.5.0";
9
+ const o = "13.6.1";
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
- get: ()=>q
7
+ get: ()=>z
8
8
  });
9
9
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
10
  const _formContextJs = require("./form-context.js");
11
11
  const _textFieldBaseJs = require("./text-field-base.js");
12
12
  const _commonJs = require("./utils/common.js");
13
+ const _domJs = require("./utils/dom.js");
14
+ const _hooksJs = require("./hooks.js");
13
15
  const _jsxRuntimeJs = require("./_virtual/jsx-runtime.js");
14
16
  function _getRequireWildcardCache(nodeInterop) {
15
17
  if (typeof WeakMap !== "function") return null;
@@ -129,8 +131,17 @@ function _objectWithoutPropertiesLoose(source, excluded) {
129
131
  }
130
132
  return target;
131
133
  }
132
- const q = /*#__PURE__*/ _react.forwardRef((_param, v)=>{
133
- var { disabled: n , error: s , helperText: f , name: o , optional: m , validate: a , onChangeValue: p , onChange: R , value: d , defaultValue: x , onBlur: r , onFocus: i , onPress: T } = _param, u = _objectWithoutProperties(_param, [
134
+ const F = (c, t, r, i)=>{
135
+ (0, _hooksJs.useIsomorphicLayoutEffect)(()=>{
136
+ c && t && r && t.length > r && i && i((0, _domJs.createChangeEvent)(c, t.slice(0, r)));
137
+ }, [
138
+ i,
139
+ t,
140
+ r,
141
+ c
142
+ ]);
143
+ }, z = /*#__PURE__*/ _react.forwardRef((_param, g)=>{
144
+ var { disabled: c , error: t , helperText: r , name: i , optional: m , validate: a , onChangeValue: p , onChange: R , value: d , defaultValue: T , onBlur: u , onFocus: l , onPress: x } = _param, s = _objectWithoutProperties(_param, [
134
145
  "disabled",
135
146
  "error",
136
147
  "helperText",
@@ -145,33 +156,33 @@ const q = /*#__PURE__*/ _react.forwardRef((_param, v)=>{
145
156
  "onFocus",
146
157
  "onPress"
147
158
  ]);
148
- const e = _react.useRef(null), g = (t)=>t, b = (t)=>{
149
- u.multiline && e.current && (e.current.scrollTop = 0), r == null || r(t);
150
- }, h = (t)=>{
151
- u.multiline && setTimeout(()=>{
159
+ const e = _react.useRef(null), v = (o)=>o, h = (o)=>{
160
+ s.multiline && e.current && (e.current.scrollTop = 0), u == null || u(o);
161
+ }, y = (o)=>{
162
+ s.multiline && setTimeout(()=>{
152
163
  if (e.current) {
153
- const j = e.current.value;
154
- e.current.value = "", e.current.value = j, e.current.scrollTop = e.current.scrollHeight;
164
+ const E = e.current.value;
165
+ e.current.value = "", e.current.value = E, e.current.scrollTop = e.current.scrollHeight;
155
166
  }
156
- }, 0), i == null || i(t);
157
- }, l = (0, _formContextJs.useFieldProps)({
158
- name: o,
167
+ }, 0), l == null || l(o);
168
+ }, f = (0, _formContextJs.useFieldProps)({
169
+ name: i,
159
170
  value: d,
160
- defaultValue: x,
161
- processValue: g,
162
- helperText: f,
171
+ defaultValue: T,
172
+ processValue: v,
173
+ helperText: r,
163
174
  optional: m,
164
- error: s,
165
- disabled: n,
166
- onBlur: b,
175
+ error: t,
176
+ disabled: c,
177
+ onBlur: h,
167
178
  validate: a,
168
179
  onChange: R,
169
180
  onChangeValue: p
170
181
  });
171
- return /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)(_textFieldBaseJs.TextFieldBaseAutosuggest, _objectSpreadProps(_objectSpread({}, u, l), {
172
- onClick: T,
173
- inputRef: (0, _commonJs.combineRefs)(e, l.inputRef, v),
174
- onFocus: h,
182
+ return F(e.current, f.value, s.maxLength, f.onChange), /* @__PURE__ */ (0, _jsxRuntimeJs.jsx)(_textFieldBaseJs.TextFieldBaseAutosuggest, _objectSpreadProps(_objectSpread({}, s, f), {
183
+ onClick: x,
184
+ inputRef: (0, _commonJs.combineRefs)(e, f.inputRef, g),
185
+ onFocus: y,
175
186
  type: "text"
176
187
  }));
177
188
  });
package/dist/text.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface TextPresetProps {
15
15
  role?: string;
16
16
  'aria-level'?: number;
17
17
  dataAttributes?: DataAttributes;
18
+ forceMobileSizes?: boolean;
19
+ textShadow?: string;
18
20
  }
19
21
  interface TextProps extends TextPresetProps {
20
22
  weight?: FontWeight;
@@ -31,6 +33,7 @@ interface TextProps extends TextPresetProps {
31
33
  /** in pixels, will be converted to rem in runtime */
32
34
  desktopLineHeight?: string | number;
33
35
  letterSpacing?: number;
36
+ forzeMobileSize?: never;
34
37
  }
35
38
  export declare const Text: React.FC<TextProps>;
36
39
  interface LightProps extends TextPresetProps {