@wonderflow/react-components 11.0.6 → 12.0.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.
Files changed (145) hide show
  1. package/core/basic.css +1 -1
  2. package/core/typography.css +1 -1
  3. package/core.css +1 -1
  4. package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
  5. package/dist/components/autocomplete/autocomplete.js +1 -1
  6. package/dist/components/avatar/avatar.d.ts.map +1 -1
  7. package/dist/components/avatar/avatar.js +3 -1
  8. package/dist/components/avatar/avatar.stories.js +1 -1
  9. package/dist/components/avatar/avatar.test.js +6 -2
  10. package/dist/components/button/button.module.css +1 -1
  11. package/dist/components/card/card.stories.d.ts.map +1 -1
  12. package/dist/components/card/card.stories.js +3 -8
  13. package/dist/components/chip/chip.js +1 -1
  14. package/dist/components/chip/chip.module.css +1 -1
  15. package/dist/components/circular-progress/circular-progress.module.css +1 -1
  16. package/dist/components/container/container.stories.js +1 -1
  17. package/dist/components/disclosure/disclosure.js +6 -6
  18. package/dist/components/disclosure/disclosure.module.css +1 -1
  19. package/dist/components/drawer/drawer.d.ts.map +1 -1
  20. package/dist/components/drawer/drawer.js +2 -2
  21. package/dist/components/index.d.ts +0 -2
  22. package/dist/components/index.d.ts.map +1 -1
  23. package/dist/components/index.js +0 -2
  24. package/dist/components/info-state/info-state.js +2 -2
  25. package/dist/components/input-group/input-group.js +1 -1
  26. package/dist/components/linear-progress/linear-progress.d.ts.map +1 -1
  27. package/dist/components/linear-progress/linear-progress.js +1 -1
  28. package/dist/components/list/list-item.js +6 -6
  29. package/dist/components/list/list.module.css +1 -1
  30. package/dist/components/menu/menu-item/menu-item.d.ts.map +1 -1
  31. package/dist/components/menu/menu-item/menu-item.js +2 -2
  32. package/dist/components/menu/menu-item/menu-item.module.css +1 -1
  33. package/dist/components/menu/menu-item/menu-item.stories.js +1 -1
  34. package/dist/components/menu/menu.stories.js +2 -2
  35. package/dist/components/modal/modal.d.ts +1 -2
  36. package/dist/components/modal/modal.d.ts.map +1 -1
  37. package/dist/components/modal/modal.js +3 -3
  38. package/dist/components/modal/modal.stories.d.ts.map +1 -1
  39. package/dist/components/modal/modal.stories.js +6 -6
  40. package/dist/components/pagination/pagination.module.css +1 -1
  41. package/dist/components/popover/popover.stories.d.ts +4 -0
  42. package/dist/components/popover/popover.stories.d.ts.map +1 -1
  43. package/dist/components/popover/popover.stories.js +16 -0
  44. package/dist/components/select/select.d.ts +8 -0
  45. package/dist/components/select/select.d.ts.map +1 -1
  46. package/dist/components/select/select.js +2 -2
  47. package/dist/components/select/select.module.css +1 -1
  48. package/dist/components/select/select.stories.d.ts +5 -2
  49. package/dist/components/select/select.stories.d.ts.map +1 -1
  50. package/dist/components/select/select.stories.js +7 -4
  51. package/dist/components/select/select.test.js +1 -1
  52. package/dist/components/selection-controls/checkbox.d.ts.map +1 -1
  53. package/dist/components/selection-controls/checkbox.js +9 -1
  54. package/dist/components/selection-controls/checkbox.stories.d.ts +7 -0
  55. package/dist/components/selection-controls/checkbox.stories.d.ts.map +1 -1
  56. package/dist/components/selection-controls/checkbox.stories.js +8 -0
  57. package/dist/components/selection-controls/radio.d.ts.map +1 -1
  58. package/dist/components/selection-controls/radio.js +10 -2
  59. package/dist/components/selection-controls/radio.stories.d.ts +6 -0
  60. package/dist/components/selection-controls/radio.stories.d.ts.map +1 -1
  61. package/dist/components/selection-controls/radio.stories.js +8 -0
  62. package/dist/components/selection-controls/selection-controls.module.css +1 -1
  63. package/dist/components/selection-controls/toggle.d.ts.map +1 -1
  64. package/dist/components/selection-controls/toggle.js +10 -2
  65. package/dist/components/selection-controls/toggle.stories.d.ts +7 -0
  66. package/dist/components/selection-controls/toggle.stories.d.ts.map +1 -1
  67. package/dist/components/selection-controls/toggle.stories.js +8 -0
  68. package/dist/components/skeleton/skeleton.module.css +1 -1
  69. package/dist/components/slider/slider.d.ts.map +1 -1
  70. package/dist/components/slider/slider.js +1 -1
  71. package/dist/components/snackbar/snackbar.d.ts.map +1 -1
  72. package/dist/components/snackbar/snackbar.js +9 -2
  73. package/dist/components/snackbar/snackbar.module.css +1 -1
  74. package/dist/components/star-meter/star-meter.js +5 -5
  75. package/dist/components/symbol/symbol.js +1 -1
  76. package/dist/components/tab/tab.module.css +1 -1
  77. package/dist/components/tab/tab.stories.d.ts.map +1 -1
  78. package/dist/components/tab/tab.stories.js +6 -0
  79. package/dist/components/table/table-cell/table-cell.module.css +1 -1
  80. package/dist/components/table/table-header/table-header.d.ts +2 -2
  81. package/dist/components/table/table-header/table-header.d.ts.map +1 -1
  82. package/dist/components/table/table-header/table-header.js +2 -2
  83. package/dist/components/table/table-pagination/table-pagination.js +2 -2
  84. package/dist/components/table/table-row/table-row.js +1 -1
  85. package/dist/components/table/table.js +1 -1
  86. package/dist/components/table/table.stories.js +2 -2
  87. package/dist/components/text/index.d.ts +1 -1
  88. package/dist/components/text/index.d.ts.map +1 -1
  89. package/dist/components/text/text.d.ts +42 -22
  90. package/dist/components/text/text.d.ts.map +1 -1
  91. package/dist/components/text/text.js +86 -5
  92. package/dist/components/text/text.module.css +1 -1
  93. package/dist/components/text/text.stories.d.ts +6 -1
  94. package/dist/components/text/text.stories.d.ts.map +1 -1
  95. package/dist/components/text/text.stories.js +63 -18
  96. package/dist/components/text/text.test.js +85 -0
  97. package/dist/components/textfield/base-field/base-field.module.css +1 -1
  98. package/dist/components/textfield/textfield.js +2 -2
  99. package/dist/components/textfield/textfield.module.css +1 -1
  100. package/dist/components/toggle-button/toggle-button.js +1 -1
  101. package/dist/components/tooltip/tooltip.module.css +1 -1
  102. package/dist/examples/shell.module.css +1 -1
  103. package/dist/examples/shell.stories.d.ts.map +1 -1
  104. package/dist/examples/shell.stories.js +7 -7
  105. package/dist/hooks/useBreakpoints.d.ts.map +1 -1
  106. package/dist/hooks/useBreakpoints.js +7 -5
  107. package/dist/providers/responsive.d.ts.map +1 -1
  108. package/dist/providers/responsive.js +7 -5
  109. package/dist/utils/conversions.d.ts +2 -0
  110. package/dist/utils/conversions.d.ts.map +1 -0
  111. package/dist/{components/title/index.js → utils/conversions.js} +10 -2
  112. package/dist/utils/convertions.test.d.ts +2 -0
  113. package/dist/utils/convertions.test.d.ts.map +1 -0
  114. package/dist/utils/convertions.test.js +13 -0
  115. package/dist/utils/themes.d.ts +3 -0
  116. package/dist/utils/themes.d.ts.map +1 -0
  117. package/dist/{components/prose/prose.js → utils/themes.js} +12 -6
  118. package/dist/utils/themes.test.d.ts +2 -0
  119. package/dist/utils/themes.test.d.ts.map +1 -0
  120. package/dist/utils/themes.test.js +26 -0
  121. package/package.json +3 -3
  122. package/dist/components/prose/index.d.ts +0 -3
  123. package/dist/components/prose/index.d.ts.map +0 -1
  124. package/dist/components/prose/index.js +0 -16
  125. package/dist/components/prose/prose.d.ts +0 -6
  126. package/dist/components/prose/prose.d.ts.map +0 -1
  127. package/dist/components/prose/prose.module.css +0 -1
  128. package/dist/components/prose/prose.stories.d.ts +0 -7
  129. package/dist/components/prose/prose.stories.d.ts.map +0 -1
  130. package/dist/components/prose/prose.stories.js +0 -12
  131. package/dist/components/prose/prose.test.d.ts +0 -2
  132. package/dist/components/prose/prose.test.d.ts.map +0 -1
  133. package/dist/components/prose/prose.test.js +0 -11
  134. package/dist/components/title/index.d.ts +0 -3
  135. package/dist/components/title/index.d.ts.map +0 -1
  136. package/dist/components/title/title.d.ts +0 -40
  137. package/dist/components/title/title.d.ts.map +0 -1
  138. package/dist/components/title/title.js +0 -41
  139. package/dist/components/title/title.module.css +0 -1
  140. package/dist/components/title/title.stories.d.ts +0 -8
  141. package/dist/components/title/title.stories.d.ts.map +0 -1
  142. package/dist/components/title/title.stories.js +0 -47
  143. package/dist/components/title/title.test.d.ts +0 -2
  144. package/dist/components/title/title.test.d.ts.map +0 -1
  145. package/dist/components/title/title.test.js +0 -18
