@telefonica/mistica 10.22.0 → 10.23.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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [10.23.0](https://github.com/Telefonica/mistica-web/compare/v10.22.3...v10.23.0) (2022-02-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Dialog:** allow disable history update in dialogs ([#412](https://github.com/Telefonica/mistica-web/issues/412)) ([178bc55](https://github.com/Telefonica/mistica-web/commit/178bc55abc19f0d9117d0a51bbcb5a8a2353f68e))
7
+
8
+ ## [10.22.3](https://github.com/Telefonica/mistica-web/compare/v10.22.2...v10.22.3) (2022-02-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **Form:** handle undefined rawValue ([#410](https://github.com/Telefonica/mistica-web/issues/410)) ([6363328](https://github.com/Telefonica/mistica-web/commit/63633288d1a9a1781b9bf350c4923af101a72312))
14
+
15
+ ## [10.22.2](https://github.com/Telefonica/mistica-web/compare/v10.22.1...v10.22.2) (2022-02-07)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **Select:** set rawValue on init ([#409](https://github.com/Telefonica/mistica-web/issues/409)) ([d72cbd1](https://github.com/Telefonica/mistica-web/commit/d72cbd179e930712ef54c5e483e08c922a857059))
21
+
22
+ ## [10.22.1](https://github.com/Telefonica/mistica-web/compare/v10.22.0...v10.22.1) (2022-02-03)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **Form fields:** use rawValue to check if a form field is empty ([#408](https://github.com/Telefonica/mistica-web/issues/408)) ([50a5d37](https://github.com/Telefonica/mistica-web/commit/50a5d37179903ed69f1aa33ac6b7e5d6b1f10a6f))
28
+
1
29
  # [10.22.0](https://github.com/Telefonica/mistica-web/compare/v10.21.0...v10.22.0) (2022-02-02)
2
30
 
3
31
 
package/dist/dialog.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import type { Theme } from './theme';
2
3
  interface DialogProps {
3
4
  className?: string;
4
5
  title?: string;
@@ -20,6 +21,7 @@ declare type DialogRootState = {
20
21
  instanceNumber: number;
21
22
  };
22
23
  export default class DialogRoot extends React.Component<DialogRootProps, DialogRootState> {
24
+ static contextType: React.Context<Theme | null>;
23
25
  state: DialogRootState;
24
26
  componentDidMount(): void;
25
27
  componentWillUnmount(): void;
package/dist/dialog.js CHANGED
@@ -560,7 +560,9 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
560
560
  dialogRootInstances++;
561
561
  if (dialogRootInstances === 1) {
562
562
  dialogInstance = this;
563
- window.addEventListener('popstate', this.handleBack);
563
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
564
+ window.addEventListener('popstate', this.handleBack);
565
+ }
564
566
  }
565
567
  }
566
568
  },
@@ -570,7 +572,9 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
570
572
  dialogRootInstances--;
571
573
  if (dialogRootInstances === 0) {
572
574
  dialogInstance = null;
573
- window.removeEventListener('popstate', this.handleBack);
575
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
576
+ window.removeEventListener('popstate', this.handleBack);
577
+ }
574
578
  }
575
579
  }
576
580
  },
@@ -580,8 +584,10 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
580
584
  if (this.state.dialogProps) {
581
585
  throw Error('Tried to show a dialog on top of another dialog. This functionality is not currently supported.');
582
586
  }
583
- // We add an additional entry to history with the same page, so the first time back is pressed we only close the Dialog
584
- window.history.pushState(null, document.title, window.location.href);
587
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
588
+ // We add an additional entry to history with the same page, so the first time back is pressed we only close the Dialog
589
+ window.history.pushState(null, document.title, window.location.href);
590
+ }
585
591
  this.setState({
586
592
  dialogProps: props,
587
593
  isClosing: false
@@ -591,8 +597,12 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
591
597
  {
592
598
  key: "close",
593
599
  value: function close() {
594
- // Here we have to remove the additional entry added to history when we created the Dialog
595
- window.history.back();
600
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
601
+ // Here we have to remove the additional entry added to history when we created the Dialog
602
+ window.history.back();
603
+ } else {
604
+ this.handleBack();
605
+ }
596
606
  }
597
607
  },
598
608
  {
@@ -651,6 +661,7 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
651
661
  ]);
652
662
  return DialogRoot;
653
663
  }(React.Component);
664
+ DialogRoot.contextType = _themeContext.default;
654
665
  exports.default = DialogRoot;
