@dbcdk/react-components 0.0.123 → 0.0.124

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/client.cjs CHANGED
@@ -28,6 +28,7 @@ var Page = require('./components/page/Page');
28
28
  var Breadcrumbs = require('./components/breadcrumbs/Breadcrumbs');
29
29
  var Circle = require('./components/circle/Circle');
30
30
  var Checkbox = require('./components/forms/checkbox/Checkbox');
31
+ var Switch = require('./components/forms/switch/Switch');
31
32
  var Table = require('./components/table/Table');
32
33
  var chartColors = require('./constants/chart-colors');
33
34
  var chartColors_types = require('./constants/chart-colors.types');
@@ -251,6 +252,12 @@ Object.keys(Checkbox).forEach(function (k) {
251
252
  get: function () { return Checkbox[k]; }
252
253
  });
253
254
  });
255
+ Object.keys(Switch).forEach(function (k) {
256
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
257
+ enumerable: true,
258
+ get: function () { return Switch[k]; }
259
+ });
260
+ });
254
261
  Object.keys(Table).forEach(function (k) {
255
262
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
256
263
  enumerable: true,
package/dist/client.d.ts CHANGED
@@ -25,6 +25,7 @@ export * from './components/page/Page';
25
25
  export * from './components/breadcrumbs/Breadcrumbs';
26
26
  export * from './components/circle/Circle';
27
27
  export * from './components/forms/checkbox/Checkbox';
28
+ export * from './components/forms/switch/Switch';
28
29
  export * from './components/table/Table';
29
30
  export * from './constants/chart-colors';
30
31
  export * from './constants/chart-colors.types';
package/dist/client.js CHANGED
@@ -26,6 +26,7 @@ export * from './components/page/Page';
26
26
  export * from './components/breadcrumbs/Breadcrumbs';
27
27
  export * from './components/circle/Circle';
28
28
  export * from './components/forms/checkbox/Checkbox';
29
+ export * from './components/forms/switch/Switch';
29
30
  export * from './components/table/Table';
30
31
  export * from './constants/chart-colors';
31
32
  export * from './constants/chart-colors.types';
@@ -75,7 +75,7 @@
75
75
  }
76
76
 
77
77
  .lg .content {
78
- gap: var(--spacing-lg);
78
+ gap: var(--spacing-md);
79
79
  }
80
80
 
81
81
  /* Layout */
@@ -34,6 +34,9 @@
34
34
  }
35
35
 
36
36
  /* Status variants */
37
+ .neutral {
38
+ background-color: var(--color-neutral);
39
+ }
37
40
  .brand {
38
41
  background-color: var(--color-brand);
39
42
  }