@@ -1,9 +1,94 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render } from '@testing-library/react';
3
+ import { Chip, Symbol, } from '../..';
3
4
  import { Text } from './text';
4
5
  describe('<Text>', () => {
5
6
  test(' it should render properly', () => {
6
7
  const { container } = render(_jsx(Text, { children: "Some text" }));
7
8
  expect(container).not.toBeNull();
8
9
  });
10
+ test(' it should render properly as <span>', () => {
11
+ const { container } = render(_jsx(Text, { as: "span", children: "Some text" }));
12
+ expect(container).not.toBeNull();
13
+ });
14
+ test(' it should render properly with all variants', () => {
15
+ const v = [
16
+ 'display-1',
17
+ 'display-2',
18
+ 'display-3',
19
+ 'display-4',
20
+ 'heading-1',
21
+ 'heading-2',
22
+ 'heading-3',
23
+ 'heading-4',
24
+ 'heading-5',
25
+ 'heading-6',
26
+ 'subtitle-1',
27
+ 'subtitle-2',
28
+ 'tagline-1',
29
+ 'tagline-2',
30
+ 'tagline-3',
31
+ 'body-1',
32
+ 'body-2',
33
+ 'body-3'
34
+ ];
35
+ v.map((el) => {
36
+ const { container } = render(_jsx(Text, { variant: el, children: "Some text" }));
37
+ return expect(container).not.toBeNull();
38
+ });
39
+ });
40
+ test(' it should render properly with colors', () => {
41
+ const c = ['positive', 'informative', 'danger', 'warning'];
42
+ c.map((col) => {
43
+ const { container } = render(_jsx(Text, { color: col, children: "Some text" }));
44
+ return expect(container).not.toBeNull();
45
+ });
46
+ });
47
+ test(' it should render properly with different alignment', () => {
48
+ const a = ['start', 'center', 'end', 'justify'];
49
+ a.map((t) => {
50
+ const { container } = render(_jsx(Text, { textAlign: t, children: "Some text" }));
51
+ return expect(container).not.toBeNull();
52
+ });
53
+ });
54
+ test(' it should render properly with props', () => {
55
+ const { container } = render(_jsx(Text, { preventBreakWord: true, preventResponsive: true, truncate: true, children: "Some text" }));
56
+ return expect(container).not.toBeNull();
57
+ });
58
+ test(' it should render properly with anchor', () => {
59
+ const { container } = render(_jsx(Text, { variant: "heading-1", anchor: true, id: "heading-1", children: "Some text" }));
60
+ return expect(container).not.toBeNull();
61
+ });
62
+ test(' it should render properly with anchor w/o id', () => {
63
+ const { container } = render(_jsx(Text, { variant: "display-1", anchor: true, children: "Some text" }));
64
+ return expect(container).not.toBeNull();
65
+ });
66
+ test(' it should render properly with decorator start icon', () => {
67
+ const s = ['small', 'medium', 'big'];
68
+ s.map(((t) => {
69
+ const { container } = render(_jsx(Text, { decoratorStart: (_jsx(Symbol, { source: "circle-check", weight: "solid" })), decoratorSize: t, children: "Some text" }));
70
+ return expect(container).not.toBeNull();
71
+ }));
72
+ });
73
+ test(' it should render properly with decorator start chip', () => {
74
+ const s = ['small', 'medium', 'big'];
75
+ s.map(((t) => {
76
+ const { container } = render(_jsx(Text, { decoratorStart: (_jsx(Chip, { color: "red", children: "Chip" })), decoratorSize: t, children: "Some text" }));
77
+ return expect(container).not.toBeNull();
78
+ }));
79
+ });
80
+ test(' it should render properly with decorator end icon', () => {
81
+ const s = ['small', 'medium', 'big'];
82
+ s.map(((t) => {
83
+ const { container } = render(_jsx(Text, { decoratorEnd: (_jsx(Symbol, { source: "circle-check", weight: "solid" })), decoratorSize: t, children: "Some text" }));
84
+ return expect(container).not.toBeNull();
85
+ }));
86
+ });
87
+ test(' it should render properly with decorator end chip', () => {
88
+ const s = ['small', 'medium', 'big'];
89
+ s.map(((t) => {
90
+ const { container } = render(_jsx(Text, { decoratorEnd: (_jsx(Chip, { color: "red", children: "Chip" })), decoratorSize: t, children: "Some text" }));
91
+ return expect(container).not.toBeNull();
92
+ }));
93
+ });
9
94
  });