655
666
  var showDialog = function showDialog(param) {
656
667
  var showCancel = param === void 0 ? false : param;
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
 
3
3
  import * as React from "react";
4
+ import type { Theme } from "./theme";
4
5
  declare type DialogProps = {
5
6
  className?: string,
6
7
  title?: string,
@@ -24,6 +25,7 @@ declare type DialogRootState = {
24
25
  declare export default class DialogRoot
25
26
  mixins React.Component<DialogRootProps, DialogRootState>
26
27
  {
28
+ static contextType: React.Context<Theme | null>;
27
29
  state: DialogRootState;
28
30
  componentDidMount(): void;
29
31
  componentWillUnmount(): void;
package/dist/form.js CHANGED
@@ -179,10 +179,11 @@ var Form = function Form(param) {
179
179
  for(var _iterator = fieldRegistrations.current[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
180
180
  var _value = _slicedToArray(_step.value, 2), name = _value[0], ref = _value[1], input = ref.input, validator = ref.validator;
181
181
  if (input) {
182
+ var ref;
182
183
  if (input.disabled) {
183
184
  continue;
184
185
  }
185
- if (input.required && !input.value.trim()) {
186
+ if (input.required && !((ref = rawValues[name]) === null || ref === void 0 ? void 0 : ref.trim())) {
186
187
  errors[name] = texts.formFieldErrorIsMandatory;
187
188
  } else {
188
189
  var error = validator === null || validator === void 0 ? void 0 : validator(values[name], rawValues[name]);
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.PACKAGE_VERSION = void 0;
6
- var PACKAGE_VERSION = '10.22.0';
6
+ var PACKAGE_VERSION = '10.23.0';
7
7
  exports.PACKAGE_VERSION = PACKAGE_VERSION;
package/dist/select.js CHANGED
@@ -354,6 +354,21 @@ var Select = function Select(param) {
354
354
  };
355
355
  var focusableElement = focusableRef.current;
356
356
  var inputElement = inputRef.current;
357
+ React.useEffect(function() {
358
+ setRawValue({
359
+ name: name,
360
+ value: value
361
+ });
362
+ formSetValue({
363
+ name: name,
364
+ value: value
365
+ });
366
+ }, [
367
+ name,
368
+ setRawValue,
369
+ formSetValue,
370
+ value
371
+ ]);
357
372
  React.useEffect(function() {
358
373
  register(name, {
359
374
  input: inputRef.current,
@@ -197,7 +197,8 @@ var ThemeContextProvider = function ThemeContextProvider(param) {
197
197
  Link: (_Link = theme.Link) !== null && _Link !== void 0 ? _Link : _theme.AnchorLink,
198
198
  isDarkMode: isDarkModeEnabled,
199
199
  isIos: (0, _platform).getPlatform(platformOverrides) === 'ios',
200
- useHrefDecorator: (_useHrefDecorator = theme.useHrefDecorator) !== null && _useHrefDecorator !== void 0 ? _useHrefDecorator : useDefaultHrefDecorator
200
+ useHrefDecorator: (_useHrefDecorator = theme.useHrefDecorator) !== null && _useHrefDecorator !== void 0 ? _useHrefDecorator : useDefaultHrefDecorator,
201
+ unstable_disableHistoryUpdateInDialogs: !!theme.unstable_disableHistoryUpdateInDialogs
201
202
  };
202
203
  }, [
203
204
  theme,
package/dist/theme.d.ts CHANGED
@@ -100,6 +100,7 @@ export declare type ThemeConfig = {
100
100
  Link?: LinkComponent;
101
101
  useHrefDecorator?: () => (href: string) => string;
102
102
  enableTabFocus?: boolean;
103
+ unstable_disableHistoryUpdateInDialogs?: boolean;
103
104
  };
104
105
  export declare type Theme = {
105
106
  skinName: SkinName;
@@ -134,5 +135,6 @@ export declare type Theme = {
134
135
  isDarkMode: boolean;
135
136
  isIos: boolean;
136
137
  useHrefDecorator: () => (href: string) => string;
138
+ unstable_disableHistoryUpdateInDialogs: boolean;
137
139
  };
138
140
  export {};
@@ -104,6 +104,7 @@ export type ThemeConfig = {
104
104
  Link?: LinkComponent,
105
105
  useHrefDecorator?: () => (href: string) => string,
106
106
  enableTabFocus?: boolean,
107
+ unstable_disableHistoryUpdateInDialogs?: boolean,
107
108
  };
108
109
  export type Theme = {
109
110
  skinName: SkinName,
@@ -138,6 +139,7 @@ export type Theme = {
138
139
  isDarkMode: boolean,
139
140
  isIos: boolean,
140
141
  useHrefDecorator: () => (href: string) => string,
142
+ unstable_disableHistoryUpdateInDialogs: boolean,
141
143
  };
142
144
  declare export {};
143
145
 
package/dist-es/dialog.js CHANGED
@@ -518,7 +518,9 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
518
518
  dialogRootInstances++;
519
519
  if (dialogRootInstances === 1) {
520
520
  dialogInstance = this;
521
- window.addEventListener('popstate', this.handleBack);
521
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
522
+ window.addEventListener('popstate', this.handleBack);
523
+ }
522
524
  }
523
525
  }
524
526
  },
@@ -528,7 +530,9 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
528
530
  dialogRootInstances--;
529
531
  if (dialogRootInstances === 0) {
530
532
  dialogInstance = null;
531
- window.removeEventListener('popstate', this.handleBack);
533
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
534
+ window.removeEventListener('popstate', this.handleBack);
535
+ }
532
536
  }
533
537
  }
534
538
  },
@@ -538,8 +542,10 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
538
542
  if (this.state.dialogProps) {
539
543
  throw Error('Tried to show a dialog on top of another dialog. This functionality is not currently supported.');
540
544
  }
541
- // We add an additional entry to history with the same page, so the first time back is pressed we only close the Dialog
542
- window.history.pushState(null, document.title, window.location.href);
545
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
546
+ // We add an additional entry to history with the same page, so the first time back is pressed we only close the Dialog
547
+ window.history.pushState(null, document.title, window.location.href);
548
+ }
543
549
  this.setState({
544
550
  dialogProps: props,
545
551
  isClosing: false
@@ -549,8 +555,12 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
549
555
  {
550
556
  key: "close",
551
557
  value: function close() {
552
- // Here we have to remove the additional entry added to history when we created the Dialog
553
- window.history.back();
558
+ if (!this.context.unstable_disableHistoryUpdateInDialogs) {
559
+ // Here we have to remove the additional entry added to history when we created the Dialog
560
+ window.history.back();
561
+ } else {
562
+ this.handleBack();
563
+ }
554
564
  }
555
565
  },
556
566
  {
@@ -606,6 +616,7 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
606
616
  ]);
607
617
  return DialogRoot;
608
618
  }(React.Component);
619
+ DialogRoot.contextType = ThemeContext;
609
620
  export { DialogRoot as default };
610
621
  var showDialog = function(param) {
611
622
  var showCancel = param === void 0 ? false : param;
package/dist-es/form.js CHANGED
@@ -143,10 +143,11 @@ var Form = function(param) {
143
143
  for(var _iterator = fieldRegistrations.current[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
144
144
  var _value = _slicedToArray(_step.value, 2), name = _value[0], ref = _value[1], input = ref.input, validator = ref.validator;
145
145
  if (input) {
146
+ var ref;
146
147
  if (input.disabled) {
147
148
  continue;
148
149
  }
149
- if (input.required && !input.value.trim()) {
150
+ if (input.required && !((ref = rawValues[name]) === null || ref === void 0 ? void 0 : ref.trim())) {
150
151
  errors[name] = texts.formFieldErrorIsMandatory;
151
152
  } else {
152
153
  var error = validator === null || validator === void 0 ? void 0 : validator(values[name], rawValues[name]);
@@ -1,2 +1,2 @@
1
1
  // DO NOT EDIT THIS FILE. It's autogenerated by set-version.js
2
- export var PACKAGE_VERSION = '10.22.0';
2
+ export var PACKAGE_VERSION = '10.23.0';
package/dist-es/select.js CHANGED
@@ -320,6 +320,21 @@ var Select = function(param) {
320
320
  };
321
321
  var focusableElement = focusableRef.current;
322
322
  var inputElement = inputRef.current;
323
+ React.useEffect(function() {
324
+ setRawValue({
325
+ name: name,
326
+ value: value
327
+ });
328
+ formSetValue({
329
+ name: name,
330
+ value: value
331
+ });
332
+ }, [
333
+ name,
334
+ setRawValue,
335
+ formSetValue,
336
+ value
337
+ ]);
323
338
  React.useEffect(function() {
324
339
  register(name, {
325
340
  input: inputRef.current,
@@ -163,7 +163,8 @@ var ThemeContextProvider = function(param) {
163
163
  Link: (_Link = theme.Link) !== null && _Link !== void 0 ? _Link : AnchorLink,
164
164
  isDarkMode: isDarkModeEnabled,
165
165
  isIos: getPlatform(platformOverrides) === 'ios',
166
- useHrefDecorator: (_useHrefDecorator = theme.useHrefDecorator) !== null && _useHrefDecorator !== void 0 ? _useHrefDecorator : useDefaultHrefDecorator
166
+ useHrefDecorator: (_useHrefDecorator = theme.useHrefDecorator) !== null && _useHrefDecorator !== void 0 ? _useHrefDecorator : useDefaultHrefDecorator,
167
+ unstable_disableHistoryUpdateInDialogs: !!theme.unstable_disableHistoryUpdateInDialogs
167
168
  };
168
169
  }, [
169
170
  theme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telefonica/mistica",
3
- "version": "10.22.0",
3
+ "version": "10.23.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",