@@ -0,0 +1,90 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var react = require('react');
6
+ var Tooltip = require('../../../components/overlay/tooltip/Tooltip');
7
+ var styles = require('./Switch.module.css');
8
+ var InputContainer = require('../input-container/InputContainer');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
13
+
14
+ function Switch({
15
+ checked: controlled,
16
+ onChange,
17
+ disabled,
18
+ modified,
19
+ label,
20
+ labelAs = "label",
21
+ size = "md",
22
+ containerLabel,
23
+ error,
24
+ helpText,
25
+ orientation = "horizontal",
26
+ labelWidth = "160px",
27
+ fullWidth = false,
28
+ required = false,
29
+ noContainer = false,
30
+ id,
31
+ "data-cy": dataCy,
32
+ tooltip,
33
+ tooltipPlacement
34
+ }) {
35
+ const [internal, setInternal] = react.useState(false);
36
+ const isChecked = controlled != null ? controlled : internal;
37
+ const generatedId = react.useId();
38
+ const controlId = id != null ? id : `switch-${generatedId}`;
39
+ const toggle = (e) => {
40
+ if (disabled) return;
41
+ const value = !isChecked;
42
+ setInternal(value);
43
+ onChange == null ? void 0 : onChange(value, e);
44
+ };
45
+ const trackClass = [styles__default.default.switch, isChecked ? styles__default.default.on : "", size === "sm" ? styles__default.default.sm : ""].filter(Boolean).join(" ");
46
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(
47
+ "span",
48
+ {
49
+ className: [styles__default.default.container, size === "sm" ? styles__default.default.containerSm : ""].filter(Boolean).join(" "),
50
+ "data-cy": dataCy,
51
+ children: [
52
+ /* @__PURE__ */ jsxRuntime.jsx(Tooltip.Tooltip, { content: tooltip, placement: tooltipPlacement, children: /* @__PURE__ */ jsxRuntime.jsx(
53
+ "button",
54
+ {
55
+ id: controlId,
56
+ disabled,
57
+ type: "button",
58
+ role: "switch",
59
+ "aria-checked": isChecked,
60
+ "aria-disabled": disabled || void 0,
61
+ "aria-invalid": Boolean(error) || void 0,
62
+ onClick: toggle,
63
+ className: trackClass,
64
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.thumb, "aria-hidden": "true" })
65
+ }
66
+ ) }),
67
+ label && (labelAs === "label" ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: styles__default.default.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: label }))
68
+ ]
69
+ }
70
+ );
71
+ if (noContainer) return content;
72
+ return /* @__PURE__ */ jsxRuntime.jsx(
73
+ InputContainer.InputContainer,
74
+ {
75
+ modified,
76
+ label: containerLabel,
77
+ htmlFor: controlId,
78
+ error,
79
+ helpText,
80
+ orientation,
81
+ size,
82
+ labelWidth,
83
+ fullWidth,
84
+ required,
85
+ children: content
86
+ }
87
+ );
88
+ }
89
+
90
+ exports.Switch = Switch;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import type { JSX, ReactNode } from 'react';
3
+ import type { TooltipPlacement } from '../../../components/overlay/tooltip/TooltipProvider';
4
+ type Size = 'sm' | 'md';
5
+ interface SwitchProps {
6
+ checked?: boolean;
7
+ onChange?: (checked: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
8
+ disabled?: boolean;
9
+ modified?: boolean;
10
+ label?: ReactNode;
11
+ labelAs?: 'label' | 'span';
12
+ size?: Size;
13
+ containerLabel?: string;
14
+ error?: string;
15
+ helpText?: string;
16
+ orientation?: 'vertical' | 'horizontal';
17
+ labelWidth?: string;
18
+ fullWidth?: boolean;
19
+ required?: boolean;
20
+ noContainer?: boolean;
21
+ id?: string;
22
+ 'data-cy'?: string;
23
+ tooltip?: ReactNode;
24
+ tooltipPlacement?: TooltipPlacement;
25
+ }
26
+ export declare function Switch({ checked: controlled, onChange, disabled, modified, label, labelAs, size, containerLabel, error, helpText, orientation, labelWidth, fullWidth, required, noContainer, id, 'data-cy': dataCy, tooltip, tooltipPlacement, }: SwitchProps): JSX.Element;
27
+ export {};
@@ -0,0 +1,84 @@
1
+ 'use client';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useId } from 'react';
4
+ import { Tooltip } from '../../../components/overlay/tooltip/Tooltip';
5
+ import styles from './Switch.module.css';
6
+ import { InputContainer } from '../input-container/InputContainer';
7
+
8
+ function Switch({
9
+ checked: controlled,
10
+ onChange,
11
+ disabled,
12
+ modified,
13
+ label,
14
+ labelAs = "label",
15
+ size = "md",
16
+ containerLabel,
17
+ error,
18
+ helpText,
19
+ orientation = "horizontal",
20
+ labelWidth = "160px",
21
+ fullWidth = false,
22
+ required = false,
23
+ noContainer = false,
24
+ id,
25
+ "data-cy": dataCy,
26
+ tooltip,
27
+ tooltipPlacement
28
+ }) {
29
+ const [internal, setInternal] = useState(false);
30
+ const isChecked = controlled != null ? controlled : internal;
31
+ const generatedId = useId();
32
+ const controlId = id != null ? id : `switch-${generatedId}`;
33
+ const toggle = (e) => {
34
+ if (disabled) return;
35
+ const value = !isChecked;
36
+ setInternal(value);
37
+ onChange == null ? void 0 : onChange(value, e);
38
+ };
39
+ const trackClass = [styles.switch, isChecked ? styles.on : "", size === "sm" ? styles.sm : ""].filter(Boolean).join(" ");
40
+ const content = /* @__PURE__ */ jsxs(
41
+ "span",
42
+ {
43
+ className: [styles.container, size === "sm" ? styles.containerSm : ""].filter(Boolean).join(" "),
44
+ "data-cy": dataCy,
45
+ children: [
46
+ /* @__PURE__ */ jsx(Tooltip, { content: tooltip, placement: tooltipPlacement, children: /* @__PURE__ */ jsx(
47
+ "button",
48
+ {
49
+ id: controlId,
50
+ disabled,
51
+ type: "button",
52
+ role: "switch",
53
+ "aria-checked": isChecked,
54
+ "aria-disabled": disabled || void 0,
55
+ "aria-invalid": Boolean(error) || void 0,
56
+ onClick: toggle,
57
+ className: trackClass,
58
+ children: /* @__PURE__ */ jsx("span", { className: styles.thumb, "aria-hidden": "true" })
59
+ }
60
+ ) }),
61
+ label && (labelAs === "label" ? /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsx("span", { className: styles.label, children: label }))
62
+ ]
63
+ }
64
+ );
65
+ if (noContainer) return content;
66
+ return /* @__PURE__ */ jsx(
67
+ InputContainer,
68
+ {
69
+ modified,
70
+ label: containerLabel,
71
+ htmlFor: controlId,
72
+ error,
73
+ helpText,
74
+ orientation,
75
+ size,
76
+ labelWidth,
77
+ fullWidth,
78
+ required,
79
+ children: content
80
+ }
81
+ );
82
+ }
83
+
84
+ export { Switch };
@@ -0,0 +1,83 @@
1
+ .container {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: var(--spacing-sm);
5
+ vertical-align: middle;
6
+ line-height: var(--line-height-normal);
7
+ color: var(--color-fg-default);
8
+ }
9
+
10
+ .containerSm {
11
+ gap: var(--spacing-xs);
12
+ }
13
+
14
+ .switch {
15
+ position: relative;
16
+ display: inline-flex;
17
+ align-items: center;
18
+ flex-shrink: 0;
19
+ width: 36px;
20
+ height: 20px;
21
+ border-radius: 999px;
22
+ border: none;
23
+ background-color: var(--color-border-default);
24
+ cursor: pointer;
25
+ padding: 0;
26
+ transition:
27
+ background-color var(--transition-fast) var(--ease-standard),
28
+ box-shadow var(--transition-fast) var(--ease-standard);
29
+ }
30
+
31
+ .switch.sm {
32
+ width: 28px;
33
+ height: 16px;
34
+ }
35
+
36
+ .switch:hover {
37
+ opacity: 0.75;
38
+ }
39
+
40
+ .switch.on {
41
+ background-color: var(--color-brand);
42
+ }
43
+
44
+ .switch:disabled {
45
+ cursor: not-allowed;
46
+ opacity: 0.4;
47
+ }
48
+
49
+ .thumb {
50
+ position: absolute;
51
+ left: 2px;
52
+ width: 16px;
53
+ height: 16px;
54
+ border-radius: 50%;
55
+ background-color: var(--color-fg-inverse);
56
+ box-shadow: var(--shadow-sm);
57
+ transition: transform var(--transition-fast) var(--ease-standard);
58
+ pointer-events: none;
59
+ }
60
+
61
+ .switch.sm .thumb {
62
+ width: 12px;
63
+ height: 12px;
64
+ }
65
+
66
+ .switch.on .thumb {
67
+ transform: translateX(16px);
68
+ }
69
+
70
+ .switch.sm.on .thumb {
71
+ transform: translateX(12px);
72
+ }
73
+
74
+ .label {
75
+ display: block;
76
+ font-size: var(--font-size-sm);
77
+ min-width: 0;
78
+ flex: 1 1 auto;
79
+ line-height: var(--line-height-normal);
80
+ white-space: normal;
81
+ overflow-wrap: anywhere;
82
+ word-break: break-word;
83
+ }
@@ -13,6 +13,7 @@
13
13
 