@@ -1 +1 @@
1
- @layer components{.BaseField{appearance:none;background-color:var(--global-background);block-size:var(--field-height);border:1px solid var(--dimmed-2);border-radius:.25rem;box-sizing:border-box;caret-color:var(--cta-default);color:inherit;display:flex;font-family:inherit;font-size:var(--font-size);inline-size:100%;line-height:1;margin:0;overflow:hidden;padding:0 var(--field-padding);text-overflow:ellipsis}[data-textfield-has-icon=true] .BaseField::-webkit-calendar-picker-indicator{opacity:0;position:absolute;right:calc(var(--field-padding)/2)}.BaseField:-moz-ui-invalid{box-shadow:none}.BaseField::placeholder{color:var(--dimmed-5)}.BaseField:focus-visible{border-color:var(--dimmed-5)}.BaseField:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));border-color:transparent;color:var(--global-disabled-foreground);cursor:not-allowed}.BaseField:disabled::placeholder{color:var(--global-disabled-foreground)}.BaseField[readonly]{border-style:dashed;box-shadow:none;cursor:default}.BaseField:-webkit-autofill,.BaseField:-webkit-autofill:active,.BaseField:-webkit-autofill:focus,.BaseField:-webkit-autofill:hover{-webkit-text-fill-color:var(--global-vibrancy-foreground);border:1px solid var(--dimmed-2);box-shadow:0 0 0 100px var(--global-background) inset}:is(.BaseField:-webkit-autofill,.BaseField:-webkit-autofill:hover,.BaseField:-webkit-autofill:focus,.BaseField:-webkit-autofill:active)::selection{-webkit-text-fill-color:var(--dimmed-0)}.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range),.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range):focus-visible{border-color:var(--highlight-red-foreground)}.BaseField[type=number]{appearance:textfield}.BaseField[type=number]::-webkit-inner-spin-button,.BaseField[type=number]::-webkit-outer-spin-button{display:none}.BaseField[type=search]{appearance:none}.BaseField[type=search]::-webkit-search-cancel-button,.BaseField[type=search]::-webkit-search-decoration{appearance:none}textarea.BaseField{block-size:auto;line-height:1.5;min-block-size:2rem;padding:calc(var(--field-padding)/2) calc(var(--field-padding) + 1rem) calc(var(--field-padding)/2) var(--field-padding);resize:vertical}textarea.BaseField::-webkit-datetime-edit-text{opacity:.3}textarea.BaseField::-webkit-calendar-picker-indicator{color:var(--global-foreground)}textarea.BaseField:-moz-ui-invalid{box-shadow:none}textarea.BaseField::-webkit-calendar-picker-indicator:hover{background-color:transparent}}
1
+ @layer components{.BaseField{appearance:none;background-color:var(--global-background);block-size:var(--field-height);border:1px solid var(--dimmed-2);border-radius:.25rem;box-sizing:border-box;caret-color:var(--cta-default);color:inherit;display:flex;font-family:inherit;font-size:var(--font-size);inline-size:100%;line-height:1rem;margin:0;overflow:hidden;padding:0 var(--field-padding);text-overflow:ellipsis}[data-textfield-has-icon=true] .BaseField::-webkit-calendar-picker-indicator{opacity:0;position:absolute;right:calc(var(--field-padding)/2)}.BaseField:-moz-ui-invalid{box-shadow:none}.BaseField::placeholder{color:var(--dimmed-5)}.BaseField:focus-visible{border-color:var(--dimmed-5)}.BaseField:disabled{background:linear-gradient(to bottom,var(--global-disabled-background),var(--global-disabled-background));border-color:transparent;color:var(--global-disabled-foreground);cursor:not-allowed}.BaseField:disabled::placeholder{color:var(--global-disabled-foreground)}.BaseField[readonly]{border-style:dashed;box-shadow:none;cursor:default}.BaseField:-webkit-autofill,.BaseField:-webkit-autofill:active,.BaseField:-webkit-autofill:focus,.BaseField:-webkit-autofill:hover{-webkit-text-fill-color:var(--global-vibrancy-foreground);border:1px solid var(--dimmed-2);box-shadow:0 0 0 100px var(--global-background) inset}:is(.BaseField:-webkit-autofill,.BaseField:-webkit-autofill:hover,.BaseField:-webkit-autofill:focus,.BaseField:-webkit-autofill:active)::selection{-webkit-text-fill-color:var(--dimmed-0)}.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range),.BaseField:is(:invalid,[data-basefield-invalid=true],:out-of-range):focus-visible{border-color:var(--highlight-red-foreground)}.BaseField[type=number]{appearance:textfield}.BaseField[type=number]::-webkit-inner-spin-button,.BaseField[type=number]::-webkit-outer-spin-button{display:none}.BaseField[type=search]{appearance:none}.BaseField[type=search]::-webkit-search-cancel-button,.BaseField[type=search]::-webkit-search-decoration{appearance:none}textarea.BaseField{block-size:auto;line-height:1.5rem;min-block-size:2rem;padding:calc(var(--field-padding)/2) calc(var(--field-padding) + 1rem) calc(var(--field-padding)/2) var(--field-padding);resize:vertical}textarea.BaseField::-webkit-datetime-edit-text{opacity:.3}textarea.BaseField::-webkit-calendar-picker-indicator{color:var(--global-foreground)}textarea.BaseField:-moz-ui-invalid{box-shadow:none}textarea.BaseField::-webkit-calendar-picker-indicator:hover{background-color:transparent}}
@@ -29,8 +29,8 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
29
29
  disabled,
30
30
  onChange,
31
31
  };
32
- return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-testid": "Textfield", "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid && !disabled, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", lineHeight: "small", "aria-disabled": disabled, className: styles.Label, size: dimension === 'small' ? 14 : 16, htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
32
+ return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(styles.Textfield, className), "data-testid": "Textfield", "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid && !disabled, "data-textfield-fullwidth": fullWidth, "aria-disabled": disabled, hAlign: "stretch", vAlign: "start", tabIndex: disabled ? 0 : undefined, style: style, children: [label && _jsx(Text, { as: "label", "aria-disabled": disabled, className: styles.Label, variant: dimension === 'big' ? 'body-1' : 'body-2', htmlFor: fieldID, children: label }), _jsxs("div", { className: styles.FieldContainer, children: [textarea
33
33
  ? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: fieldID, ...commonProps, ...otherProps }))
