@rikstv/shared-components 0.8.1 → 1.1.79

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 (151) hide show
  1. package/README.md +21 -2
  2. package/dist/{accordion → components/accordion}/Accordion.d.ts +1 -2
  3. package/dist/components/accordion/Accordion.js +34 -0
  4. package/dist/{accordion → components/accordion}/accordion.scss +58 -39
  5. package/dist/components/breadcrumb/Breadcrumb.d.ts +13 -0
  6. package/dist/components/breadcrumb/Breadcrumb.js +39 -0
  7. package/dist/components/breadcrumb/breadcrumb.scss +75 -0
  8. package/dist/components/button/ArrowButton.d.ts +12 -0
  9. package/dist/components/button/ArrowButton.js +44 -0
  10. package/dist/components/button/BaseButton.d.ts +18 -0
  11. package/dist/components/button/BaseButton.js +42 -0
  12. package/dist/components/button/BaseDecoratedButton.d.ts +11 -0
  13. package/dist/components/button/BaseDecoratedButton.js +32 -0
  14. package/dist/components/button/BaseLinkButton.d.ts +20 -0
  15. package/dist/components/button/BaseLinkButton.js +44 -0
  16. package/dist/{button → components/button}/Button.d.ts +2 -0
  17. package/dist/components/button/Button.js +29 -0
  18. package/dist/components/button/DecoratedButton.d.ts +7 -0
  19. package/dist/components/button/DecoratedButton.js +23 -0
  20. package/dist/{button → components/button}/IconButton.d.ts +2 -3
  21. package/dist/components/button/IconButton.js +24 -0
  22. package/dist/components/button/LinkButton.d.ts +5 -0
  23. package/dist/components/button/LinkButton.js +10 -0
  24. package/dist/components/button/arrow-button.scss +37 -0
  25. package/dist/{button → components/button}/button-shared.scss +14 -3
  26. package/dist/components/button/button.scss +93 -0
  27. package/dist/{button → components/button}/icon-button.scss +0 -0
  28. package/dist/components/button/link-button.scss +6 -0
  29. package/dist/components/checkbox/Checkbox.d.ts +9 -0
  30. package/dist/components/checkbox/Checkbox.js +40 -0
  31. package/dist/components/checkbox/checkbox.scss +116 -0
  32. package/dist/{core → components/core}/Core.d.ts +0 -0
  33. package/dist/{core → components/core}/Core.js +0 -0
  34. package/dist/{core → components/core}/LightMode.d.ts +0 -0
  35. package/dist/components/core/LightMode.js +14 -0
  36. package/dist/{core → components/core}/RiksTV.d.ts +0 -0
  37. package/dist/components/core/RiksTV.js +116 -0
  38. package/dist/{core → components/core}/Strim.d.ts +0 -0
  39. package/dist/components/core/Strim.js +10 -0
  40. package/dist/components/core/core.scss +102 -0
  41. package/dist/components/core/docs/Spacing.scss +12 -0
  42. package/dist/components/core/docs/componets/ColorSwatch/ColorSwatch.scss +66 -0
  43. package/dist/components/core/docs/componets/ColorSwatch/ColorSwatchBtn.scss +19 -0
  44. package/dist/components/core/docs/componets/ExampleGrid/ExampleGrid.scss +12 -0
  45. package/dist/components/core/docs/componets/SpacingBlock/SpacingBlock.scss +6 -0
  46. package/dist/components/core/docs/hooks/animated.scss +12 -0
  47. package/dist/components/core/docs/hooks/clickOutside.scss +11 -0
  48. package/dist/components/core/docs/hooks/intersection.scss +14 -0
  49. package/dist/components/core/hooks/useAnimatedHeight.d.ts +19 -0
  50. package/dist/components/core/hooks/useBrowserPreferences.d.ts +5 -0
  51. package/dist/components/core/hooks/useClickOutsideListener.d.ts +8 -0
  52. package/dist/components/core/hooks/useIntersectionObserver.d.ts +2 -0
  53. package/dist/components/core/hooks/useMutationObserver.d.ts +2 -0
  54. package/dist/components/core/mixin/breakpoints.scss +44 -0
  55. package/dist/{core → components/core}/mixin/fluid.scss +0 -0
  56. package/dist/{core → components/core}/mixin/focus.scss +0 -0
  57. package/dist/{core → components/core}/mixin/navigation.scss +0 -0
  58. package/dist/{core → components/core}/mixin/rem.scss +0 -0
  59. package/dist/components/core/rikstvColors.scss +71 -0
  60. package/dist/components/core/rtv.scss +75 -0
  61. package/dist/components/core/spacing/Gutter.d.ts +2 -0
  62. package/dist/components/core/spacing/GutterPadding.d.ts +2 -0
  63. package/dist/components/core/strimColors.scss +48 -0
  64. package/dist/components/core/strm.scss +79 -0
  65. package/dist/{core → components/core}/utils/detectUserInputMethod.d.ts +0 -0
  66. package/dist/components/icons/Arrow.d.ts +2 -0
  67. package/dist/components/icons/Arrow.js +12 -0
  68. package/dist/{icons → components/icons}/Chevron.d.ts +0 -0
  69. package/dist/{icons → components/icons}/Chevron.js +0 -0
  70. package/dist/{icons → components/icons}/heartToggle.scss +12 -6
  71. package/dist/components/index.d.ts +31 -0
  72. package/dist/components/list/CheckmarkListItem.d.ts +8 -0
  73. package/dist/components/list/CheckmarkListItem.js +32 -0
  74. package/dist/components/list/CheckmarkListItem.scss +41 -0
  75. package/dist/components/list/CrossmarkListItem.d.ts +8 -0
  76. package/dist/components/list/CrossmarkListItem.js +23 -0
  77. package/dist/components/list/CrossmarkListItem.scss +42 -0
  78. package/dist/components/list/List.d.ts +8 -0
  79. package/dist/components/list/List.js +28 -0
  80. package/dist/components/list/List.scss +15 -0
  81. package/dist/components/list/ListItem.d.ts +8 -0
  82. package/dist/components/list/ListItem.js +19 -0
  83. package/dist/components/list/ListItem.scss +25 -0
  84. package/dist/components/list/OrderedListItem.d.ts +7 -0
  85. package/dist/components/list/OrderedListItem.js +15 -0
  86. package/dist/components/list/OrderedListItem.scss +21 -0
  87. package/dist/components/list/internal/getMarkColor.d.ts +3 -0
  88. package/dist/components/loader/Loader.d.ts +7 -0
  89. package/dist/components/loader/Loader.js +31 -0
  90. package/dist/components/loader/Loader.scss +148 -0
  91. package/dist/components/loader/RawLoader.d.ts +10 -0
  92. package/dist/components/loader/RawLoader.js +30 -0
  93. package/dist/components/panel/Info.d.ts +2 -0
  94. package/dist/components/panel/Info.js +25 -0
  95. package/dist/components/panel/Panel.d.ts +15 -0
  96. package/dist/components/panel/Panel.js +55 -0
  97. package/dist/components/panel/Success.d.ts +2 -0
  98. package/dist/components/panel/Success.js +80 -0
  99. package/dist/components/panel/Warning.d.ts +2 -0
  100. package/dist/components/panel/Warning.js +14 -0
  101. package/dist/components/panel/panel.scss +95 -0
  102. package/dist/components/progress/CircularProgress.d.ts +11 -0
  103. package/dist/components/progress/CircularProgress.js +87 -0
  104. package/dist/components/progress/Progress.d.ts +11 -0
  105. package/dist/components/progress/Progress.js +42 -0
  106. package/dist/components/progress/Progress.scss +76 -0
  107. package/dist/components/progress/circularProgress.scss +70 -0
  108. package/dist/components/spacing/Gutter.js +13 -0
  109. package/dist/components/spacing/GutterPadding.js +13 -0
  110. package/dist/{textfield → components/textfield}/TextField.d.ts +6 -5
  111. package/dist/components/textfield/TextField.js +57 -0
  112. package/dist/components/textfield/textfield.scss +178 -0
  113. package/dist/{toggle → components/toggle}/FieldSet.d.ts +0 -0
  114. package/dist/components/toggle/FieldSet.js +29 -0
  115. package/dist/{toggle → components/toggle}/RadioContext.d.ts +0 -0
  116. package/dist/{toggle → components/toggle}/RadioToggle.d.ts +0 -0
  117. package/dist/components/toggle/RadioToggle.js +30 -0
  118. package/dist/{toggle → components/toggle}/radioToggle.scss +2 -1
  119. package/dist/{toggleButton → components/toggleButton}/ToggleButton.d.ts +1 -0
  120. package/dist/components/toggleButton/ToggleButton.js +70 -0
  121. package/dist/{toggleButton → components/toggleButton}/toggleButton.scss +16 -8
  122. package/dist/components/toggleLinkButton/ToggleLinkButton.d.ts +10 -0
  123. package/dist/components/toggleLinkButton/ToggleLinkButton.js +60 -0
  124. package/dist/components/toggleLinkButton/toggleLinkButton.scss +54 -0
  125. package/dist/{typography → components/typography}/Typography.d.ts +3 -1
  126. package/dist/components/typography/Typography.js +67 -0
  127. package/dist/{typography → components/typography}/typography.scss +30 -1
  128. package/dist/shared-components.es.js +210 -15
  129. package/dist/style.css +1 -1
  130. package/dist/{core/utils → utils}/generateId.d.ts +0 -0
  131. package/package.json +12 -17
  132. package/dist/accordion/Accordion.js +0 -73
  133. package/dist/button/BaseButton.d.ts +0 -15
  134. package/dist/button/BaseButton.js +0 -80
  135. package/dist/button/Button.js +0 -40
  136. package/dist/button/IconButton.js +0 -40
  137. package/dist/button/button.scss +0 -46
  138. package/dist/core/LightMode.js +0 -50
  139. package/dist/core/RiksTV.js +0 -115
  140. package/dist/core/Strim.js +0 -10
  141. package/dist/core/core.scss +0 -29
  142. package/dist/core/rtv.scss +0 -58
  143. package/dist/core/strm.scss +0 -62
  144. package/dist/index.d.ts +0 -11
  145. package/dist/textfield/TextField.js +0 -87
  146. package/dist/textfield/textfield.scss +0 -101
  147. package/dist/toggle/FieldSet.js +0 -66
  148. package/dist/toggle/RadioToggle.js +0 -65
  149. package/dist/toggleButton/ToggleButton.js +0 -106
  150. package/dist/toggleButton/internal/generateId.d.ts +0 -1
  151. package/dist/typography/Typography.js +0 -95
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export { RiksTVProvider } from "./core/RiksTV";
2
- export { StrimProvider } from "./core/Strim";
3
- export { LightMode } from "./core/LightMode";
4
- export { Accordion } from "./accordion/Accordion";
5
- export { PrimaryButton, SecondaryButton, TertiaryButton } from "./button/Button";
6
- export { PrimaryIconButton, SecondaryIconButton, TertiaryIconButton } from "./button/IconButton";
7
- export { ToggleButton } from "./toggleButton/ToggleButton";
8
- export { RadioToggleInput } from "./toggle/RadioToggle";
9
- export { FieldSet } from "./toggle/FieldSet";
10
- export { TextField } from "./textfield/TextField";
11
- export { DisplayTitle, H1, H2, H3, H4, Body, Bold, SubBody, Tag, Meta } from "./typography/Typography";
@@ -1,87 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __objRest = (source, exclude) => {
18
- var target = {};
19
- for (var prop in source)
20
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
- target[prop] = source[prop];
22
- if (source != null && __getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(source)) {
24
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
- target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
- import { forwardRef } from "react";
30
- import { S as SubBody } from "../typography/Typography.js";
31
- import { a as jsxs, j as jsx } from "../core/RiksTV.js";
32
- const generateId = (id) => {
33
- if (id) {
34
- return id;
35
- }
36
- return `${new Date().valueOf()}`;
37
- };
38
- var textfield = "";
39
- const TextField = forwardRef((_a, ref) => {
40
- var _b = _a, {
41
- className = "",
42
- id,
43
- labelClass = "",
44
- type = "text",
45
- fullWidth = false,
46
- lightBackground = false,
47
- label,
48
- error
49
- } = _b, props = __objRest(_b, [
50
- "className",
51
- "id",
52
- "labelClass",
53
- "type",
54
- "fullWidth",
55
- "lightBackground",
56
- "label",
57
- "error"
58
- ]);
59
- const errorTextId = generateId();
60
- const generatedId = generateId(id);
61
- return /* @__PURE__ */ jsxs("div", {
62
- className: `rds-form-group ${className}`,
63
- children: [/* @__PURE__ */ jsx("input", __spreadValues({
64
- ref,
65
- id: generatedId,
66
- className: `
67
- rds-textfield
68
- rds-textfield--input ${error ? "rds-textfield--input--error" : ""} ${fullWidth ? "rds-textfield--input--full-width" : ""} ${lightBackground ? "rds-light" : ""}
69
- `,
70
- type,
71
- placeholder: label,
72
- "aria-describedby": error ? errorTextId : void 0
73
- }, props)), error && /* @__PURE__ */ jsx(SubBody, {
74
- id: errorTextId,
75
- className: "rds-textfield--error-text",
76
- children: error
77
- }), /* @__PURE__ */ jsx("label", {
78
- htmlFor: generatedId,
79
- className: `rds-textfield rds-textfield--label ${labelClass} ${lightBackground ? "rds-light" : ""}`,
80
- children: /* @__PURE__ */ jsx("span", {
81
- children: label
82
- })
83
- })]
84
- });
85
- });
86
- TextField.displayName = "TextField";
87
- export { TextField as T };
@@ -1,101 +0,0 @@
1
- @use "../typography/typography.scss";
2
- @use "../core/mixin/focus" as mix;
3
- @use "../core/mixin/rem";
4
-
5
- .rds-form-group {
6
- --input-color: var(--rds-foreground-primary);
7
- --input-label-color: var(--rds-foreground-secondary);
8
- --input-border-color: var(--rds-foreground-primary);
9
- --input-error-color: var(--rds-feedback-error);
10
- --input-bg: var(--rds-background-primary);
11
-
12
- .rds-textfield {
13
- &--input {
14
- border: 1px solid var(--input-border-color);
15
- background-color: var(--input-border-bg);
16
- color: var(--input-color);
17
- border-radius: 2px;
18
-
19
- height: 3rem;
20
- width: 100%;
21
- max-width: 500px;
22
- padding: 0 var(--rds-spacing--8);
23
-
24
- &--full-width {
25
- max-width: unset;
26
- }
27
-
28
- &::placeholder {
29
- opacity: 0;
30
- }
31
-
32
- &::-webkit-search-cancel-button {
33
- -webkit-appearance: none;
34
- display: none;
35
- }
36
-
37
- &:-webkit-autofill {
38
- box-shadow: 0 0 0 30px var(--rds-background-primary) inset;
39
- -webkit-box-shadow: 0 0 0 30px var(--rds-background-primary) inset;
40
- -webkit-text-fill-color: var(--rds-foreground-primary);
41
- }
42
- }
43
-
44
- &--label {
45
- cursor: text;
46
- background-color: var(--input-bg);
47
- position: absolute;
48
- padding: 0 8px;
49
- top: 50%;
50
- left: var(--rds-spacing--4);
51
- transform: translateY(-50%);
52
- transition: 0.2s ease-in-out;
53
- transition-property: top, font-size;
54
-
55
- span {
56
- @extend .rds-bold;
57
- font-size: rem.convert(18px);
58
- color: var(--input-label-color);
59
- }
60
- }
61
-
62
- &--error-text {
63
- color: var(--input-error-color);
64
- margin-top: 0.5rem;
65
- margin-bottom: 0.5rem;
66
- position: absolute;
67
- }
68
-
69
- @include mix.with-keyboard-focus;
70
- }
71
- }
72
-
73
- .rds-form-group {
74
- position: relative;
75
-
76
- &:focus-within {
77
- .rds-textfield--label {
78
- top: 0;
79
- font-size: 1rem;
80
- }
81
- }
82
-
83
- input:not(:placeholder-shown) + label {
84
- top: 0;
85
- font-size: 1rem;
86
- }
87
- }
88
-
89
- .rds-light {
90
- .rds-textfield,
91
- &.rds-textfield {
92
- --input-color: var(--rds-button-primary-fg);
93
- --input-border-color: var(--rds-button-primary-fg);
94
- --input-bg: var(--surface-background);
95
- &--label {
96
- span {
97
- --input-label-color: var(--rds-background-primary);
98
- }
99
- }
100
- }
101
- }
@@ -1,66 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { forwardRef } from "react";
33
- import { R as RadioContext } from "./RadioToggle.js";
34
- import { j as jsx, a as jsxs } from "../core/RiksTV.js";
35
- const FieldSet = forwardRef((_a, ref) => {
36
- var _b = _a, {
37
- legend,
38
- children,
39
- name,
40
- className = "",
41
- showLegend = false
42
- } = _b, rest = __objRest(_b, [
43
- "legend",
44
- "children",
45
- "name",
46
- "className",
47
- "showLegend"
48
- ]);
49
- return /* @__PURE__ */ jsx(RadioContext.Provider, {
50
- value: {
51
- radioName: name
52
- },
53
- children: /* @__PURE__ */ jsxs("fieldset", __spreadProps(__spreadValues({
54
- "data-testid": "fieldset"
55
- }, rest), {
56
- className: `rds-field-set ${className}`,
57
- ref,
58
- children: [/* @__PURE__ */ jsx("legend", {
59
- className: `rds-field-set__legend ${showLegend ? "" : "sr-only"}`,
60
- children: legend
61
- }), children]
62
- }))
63
- });
64
- });
65
- FieldSet.displayName = "FieldSet";
66
- export { FieldSet as F };
@@ -1,65 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { createContext, forwardRef, useContext } from "react";
33
- import "../button/Button.js";
34
- import { a as jsxs, j as jsx } from "../core/RiksTV.js";
35
- const RadioContext = createContext({ radioName: "" });
36
- var radioToggle = "";
37
- const RadioToggleInput = forwardRef((_a, ref) => {
38
- var _b = _a, {
39
- label,
40
- name,
41
- className = ""
42
- } = _b, rest = __objRest(_b, [
43
- "label",
44
- "name",
45
- "className"
46
- ]);
47
- const {
48
- radioName
49
- } = useContext(RadioContext);
50
- return /* @__PURE__ */ jsxs("label", {
51
- className: `rds-radio-toggle ${className}`,
52
- children: [/* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({
53
- className: "rds-radio-toggle__input"
54
- }, rest), {
55
- ref,
56
- type: "radio",
57
- name: radioName || name
58
- })), /* @__PURE__ */ jsx("span", {
59
- className: "rds-radio-toggle__label",
60
- children: label
61
- })]
62
- });
63
- });
64
- RadioToggleInput.displayName = "RadioToggleInput";
65
- export { RadioContext as R, RadioToggleInput as a };
@@ -1,106 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __objRest = (source, exclude) => {
18
- var target = {};
19
- for (var prop in source)
20
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
- target[prop] = source[prop];
22
- if (source != null && __getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(source)) {
24
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
- target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
- import { forwardRef, useRef, useState } from "react";
30
- import { a as jsxs, j as jsx } from "../core/RiksTV.js";
31
- const generateId = (id) => {
32
- if (id) {
33
- return id;
34
- }
35
- return `${new Date().valueOf()}`;
36
- };
37
- var toggleButton = "";
38
- const ToggleButton = forwardRef((_a, ref) => {
39
- var _b = _a, {
40
- defaultChecked,
41
- showLabel = true,
42
- icons,
43
- iconClass = "",
44
- children,
45
- onChange,
46
- id,
47
- className = ""
48
- } = _b, rest = __objRest(_b, [
49
- "defaultChecked",
50
- "showLabel",
51
- "icons",
52
- "iconClass",
53
- "children",
54
- "onChange",
55
- "id",
56
- "className"
57
- ]);
58
- const internalRef = useRef(null);
59
- const [internalId] = useState(generateId(id));
60
- const [isChecked, setIsChecked] = useState(!!defaultChecked);
61
- const CheckedIcon = icons && "checkedIcon" in icons ? icons.checkedIcon : null;
62
- const UncheckedIcon = icons && "uncheckedIcon" in icons ? icons.uncheckedIcon : null;
63
- const ToggleIcon = icons && "toggleIcon" in icons ? icons.toggleIcon : null;
64
- const inputRef = ref || internalRef;
65
- const handleChange = (e) => {
66
- var _a2;
67
- if (typeof onChange === "function") {
68
- onChange(e);
69
- }
70
- if (typeof inputRef !== "function") {
71
- setIsChecked(!!((_a2 = inputRef.current) == null ? void 0 : _a2.checked));
72
- } else {
73
- setIsChecked(!isChecked);
74
- }
75
- };
76
- return /* @__PURE__ */ jsxs("div", {
77
- className,
78
- children: [/* @__PURE__ */ jsx("input", __spreadValues({
79
- id: internalId,
80
- ref: inputRef,
81
- type: "checkbox",
82
- className: "rds-toggle-button__input",
83
- onChange: handleChange,
84
- defaultChecked
85
- }, rest)), /* @__PURE__ */ jsx("label", {
86
- "data-testid": "toggle-button__label",
87
- className: `rds-toggle-button ${showLabel ? "" : "rds-toggle-button--round"}`,
88
- htmlFor: internalId,
89
- children: /* @__PURE__ */ jsxs("span", {
90
- className: "rds-toggle-button__content",
91
- children: [icons && /* @__PURE__ */ jsxs("span", {
92
- className: `rds-toggle-button__rounded ${iconClass}`,
93
- children: [ToggleIcon && /* @__PURE__ */ jsx(ToggleIcon, {
94
- checked: isChecked
95
- }), CheckedIcon && isChecked && /* @__PURE__ */ jsx(CheckedIcon, {}), UncheckedIcon && !isChecked && /* @__PURE__ */ jsx(UncheckedIcon, {})]
96
- }), /* @__PURE__ */ jsx("span", {
97
- "data-testid": "toggle-button__label__text",
98
- className: showLabel ? "" : "sr-only",
99
- children
100
- })]
101
- })
102
- })]
103
- });
104
- });
105
- ToggleButton.displayName = "ToggleButton";
106
- export { ToggleButton as T };
@@ -1 +0,0 @@
1
- export declare const generateId: (id: string | undefined) => string;
@@ -1,95 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { forwardRef } from "react";
33
- import { j as jsx } from "../core/RiksTV.js";
34
- var typography = "";
35
- const typographyFactory = (factoryProps) => forwardRef((_a, ref) => {
36
- var _b = _a, {
37
- children,
38
- lookLike = factoryProps.lookLike,
39
- className = "",
40
- lightBackground = false
41
- } = _b, props = __objRest(_b, [
42
- "children",
43
- "lookLike",
44
- "className",
45
- "lightBackground"
46
- ]);
47
- const C = factoryProps.semanticElement;
48
- return /* @__PURE__ */ jsx(C, __spreadProps(__spreadValues({
49
- className: `rds-${lookLike} ${lightBackground ? `rds-${lookLike}--light` : ""} ${className}`
50
- }, props), {
51
- ref,
52
- children
53
- }));
54
- });
55
- const DisplayTitle = typographyFactory({
56
- semanticElement: "h1",
57
- lookLike: "display-title"
58
- });
59
- const H1 = typographyFactory({
60
- semanticElement: "h1",
61
- lookLike: "title-1"
62
- });
63
- const H2 = typographyFactory({
64
- semanticElement: "h2",
65
- lookLike: "title-2"
66
- });
67
- const H3 = typographyFactory({
68
- semanticElement: "h3",
69
- lookLike: "title-3"
70
- });
71
- const H4 = typographyFactory({
72
- semanticElement: "h4",
73
- lookLike: "title-4"
74
- });
75
- const Body = typographyFactory({
76
- semanticElement: "p",
77
- lookLike: "body"
78
- });
79
- const SubBody = typographyFactory({
80
- semanticElement: "p",
81
- lookLike: "sub-body"
82
- });
83
- const Tag = typographyFactory({
84
- semanticElement: "span",
85
- lookLike: "tag"
86
- });
87
- const Bold = typographyFactory({
88
- semanticElement: "strong",
89
- lookLike: "bold"
90
- });
91
- const Meta = typographyFactory({
92
- semanticElement: "span",
93
- lookLike: "meta"
94
- });
95
- export { Body as B, DisplayTitle as D, H1 as H, Meta as M, SubBody as S, Tag as T, H2 as a, H3 as b, H4 as c, Bold as d };