14
14
  .icon svg {
15
15
  height: var(--icon-size-md);
16
+ width: auto;
16
17
  }
17
18
 
18
19
  .success {
@@ -132,7 +132,7 @@
132
132
  align-items: center;
133
133
 
134
134
  background: var(--color-bg-surface);
135
- padding: var(--spacing-lg) var(--spacing-md);
135
+ padding: var(--spacing-lg) var(--spacing-xl);
136
136
  overflow: visible;
137
137
  }
138
138
 
@@ -154,7 +154,7 @@
154
154
  display: flex;
155
155
  justify-content: center;
156
156
  width: 100%;
157
- padding-inline: var(--spacing-md);
157
+ padding-inline: var(--spacing-xl);
158
158
  }
159
159
 
160
160
  .headerContent {
@@ -9,7 +9,7 @@
9
9
  max-inline-size: var(--container-xl);
10
10
  margin-inline: auto;
11
11
  padding-block: var(--spacing-lg);
12
- padding-inline: var(--spacing-md);
12
+ padding-inline: var(--spacing-xl);
13
13
  display: flex;
14
14
  flex-direction: row;
15
15
  align-items: flex-start;
@@ -263,6 +263,10 @@
263
263
  padding-block: var(--spacing-xxs);
264
264
  }
265
265
 