34
- : (_jsx(BaseField, { className: styles.InputField, id: fieldID, ref: forwardedRef, type: isPasswordVisible ? 'text' : type, spellCheck: isPassword ? false : undefined, ...commonProps, ...otherProps })), isPassword && (_jsx(IconButton, { className: styles.IconButton, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", "data-testid": "RevealIcon", icon: isPasswordVisible ? 'eye-slash' : 'eye' })), !textarea && icon && !isPassword && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] }), message && _jsx(Text, { as: "label", lineHeight: "small", sentiment: (invalid && !disabled) ? 'danger' : undefined, "aria-disabled": disabled, className: styles.Label, size: 14, children: message })] }));
34
+ : (_jsx(BaseField, { className: styles.InputField, id: fieldID, ref: forwardedRef, type: isPasswordVisible ? 'text' : type, spellCheck: isPassword ? false : undefined, ...commonProps, ...otherProps })), isPassword && (_jsx(IconButton, { className: styles.IconButton, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", "data-testid": "RevealIcon", icon: isPasswordVisible ? 'eye-slash' : 'eye' })), !textarea && icon && !isPassword && (_jsx(Symbol, { className: styles.Icon, source: icon, dimension: iconSizes[dimension] }))] }), message && _jsx(Text, { as: "label", color: (invalid && !disabled) ? 'danger' : undefined, "aria-disabled": disabled, className: styles.Label, variant: dimension === 'big' ? 'body-2' : 'body-3', children: message })] }));
35
35
  });
36
36
  Textfield.displayName = 'Textfield';
@@ -1 +1 @@
1
- @layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.500rem;--field-padding:0.33rem;--font-size:0.875rem}.Textfield[data-textfield-dimension=regular]{--field-height:2.500rem;--field-padding:1.000rem;--font-size:1.000rem}.Textfield[data-textfield-dimension=big]{--field-height:3.000rem;--field-padding:1.000rem;--font-size:1.125rem}.Textfield[data-textfield-fullwidth=true]{inline-size:100%}.FieldContainer{position:relative}.InputField{--factor:4}[data-textfield-has-icon=true][data-textfield-icon-position=right] .InputField{padding:0 calc(var(--field-padding)*var(--factor)) 0 var(--field-padding)}[data-textfield-has-icon=true][data-textfield-icon-position=left] .InputField{padding:0 var(--field-padding) 0 calc(var(--field-padding)*var(--factor))}[data-textfield-dimension*=big] .InputField,[data-textfield-dimension*=regular] .InputField{--factor:3}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}[data-textfield-icon-position=left] .Icon{left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .Icon{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .Icon{fill:var(--highlight-red-foreground)}.InputField:invalid+.Icon{fill:var(--highlight-red-foreground)}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}@layer overrides{.IconButton{--x:25%;outline-offset:-.25em;position:absolute;top:50%;transform:translateY(-50%) translateX(var(--x))}.IconButton[data-button-kind=flat]:is(:hover,:active,:focus,[data-button-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}[data-textfield-icon-position=left] .IconButton{--x:-19%;left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .IconButton{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .IconButton{color:var(--highlight-red-foreground)}}
1
+ @layer components{.Textfield{appearance:none;padding:0;position:relative}.Textfield[data-textfield-dimension=small]{--field-height:1.500rem;--field-padding:0.33rem;--font-size:0.875rem}.Textfield[data-textfield-dimension=regular]{--field-height:2.500rem;--field-padding:1.000rem;--font-size:1rem}.Textfield[data-textfield-dimension=big]{--field-height:3.000rem;--field-padding:1.000rem;--font-size:1rem}.Textfield[data-textfield-fullwidth=true]{inline-size:100%}.FieldContainer{position:relative}.InputField{--factor:4}[data-textfield-has-icon=true][data-textfield-icon-position=right] .InputField{padding:0 calc(var(--field-padding)*var(--factor)) 0 var(--field-padding)}[data-textfield-has-icon=true][data-textfield-icon-position=left] .InputField{padding:0 var(--field-padding) 0 calc(var(--field-padding)*var(--factor))}[data-textfield-dimension*=big] .InputField,[data-textfield-dimension*=regular] .InputField{--factor:3}.Icon{border-radius:.25rem;pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}[data-textfield-icon-position=left] .Icon{left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .Icon{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .Icon{fill:var(--highlight-red-foreground)}.InputField:invalid+.Icon{fill:var(--highlight-red-foreground)}.Label[aria-disabled=true]{color:var(--global-disabled-foreground);cursor:not-allowed}}@layer overrides{.IconButton{--x:25%;outline-offset:-.25em;position:absolute;top:50%;transform:translateY(-50%) translateX(var(--x))}.IconButton[data-button-kind=flat]:is(:hover,:active,:focus,[data-button-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none;background-color:transparent}[data-textfield-icon-position=left] .IconButton{--x:-19%;left:var(--field-padding);right:auto}[data-textfield-icon-position=right] .IconButton{left:auto;right:var(--field-padding)}.Textfield[data-textfield-invalid=true] .IconButton{color:var(--highlight-red-foreground)}}
@@ -49,7 +49,7 @@ export const ToggleButton = forwardRef(({ className, restingIcon, pressedIcon, d
49
49
  }, [onClick, isPressed]);
50
50
  const renderIcon = useCallback((icon, dimension) => {
51
51
  const iconSize = {
52
- big: 24,
52
+ big: 18,
53
53
  regular: 16,
54
54
  small: 12,
55
55
  };
@@ -1 +1 @@
1
- @layer components{.Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.25rem;font-size:1rem;max-inline-size:var(--max-w);padding:.5rem 1rem;position:relative;z-index:5}.Balloon[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Balloon[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Balloon[data-popper-placement^=top] .Arrow{bottom:6px}.Balloon[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=left] .Arrow{right:6px}.Balloon[data-popper-placement^=left] .Arrow:before{transform:translateY(-50%) rotate(45deg)}.Balloon[data-popper-placement^=bottom] .Arrow{top:-6px}.Balloon[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) rotate(45deg)}.Balloon[data-popper-placement^=right] .Arrow{left:-6px}.Balloon[data-popper-placement^=right] .Arrow:before{transform:translateY(-50%) rotate(45deg)}}
1
+ @layer components{.Tooltip{display:contents}.Balloon{word-wrap:break-word;background-color:#31363f;border-radius:.25rem;font-size:1rem;max-inline-size:var(--max-w);padding:.5rem 1rem;position:relative;z-index:5}.Balloon[data-popper-reference-hidden=true]{pointer-events:none;visibility:hidden}.Arrow:before{background-color:#31363f;block-size:12px;content:"";inline-size:12px;position:absolute;transform:rotate(45deg);visibility:visible}.Balloon[data-popper-reference-hidden=true] .Arrow{pointer-events:none;visibility:hidden}.Balloon[data-popper-placement^=top] .Arrow{bottom:6px}.Balloon[data-popper-placement^=top] .Arrow:before{transform:translateX(-50%) translateY(-2px) rotate(45deg)}.Balloon[data-popper-placement^=left] .Arrow{right:6px}.Balloon[data-popper-placement^=left] .Arrow:before{transform:translateX(-2px) translateY(-50%) rotate(45deg)}.Balloon[data-popper-placement^=bottom] .Arrow{top:-6px}.Balloon[data-popper-placement^=bottom] .Arrow:before{transform:translateX(-50%) translateY(2px) rotate(45deg)}.Balloon[data-popper-placement^=right] .Arrow{left:-6px}.Balloon[data-popper-placement^=right] .Arrow:before{transform:translateX(2px) translateY(-50%) rotate(45deg)}}
@@ -1 +1 @@
1
- @layer components{.MainContainer{background-color:#f9fafb}.LeftMenu{background-color:var(--global-background);border-right:1px solid var(--dimmed-1);max-width:63px;min-width:63px}.LeftMenu[data-is-open=true]{max-width:279px;min-width:279px}.LeftMenuInner{wordbreak:break-all;background-color:var(--dimmed-1);border-bottom:1px solid var(--dimmed-1);height:64px;max-height:64px;padding:.5rem}.LeftMenuInner[data-is-open=true]{background-color:var(--global-background);height:250px;max-height:250px}.MainMenu{maxheight:64px;border-bottom:1px solid var(--dimmed-1);height:64px;padding:0 2rem}.MainMenu,.RightMenu{background-color:var(--global-background)}.RightMenu{border-left:1px solid var(--dimmed-1);max-width:0;min-width:0;overflow:hidden}.RightMenu[data-is-open=true]{max-width:299px;min-width:299px}.RightMenuInner{wordbreak:break-all;background-color:var(--global-background);border-bottom:1px solid var(--dimmed-1);height:4rem;max-height:4rem;padding:.5rem}.Container{height:calc(100vh - 64px);overflow:auto}.Filter{overflowy:scroll;max-height:calc(100vh - 64px)}}
1
+ @layer components{.MainContainer{background-color:#f9fafb}.LeftMenu{background-color:var(--global-background);border-right:1px solid var(--dimmed-1);max-width:63px;min-width:63px}.LeftMenu[data-is-open=true]{max-width:279px;min-width:279px}.LeftMenuInner{wordbreak:break-all;background-color:var(--dimmed-1);border-bottom:1px solid var(--dimmed-1);height:64px;max-height:64px;padding:.5rem}.LeftMenuInner[data-is-open=true]{background-color:var(--global-background);height:250px;max-height:250px}.MainMenu{maxheight:64px;border-bottom:1px solid var(--dimmed-1);height:64px;padding:0 2rem}.MainMenu,.RightMenu{background-color:var(--global-background)}.RightMenu{border-left:1px solid var(--dimmed-1);max-width:0;min-width:0;overflow:hidden}.RightMenu[data-is-open=true]{max-width:299px;min-width:299px}.RightMenuInner{wordbreak:break-all;background-color:var(--global-background);border-bottom:1px solid var(--dimmed-1);height:4rem;max-height:4rem;padding:.5rem}.Container{height:calc(100vh - 64px);overflow:auto}.Filter{max-height:calc(100vh - 64px);overflow-y:scroll}}
@@ -1 +1 @@
1
- {"version":3,"file":"shell.stories.d.ts","sourceRoot":"","sources":["../../src/examples/shell.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAGL,SAAS,EAOV,MAAM,cAAc,CAAC;AAItB,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAG1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAuJrB,eAAO,MAAM,KAAK,kHAAoB,CAAC"}
1
+ {"version":3,"file":"shell.stories.d.ts","sourceRoot":"","sources":["../../src/examples/shell.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQjE,OAAO,EAGL,SAAS,EAOV,MAAM,cAAc,CAAC;AAItB,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,SAAS,CAG1C,CAAC;AAEF,eAAe,KAAK,CAAC;AAqJrB,eAAO,MAAM,KAAK,kHAAoB,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import clsx from 'clsx';
3
3
  import { useEffect, useMemo, useRef, useState, } from 'react';
4
4
  import { useUIDSeed } from 'react-uid';
5
- import { Button, Card, Container, Disclosure, Grid, IconButton, Menu, Snackbar, Stack, Text, Title, useBreakpoints, useBreakpointsConfig, useSSR, } from '..';
5
+ import { Button, Card, Container, Disclosure, Grid, IconButton, Menu, Snackbar, Stack, Text, useBreakpoints, useBreakpointsConfig, useSSR, } from '..';
6
6
  import * as style from './shell.module.css';
7
7
  const story = {
8
8
  title: 'Examples/Wireframe',
@@ -18,11 +18,11 @@ const Template = () => {
18
18
  const { matches, size } = useBreakpoints();
19
19
  const linkIcons = useMemo(() => ['accessibility', 'astronomy', 'crown', 'megaphone', 'thumbs-up'], []);
20
20
  const { value: containerValue, matches: containerMatches, size: containerSize, } = useBreakpointsConfig({
21
- sm: { gutter: 16, col: 3, dimension: 'fixed' },
22
- md: { gutter: 24, col: 3, dimension: 'fixed' },
23
- lg: { gutter: 24, col: 4, dimension: 'fixed' },
24
- xl: { gutter: 24, col: 6, dimension: 'fixed' },
25
- fallback: { gutter: 16, col: 2, dimension: 'fixed' },
21
+ sm: { gutter: 16, col: 2, dimension: 'extra-large' },
22
+ md: { gutter: 24, col: 3, dimension: 'extra-large' },
23
+ lg: { gutter: 24, col: 4, dimension: 'extra-large' },
24
+ xl: { gutter: 32, col: 6, dimension: 'extra-large' },
25
+ fallback: { gutter: 16, col: 1, dimension: 'extra-large' },
26
26
  }, ref);
27
27
  useEffect(() => {
28
28
  if (isBrowser) {
@@ -35,6 +35,6 @@ const Template = () => {
35
35
  }, [isBrowser]);
36
36
  return (_jsx(Container, { dimension: "full", padding: false, className: style.MainContainer, children: _jsxs(Stack, { direction: "row", children: [_jsxs(Stack, { id: "LeftMenu", rowGap: 16, className: style.LeftMenu, "data-is-open": isLeftOpen, children: [_jsx("div", { className: style.LeftMenuInner, "data-is-open": isLeftOpen }), isLeftOpen
37
37
  ? (_jsx("div", { children: linkIcons.map((e, i) => (_jsx(Menu.Item, { disabled: true, value: `${e}`, icon: linkIcons[i], children: e }, seed(`linkMenu${i}`)))) }))
38
- : (_jsx(Stack, { inline: true, hAlign: "center", rowGap: 8, children: linkIcons.map((e, i) => (_jsx(IconButton, { disabled: true, icon: linkIcons[i], kind: "flat" }, `${e} ${seed(`icons${i}`)}`))) }))] }), _jsxs(Stack, { children: [_jsxs(Stack, { id: "MainMenu", direction: "row", vAlign: "center", hAlign: "space-between", columnGap: 16, className: style.MainMenu, children: [_jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsLeftOpen(!isLeftOpen), children: "Menu" }) }), _jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsRightOpen(!isRightOpen), children: "Filters" }) })] }), _jsx(Container, { ref: ref, dimension: containerValue.dimension, className: clsx(style.Container, 'ContainerEx'), children: _jsxs(Stack, { rowGap: 32, vPadding: 32, children: [_jsxs(Snackbar, { children: [_jsx(Title, { level: "2", children: "Product Card Container" }), _jsx(Text, { as: "span", children: `Window Width: ${size}px - Breakpoints Match: ${matches.toUpperCase()}` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `Container Width: ${containerSize}px - Grid Columns: ${containerValue.col} - Grid Gutter: ${containerValue.gutter}px` }), _jsx("br", {}), _jsx(Text, { as: "span", children: `useBreakpointsConfig.value: ${JSON.stringify(containerValue)} - useBreakpointsConfig.matches: ${containerMatches.toUpperCase()}` })] }), _jsx(Grid, { columns: containerValue.col, rowGap: containerValue.gutter, columnGap: containerValue.gutter, filling: false, children: Array(12).fill('Card').map((e, i) => (_jsx(Grid.Item, { children: _jsx(Card, { bordered: true, style: { height: '500px' }, children: _jsx(Stack, { hAlign: "center", children: _jsx(Text, { size: 14, children: `${e} ${i + 1}` }) }) }) }, seed(`cards${i}`)))) })] }) })] }), _jsxs(Stack, { id: "RightMenu", className: style.RightMenu, "data-is-open": isRightOpen, children: [_jsx("div", { className: style.RightMenuInner }), _jsx("div", { className: style.Filter, children: Array(10).fill('Filter').map((e, i) => (_jsxs(Disclosure, { summary: `${e} ${String.fromCharCode(i + 65)}`, children: [_jsx(Menu.Item, { value: "1", subtext: "Hint Text", children: "Menu Item 1" }), _jsx(Menu.Item, { value: "2", subtext: "Hint Text", children: "Menu Item 2" }), _jsx(Menu.Item, { value: "3", subtext: "Hint Text", children: "Menu Item 3" }), _jsx(Menu.Item, { value: "4", subtext: "Hint Text", children: "Menu Item 4" })] }, seed(`filters${i}`)))) })] })] }) }));
38
+ : (_jsx(Stack, { inline: true, hAlign: "center", rowGap: 8, children: linkIcons.map((e, i) => (_jsx(IconButton, { disabled: true, icon: linkIcons[i], kind: "flat" }, `${e} ${seed(`icons${i}`)}`))) }))] }), _jsxs(Stack, { children: [_jsxs(Stack, { id: "MainMenu", direction: "row", vAlign: "center", hAlign: "space-between", columnGap: 16, className: style.MainMenu, children: [_jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsLeftOpen(!isLeftOpen), children: "Menu" }) }), _jsx(Stack, { inline: true, children: _jsx(Button, { kind: "secondary", dimension: "regular", fullWidth: false, onClick: () => setIsRightOpen(!isRightOpen), children: "Filters" }) })] }), _jsx(Container, { ref: ref, dimension: containerValue.dimension, className: clsx(style.Container, 'ContainerEx'), children: _jsxs(Stack, { rowGap: 32, vPadding: 32, children: [_jsxs(Snackbar, { title: "Product Card Container", children: [_jsx(Text, { children: `Window Width: ${size}px - Breakpoints Match: ${matches.toUpperCase()}` }), _jsx(Text, { children: `Container Width: ${containerSize}px - Grid Columns: ${containerValue.col} - Grid Gutter: ${containerValue.gutter}px` }), _jsx(Text, { children: `useBreakpointsConfig.value: ${JSON.stringify(containerValue)} - useBreakpointsConfig.matches: ${containerMatches.toUpperCase()}` })] }), _jsx(Grid, { colMinWidth: "1rem", columns: containerValue.col, rowGap: containerValue.gutter, columnGap: containerValue.gutter, filling: false, children: Array(12).fill('Card').map((e, i) => (_jsx(Grid.Item, { children: _jsx(Card, { bordered: true, style: { height: '500px' }, children: _jsx(Stack, { hAlign: "center", children: _jsx(Text, { variant: "body-2", children: `${e} ${i + 1}` }) }) }) }, seed(`cards${i}`)))) })] }) })] }), _jsxs(Stack, { id: "RightMenu", className: style.RightMenu, "data-is-open": isRightOpen, children: [_jsx("div", { className: style.RightMenuInner }), _jsx("div", { className: style.Filter, children: Array(10).fill('Filter').map((e, i) => (_jsxs(Disclosure, { summary: `${e} ${String.fromCharCode(i + 65)}`, children: [_jsx(Menu.Item, { value: "1", subtext: "Hint Text", children: "Menu Item 1" }), _jsx(Menu.Item, { value: "2", subtext: "Hint Text", children: "Menu Item 2" }), _jsx(Menu.Item, { value: "3", subtext: "Hint Text", children: "Menu Item 3" }), _jsx(Menu.Item, { value: "4", subtext: "Hint Text", children: "Menu Item 4" })] }, seed(`filters${i}`)))) })] })] }) }));
39
39
  };
40
40
  export const Shell = Template.bind({});
@@ -1 +1 @@
1
- {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAIf,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/D,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;AAExD,oBAAY,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAErD,oBAAY,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;AAkBpD,eAAO,MAAM,cAAc,YAChB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aACnC,mBAAmB;;;;CA6D9B,CAAC"}
1
+ {"version":3,"file":"useBreakpoints.d.ts","sourceRoot":"","sources":["../../src/hooks/useBreakpoints.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAKf,oBAAY,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/D,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAA;AAExD,oBAAY,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAErD,oBAAY,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;AAkBpD,eAAO,MAAM,cAAc,YAChB,iBAAiB,WAAW,GAAG,IAAI,CAAC,aACnC,mBAAmB;;;;CA6D9B,CAAC"}
@@ -13,15 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
16
17
  import { useSize } from 'ahooks';
17
18
  import { useEffect, useState, } from 'react';
19
+ import { cssRelativeUnitsToPixel } from '../utils/conversions';
18
20
  import { useSSR } from './useSSR';
19
21
  const DefaultBreakpointsSettings = {
20
- xs: 480,
21
- sm: 768,
22
- md: 960,
23
- lg: 1280,
24
- xl: 1600,
22
+ xs: cssRelativeUnitsToPixel(tkns.breakpoint['extra-small']),
23
+ sm: cssRelativeUnitsToPixel(tkns.breakpoint.small),
24
+ md: cssRelativeUnitsToPixel(tkns.breakpoint.medium),
25
+ lg: cssRelativeUnitsToPixel(tkns.breakpoint.large),
26
+ xl: cssRelativeUnitsToPixel(tkns.breakpoint['extra-large']),
25
27
  };
26
28
  const DefaultBreakpointsValues = {
27
29
  xs: false,
@@ -1 +1 @@
1
- {"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../src/providers/responsive.tsx"],"names":[],"mappings":";AAqBA,aAAK,sBAAsB,GAAG;IAC5B;;MAEE;IACF,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF;;MAEE;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,sBAAsB,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;CACvE,CAAA;AAED,aAAK,uBAAuB,GAAG;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACrD,CAAA;AAUD,eAAO,MAAM,iBAAiB,iDAS5B,CAAC;AAIH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,CAuBlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,8BAShC,CAAC"}
1
+ {"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../src/providers/responsive.tsx"],"names":[],"mappings":";AAuBA,aAAK,sBAAsB,GAAG;IAC5B;;MAEE;IACF,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF;;MAEE;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,sBAAsB,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;CACvE,CAAA;AAED,aAAK,uBAAuB,GAAG;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;CACrD,CAAA;AAUD,eAAO,MAAM,iBAAiB,iDAS5B,CAAC;AAIH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,CAuBlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,8BAShC,CAAC"}
@@ -14,14 +14,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import tkns from '@wonderflow/tokens/platforms/web/tokens.json';
17
18
  import { configResponsive, useResponsive as responsiveAhook } from 'ahooks';
18
19
  import { createContext, useContext, useEffect, useState, } from 'react';
20
+ import { cssRelativeUnitsToPixel } from '../utils/conversions';
19
21
  const DEFAULT_BREAKPOINTS = {
20
- extraSmall: 480,
21
- small: 768,
22
- medium: 960,
23
- large: 1280,
24
- extraLarge: 1600,
22
+ extraSmall: cssRelativeUnitsToPixel(tkns.breakpoint['extra-small']),
23
+ small: cssRelativeUnitsToPixel(tkns.breakpoint.small),
24
+ medium: cssRelativeUnitsToPixel(tkns.breakpoint.medium),
25
+ large: cssRelativeUnitsToPixel(tkns.breakpoint.large),
26
+ extraLarge: cssRelativeUnitsToPixel(tkns.breakpoint['extra-large']),
25
27
  };
26
28
  export const ResponsiveContext = createContext({
27
29
  breakpoints: DEFAULT_BREAKPOINTS,
@@ -0,0 +1,2 @@
1
+ export declare const cssRelativeUnitsToPixel: (size: string) => number;
2
+ //# sourceMappingURL=conversions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../src/utils/conversions.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,MAStD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2022-2023 Wonderflow Design Team
2
+ * Copyright 2023 Wonderflow Design Team
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,4 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { Title } from './title';
16
+ export const cssRelativeUnitsToPixel = (size) => {
17
+ if ((/[0-9]+(em|rem)/g).test(size)) {
18
+ const re = /\d+/g;
19
+ const m = size.match(re);
20
+ const v = m ?? +m[0];
21
+ return v * 16;
22
+ }
23
+ return -1;
24
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=convertions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertions.test.d.ts","sourceRoot":"","sources":["../../src/utils/convertions.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { cssRelativeUnitsToPixel } from './conversions';
2
+ describe('cssRelativeUnitsToPixel()', () => {
3
+ const rightCases = ['20rem', '20em'];
4
+ const wrongCases = ['abc', '20Rem', '20eM', '20ReM', '20EM', '20px', '20%'];
5
+ rightCases.map(c => it(`should return 320 with input "${c}"`, () => {
6
+ const res = cssRelativeUnitsToPixel(c);
7
+ expect(res).toBe(320);
8
+ }));
9
+ wrongCases.map(c => it(`should return -1 with input "${c}"`, () => {
10
+ const res = cssRelativeUnitsToPixel(c);
11
+ expect(res).toBe(-1);
12
+ }));
13
+ });
@@ -0,0 +1,3 @@
1
+ export declare const getPrefersColorScheme: () => "dark" | "light";
2
+ export declare const getCurrentTheme: () => "dark" | "light";
3
+ //# sourceMappingURL=themes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/utils/themes.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,qBAAqB,wBAOjC,CAAC;AAEF,eAAO,MAAM,eAAe,wBAId,CAAC"}
@@ -1,6 +1,5 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  /*
3
- * Copyright 2022-2023 Wonderflow Design Team
2
+ * Copyright 2023 Wonderflow Design Team
4
3
  *
5
4
  * Licensed under the Apache License, Version 2.0 (the "License");
6
5
  * you may not use this file except in compliance with the License.
@@ -14,7 +13,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
13
  * See the License for the specific language governing permissions and
15
14
  * limitations under the License.
16
15
  */
17
- import clsx from 'clsx';
18
- import { forwardRef } from 'react';
19
- import * as styles from './prose.module.css';
20
- export const Prose = forwardRef(({ children, className, as: Wrapper = 'div', ...otherProps }, forwardedRef) => (_jsx(Wrapper, { ref: forwardedRef, className: clsx(styles.Prose, className), ...otherProps, children: children })));
16
+ export const getPrefersColorScheme = () => {
17
+ if (typeof window !== 'undefined') {
18
+ const m = window.matchMedia('(prefers-color-scheme: dark)');
19
+ return m.matches ? 'dark' : 'light';
20
+ }
21
+ return 'light';
22
+ };
23
+ export const getCurrentTheme = () => ((typeof window !== 'undefined'
24
+ && window.document?.querySelector('htlm')?.getAttribute('data-theme') === 'dark')
25
+ ? 'dark'
26
+ : 'light');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=themes.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themes.test.d.ts","sourceRoot":"","sources":["../../src/utils/themes.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { getCurrentTheme, getPrefersColorScheme } from './themes';
2
+ describe('getCurrentTheme()', () => {
3
+ Object.defineProperty(window, 'matchMedia', {
4
+ writable: true,
5
+ value: jest.fn().mockImplementation(query => ({
6
+ matches: false,
7
+ media: query,
8
+ onchange: null,
9
+ addListener: jest.fn(),
10
+ removeListener: jest.fn(),
11
+ addEventListener: jest.fn(),
12
+ removeEventListener: jest.fn(),
13
+ dispatchEvent: jest.fn(),
14
+ })),
15
+ });
16
+ it('should return light', () => {
17
+ const t = getCurrentTheme();
18
+ expect(t).toBe('light');
19
+ });
20
+ });
21
+ describe('getPrefersColorScheme()', () => {
22
+ it('should return a value', () => {
23
+ const s = getPrefersColorScheme();
24
+ expect(s).toBe('light');
25
+ });
26
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
- "version": "11.0.6",
3
+ "version": "12.0.0",
4
4
  "description": "UI components from Wonderflow's Wanda design system",
5
5
  "author": "Wonderflow",
6
6
  "license": "Apache-2.0",
@@ -82,8 +82,8 @@
82
82
  "@types/react-dom": "17.0.14",
83
83
  "@types/react-table": "7.7.12",
84
84
  "@types/react-test-renderer": "18.0.0",
85
- "@wonderflow/config": "11.0.6",
86
- "@wonderflow/tokens": "11.0.6",
85
+ "@wonderflow/config": "12.0.0",
86
+ "@wonderflow/tokens": "12.0.0",
87
87
  "babel-loader": "8.2.5",
88
88
  "cpy-cli": "3.1.1",
89
89
  "postcss": "8.4.17",
@@ -1,3 +0,0 @@
1
- export type { ProseProps } from './prose';
2
- export { Prose } from './prose';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/prose/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,16 +0,0 @@
1
- /*
2
- * Copyright 2022-2023 Wonderflow Design Team
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export { Prose } from './prose';
@@ -1,6 +0,0 @@
1
- import { Polymorphic } from '../..';
2
- export declare type ProseProps = Record<string, unknown>;
3
- declare type PolymorphicProse = Polymorphic.ForwardRefComponent<'div', {}>;
4
- export declare const Prose: PolymorphicProse;
5
- export {};
6
- //# sourceMappingURL=prose.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prose.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3C,oBAAY,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAGhD,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEnE,eAAO,MAAM,KAAK,kBAaI,CAAC"}
@@ -1 +0,0 @@
1
- @layer components{.Prose>h1:is(h1,h2,h3,h4,h5,h6),.Prose>h2:is(h1,h2,h3,h4,h5,h6),.Prose>h3:is(h1,h2,h3,h4,h5,h6),.Prose>h4:is(h1,h2,h3,h4,h5,h6),.Prose>h5:is(h1,h2,h3,h4,h5,h6),.Prose>h6:is(h1,h2,h3,h4,h5,h6){margin-block-end:0}.Prose>blockquote:where(:not(:first-child)),.Prose>dd:where(:not(:first-child)),.Prose>fieldset:where(:not(:first-child)),.Prose>figure:where(:not(:first-child)),.Prose>h1:where(:not(:first-child)),.Prose>h2:where(:not(:first-child)),.Prose>h3:where(:not(:first-child)),.Prose>h4:where(:not(:first-child)),.Prose>h5:where(:not(:first-child)),.Prose>h6:where(:not(:first-child)),.Prose>hgroup:where(:not(:first-child)),.Prose>img:where(:not(:first-child)),.Prose>ol:where(:not(:first-child)),.Prose>p:where(:not(:first-child)),.Prose>picture:where(:not(:first-child)),.Prose>pre:where(:not(:first-child)),.Prose>table:where(:not(:first-child)),.Prose>ul:where(:not(:first-child)){margin-block-end:2em;margin-block-start:2em}.Prose>h1:first-child,.Prose>h2:first-child,.Prose>h3:first-child,.Prose>h4:first-child,.Prose>h5:first-child,.Prose>h6:first-child{margin-block-start:0}.Prose>h1+*,.Prose>h2+*,.Prose>h3+*,.Prose>h4+*,.Prose>h5+*,.Prose>h6+*{margin-block-start:1.3em}}
@@ -1,7 +0,0 @@
1
- import { ComponentStory, Meta } from '@storybook/react';
2
- import { Polymorphic } from '../..';
3
- import { Prose } from './prose';
4
- declare const story: Meta<Polymorphic.OwnProps<typeof Prose>>;
5
- export default story;
6
- export declare const Default: ComponentStory<typeof Prose>;
7
- //# sourceMappingURL=prose.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prose.stories.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EACM,WAAW,EAEvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAMnD,CAAC;AAEF,eAAe,KAAK,CAAC;AAErB,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,OAAO,KAAK,CAiDhD,CAAC"}
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Container, Separator, Text, Title, } from '../..';
3
- import { Prose } from './prose';
4
- const story = {
5
- title: 'Typography/Prose',
6
- component: Prose,
7
- args: {
8
- as: 'section',
9
- },
10
- };
11
- export default story;
12
- export const Default = args => (_jsx(Container, { dimension: "medium", children: _jsxs(Prose, { ...args, children: [_jsx(Title, { as: "h1", level: "display", children: "Title" }), _jsx(Text, { size: 28, children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium." }), _jsx(Title, { as: "h2", level: "2", children: "Sample H2 Title" }), _jsx("img", { style: { width: '100%' }, alt: "", src: "https://images.unsplash.com/photo-1593963171957-d87a6279226d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Separator, {}), _jsx(Title, { as: "h2", level: "2", children: "Sample H2 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx("img", { style: { width: '100%' }, alt: "", src: "https://images.unsplash.com/photo-1593963171957-d87a6279226d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Title, { as: "h3", level: "3", children: "Sample H3 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" }), _jsx(Title, { as: "h4", level: "4", children: "Sample H4 Title" }), _jsx(Text, { children: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius dolores, tempore quas labore officiis praesentium. Porro sed dolorem, numquam temporibus consequuntur quam doloremque ducimus error tempora illo aliquam nesciunt nostrum!" })] }) }));
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=prose.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prose.test.d.ts","sourceRoot":"","sources":["../../../src/components/prose/prose.test.tsx"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /* eslint-disable max-len */
3
- import { render } from '@testing-library/react';
4
- import { Prose } from './prose';
5
- const innerText = 'Lorem, ipsum dolor sit amet consectetur adipisicing elit. Ullam hic illo quam ipsa. Aspernatur, eveniet? Optio dolore minima magni culpa necessitatibus facilis quam libero nam.';
6
- describe('<Prose>', () => {
7
- test(' it should render properly', () => {
8
- const { container } = render(_jsx(Prose, { children: innerText }));
9
- expect(container).not.toBeNull();
10
- });
11
- });
@@ -1,3 +0,0 @@
1
- export type { TitleProps } from './title';
2
- export { Title } from './title';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/title/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Polymorphic } from '../..';
2
- export declare type TitleProps = {
3
- /**
4
- * Set the level of the title. This property only
5
- * affects the visual appearance of the title and not the
6
- * semantic meaning of the title, which you can define
7
- * by using the `as` property.
8
- */
9
- level?: '1' | '2' | '3' | '4' | '5' | '6' | 'display';
10
- /**
11
- * Set the text line-height of the title. This uses
12
- * the predefined tokens from the typography system.
13
- */
14
- lineHeight?: 'none' | 'small' | 'large';
15
- /**
16
- * Set the text alignment of the title based on the text direction.
17
- */
18
- textAlign?: 'start' | 'center' | 'end';
19
- /**
20
- * Set the maximum width of the text after which it will wrap.
21
- */
22
- maxWidth?: string;
23
- /**
24
- * Enable or disable the responsiveness of the text. If disabled,
25
- * the text will be always the same size across all breakpoints.
26
- */
27
- responsive?: boolean;
28
- /**
29
- * Auto generate anchor link inside the heading. This should be
30
- * used only when the title define a new content section and has
31
- * a semantic tag.
32
- *
33
- * @default: `false`
34
- */
35
- anchor?: boolean;
36
- };
37
- declare type PolymorphicTitle = Polymorphic.ForwardRefComponent<'span', TitleProps>;
38
- export declare const Title: PolymorphicTitle;
39
- export {};
40
- //# sourceMappingURL=title.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../../src/components/title/title.tsx"],"names":[],"mappings":"AAsBA,OAAO,EAAE,WAAW,EAAU,MAAM,cAAc,CAAC;AAInD,oBAAY,UAAU,GAAG;IACvB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC;IACtD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACxC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAA;AAED,aAAK,gBAAgB,GAAG,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE5E,eAAO,MAAM,KAAK,kBAqDI,CAAC"}