@bbl-digital/snorre 4.1.36 → 4.1.37

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/bundle.js CHANGED
@@ -1342,9 +1342,8 @@
1342
1342
  };
1343
1343
  const handleNumberOnlyFormatting = val => {
1344
1344
  const onlyNumbers = val.replace(/[^\d]/g, '');
1345
- const formatedNumbersWithSpace = onlyNumbers.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
1346
1345
  getFormattedNumber && getFormattedNumber(onlyNumbers);
1347
- return formatedNumbersWithSpace;
1346
+ return onlyNumbers;
1348
1347
  };
1349
1348
  const onInputChange = e => {
1350
1349
  setInputDirty(true);
@@ -1359,6 +1358,20 @@
1359
1358
  props.onChange(e);
1360
1359
  }
1361
1360
  };
1361
+ const handleBlur = e => {
1362
+ if (variant === 'formattedNumber') {
1363
+ const onlyNumbers = value.toString().replace(/[^\d]/g, '');
1364
+ const formatedNumbersWithSpace = onlyNumbers.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
1365
+ setValueChanged(formatedNumbersWithSpace);
1366
+ }
1367
+ props.onBlur && props.onBlur(e);
1368
+ };
1369
+ const handleFocus = e => {
1370
+ if (variant === 'formattedNumber') {
1371
+ setValueChanged(value.toString().replaceAll(' ', ''));
1372
+ }
1373
+ props.onFocus && props.onFocus(e);
1374
+ };
1362
1375
  React.useEffect(() => {
1363
1376
  if (props.reset) {
1364
1377
  setValueChanged('');
@@ -1400,8 +1413,8 @@
1400
1413
  placeholder: props.placeholder,
1401
1414
  disabled: props.disabled,
1402
1415
  autoFocus: props.focus,
1403
- onBlur: props.onBlur,
1404
- onFocus: props.onFocus,
1416
+ onBlur: handleBlur,
1417
+ onFocus: handleFocus,
1405
1418
  onChange: onInputChange,
1406
1419
  maxLength: maxlength,
1407
1420
  ref: ref,
@@ -37,9 +37,8 @@ const Input = /*#__PURE__*/React.forwardRef(({
37
37
  };
38
38
  const handleNumberOnlyFormatting = val => {
39
39
  const onlyNumbers = val.replace(/[^\d]/g, '');
40
- const formatedNumbersWithSpace = onlyNumbers.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
41
40
  getFormattedNumber && getFormattedNumber(onlyNumbers);
42
- return formatedNumbersWithSpace;
41
+ return onlyNumbers;
43
42
  };
44
43
  const onInputChange = e => {
45
44
  setInputDirty(true);
@@ -54,6 +53,20 @@ const Input = /*#__PURE__*/React.forwardRef(({
54
53
  props.onChange(e);
55
54
  }
56
55
  };
56
+ const handleBlur = e => {
57
+ if (variant === 'formattedNumber') {
58
+ const onlyNumbers = value.toString().replace(/[^\d]/g, '');
59
+ const formatedNumbersWithSpace = onlyNumbers.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
60
+ setValueChanged(formatedNumbersWithSpace);
61
+ }
62
+ props.onBlur && props.onBlur(e);
63
+ };
64
+ const handleFocus = e => {
65
+ if (variant === 'formattedNumber') {
66
+ setValueChanged(value.toString().replaceAll(' ', ''));
67
+ }
68
+ props.onFocus && props.onFocus(e);
69
+ };
57
70
  useEffect(() => {
58
71
  if (props.reset) {
59
72
  setValueChanged('');
@@ -95,8 +108,8 @@ const Input = /*#__PURE__*/React.forwardRef(({
95
108
  placeholder: props.placeholder,
96
109
  disabled: props.disabled,
97
110
  autoFocus: props.focus,
98
- onBlur: props.onBlur,
99
- onFocus: props.onFocus,
111
+ onBlur: handleBlur,
112
+ onFocus: handleFocus,
100
113
  onChange: onInputChange,
101
114
  maxLength: maxlength,
102
115
  ref: ref,
@@ -1,5 +1,7 @@
1
1
  import Button from '.';
2
2
  import IconCaretDown from '../../../icons/General/IconCaretDown';
3
+ import IconBookmarkFilled from '../../../icons/General/IconBookmarkFilled';
4
+ import IconBookmarkOutline from '../../../icons/General/IconBookmarkOutline';
3
5
  import { jsx as _jsx } from "react/jsx-runtime";
4
6
  const meta = {
5
7
  title: 'v2/Core/Button',
@@ -12,9 +14,64 @@ export const Default = {
12
14
  },
13
15
  name: 'Default'
14
16
  };
17
+ export const DefaultSmall = {
18
+ args: {
19
+ small: true,
20
+ children: 'Small button'
21
+ },
22
+ name: 'Default small'
23
+ };
24
+ export const Secondary = {
25
+ args: {
26
+ secondary: true,
27
+ children: 'Secondary button'
28
+ },
29
+ name: 'Secondary'
30
+ };
31
+ export const SecondaryWithIcon = {
32
+ args: {
33
+ secondary: true,
34
+ beforeIcon: /*#__PURE__*/_jsx(IconBookmarkOutline, {}),
35
+ children: 'Secondary button'
36
+ },
37
+ name: 'Secondary with icon'
38
+ };
39
+ export const SecondarySmall = {
40
+ args: {
41
+ secondary: true,
42
+ small: true,
43
+ children: 'Secondary'
44
+ },
45
+ name: 'Secondary small'
46
+ };
47
+ export const Ghost = {
48
+ args: {
49
+ ghost: true,
50
+ children: 'Ghost button',
51
+ disabled: true
52
+ },
53
+ name: 'Ghost'
54
+ };
55
+ export const GhostSmall = {
56
+ args: {
57
+ ghost: true,
58
+ small: true,
59
+ children: 'Ghost small button'
60
+ },
61
+ name: 'Ghost small'
62
+ };
63
+ export const GhostSmallIcon = {
64
+ args: {
65
+ ghost: true,
66
+ small: true,
67
+ beforeIcon: /*#__PURE__*/_jsx(IconBookmarkOutline, {}),
68
+ children: 'Ghost small button'
69
+ },
70
+ name: 'Ghost small icon'
71
+ };
15
72
  export const IconBefore = {
16
73
  args: {
17
- beforeIcon: /*#__PURE__*/_jsx(IconCaretDown, {}),
74
+ beforeIcon: /*#__PURE__*/_jsx(IconBookmarkFilled, {}),
18
75
  children: 'Standard button'
19
76
  },
20
77
  name: 'Icon before'
@@ -29,6 +86,14 @@ export const IconAfter = {
29
86
  },
30
87
  name: 'Icon after'
31
88
  };
89
+ export const SmallWithIcon = {
90
+ args: {
91
+ small: true,
92
+ beforeIcon: /*#__PURE__*/_jsx(IconBookmarkFilled, {}),
93
+ children: 'Small button'
94
+ },
95
+ name: 'Small with icon'
96
+ };
32
97
  export const Success = {
33
98
  args: {
34
99
  success: true,
@@ -8,6 +8,8 @@ import AppLoader from '../../../core/AppLoader';
8
8
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
9
9
  const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
10
10
  const {
11
+ secondary,
12
+ ghost,
11
13
  danger,
12
14
  success,
13
15
  highlight,
@@ -50,7 +52,7 @@ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
50
52
  disabled: disabled,
51
53
  loading: loading,
52
54
  ref: ref,
53
- css: theme => [styles.default(theme), outline && styles.outline(theme), danger && styles.danger(theme), success && styles.success(theme), highlight && styles.highlighted, disabled && styles.disabled(theme), (beforeIcon || afterIcon) && styles.icon(theme), beforeIcon && styles.beforeIcon, afterIcon && styles.afterIcon, border && styles.border(border), nostyle && styles.nostyle, loading && styles.loading(theme), back && styles.back(theme), css && css, small && styles.small, danger && outline && styles.dangerOutline(theme), success && outline && styles.successOutline(theme), transparentBg && styles.transparentBg, focusable && styles.focusable],
55
+ css: theme => [styles.default(theme), secondary && styles.secondary(theme), outline && styles.outline(theme), danger && styles.danger(theme), success && styles.success(theme), highlight && styles.highlighted, ghost && styles.ghost(theme), disabled && styles.disabled(theme), (beforeIcon || afterIcon) && styles.icon(theme), border && styles.border(border), nostyle && styles.nostyle, loading && styles.loading(theme), back && styles.back(theme), css && css, small && styles.small, danger && outline && styles.dangerOutline(theme), success && outline && styles.successOutline(theme), transparentBg && styles.transparentBg, focusable && styles.focusable],
54
56
  afterIcon: afterIcon,
55
57
  beforeIcon: back ? _jsx(IconChevronLeft, {
56
58
  size: '12px'