266
+ .headerCell:hover [data-resizer='true']::after {
267
+ opacity: 1;
268
+ }
269
+
266
270
  .cell.contextMenuCell {
267
271
  vertical-align: top;
268
272
  padding-block: var(--spacing-2xs);
@@ -194,7 +194,7 @@ function RowContextMenu({
194
194
  "aria-label": `Flere handlinger for r\xE6kke ${String(rowId)}`,
195
195
  "aria-haspopup": "menu",
196
196
  "aria-expanded": isOpen ? true : false,
197
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { size: 16 }),
197
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { size: 16 }),
198
198
  "data-row-context-menu": "true",
199
199
  onClick: (e) => {
200
200
  e.stopPropagation();
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { MoreHorizontal } from 'lucide-react';
2
+ import { MoreVertical } from 'lucide-react';
3
3
  import { Checkbox } from '../../../components/forms/checkbox/Checkbox';
4
4
  import { RadioButton } from '../../../components/forms/radio-buttons/RadioButton';
5
5
  import { Popover } from '../../../components/popover/Popover';
@@ -188,7 +188,7 @@ function RowContextMenu({
188
188
  "aria-label": `Flere handlinger for r\xE6kke ${String(rowId)}`,
189
189
  "aria-haspopup": "menu",
190
190
  "aria-expanded": isOpen ? true : false,
191
- icon: /* @__PURE__ */ jsx(MoreHorizontal, { size: 16 }),
191
+ icon: /* @__PURE__ */ jsx(MoreVertical, { size: 16 }),
192
192
  "data-row-context-menu": "true",
193
193
  onClick: (e) => {
194
194
  e.stopPropagation();
@@ -19,4 +19,6 @@
19
19
  top: 50%;
20
20
  transform: translateY(-50%);
21
21
  background-color: var(--opac-bg-default);
22
+ opacity: 0;
23
+ transition: opacity 0.15s;
22
24
  }
package/dist/index.css CHANGED
@@ -28,6 +28,7 @@
28
28
  @import './components/forms/input/Input.module.css';
29
29
  @import './components/forms/radio-buttons/RadioButtons.module.css';
30
30
  @import './components/forms/select/Select.module.css';
31
+ @import './components/forms/switch/Switch.module.css';
31
32
  @import './components/forms/text-area/Textarea.module.css';
32
33
  @import './components/forms/typeahead/Typeahead.module.css';
33
34
  @import './components/grid/Grid.module.css';
@@ -70,7 +70,7 @@
70
70
  --font-size-xs: 12px;
71
71
  --font-size-sm: 14px;
72
72
  --font-size-md: 16px;
73
- --font-size-lg: 18px;
73
+ --font-size-lg: 20px;
74
74
  --font-size-xl: 24px;
75
75
  --font-size-2xl: 30px;
76
76
 
@@ -172,7 +172,7 @@ html {
172
172
  --color-status-info-fg-soft: var(--color-status-info-fg);
173
173
 
174
174
  /* Chart colors */
175
- --color-chart-empty: color-mix(in srgb, var(--color-fg-muted) 15%, rgb(255 255 255 / 0));
175
+ --color-chart-empty: color-mix(in srgb, var(--color-fg-muted) 10%, rgb(255 255 255 / 0));
176
176
  --color-chart-neutral: color-mix(in srgb, var(--color-fg-muted) 25%, rgb(255 255 255 / 0));
177
177
  --color-chart-primary: color-mix(in srgb, var(--dbc-blue-500) 75%, rgb(255 255 255 / 0));
178
178
  --color-chart-success: color-mix(in srgb, var(--dbc-green-500) 75%, rgb(255 255 255 / 0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcdk/react-components",
3
- "version": "0.0.123",
3
+ "version": "0.0.124",
4
4
  "description": "Reusable React components for DBC projects",
5
5
  "license": "ISC",
6
6
  "author": "",