@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 +7 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/components/card/Card.module.css +1 -1
- package/dist/components/circle/Circle.module.css +3 -0
- package/dist/components/forms/switch/Switch.cjs +90 -0
- package/dist/components/forms/switch/Switch.d.ts +27 -0
- package/dist/components/forms/switch/Switch.js +84 -0
- package/dist/components/forms/switch/Switch.module.css +83 -0
- package/dist/components/icon/Icon.module.css +1 -0
- package/dist/components/page-layout/PageLayout.module.css +2 -2
- package/dist/components/page-layout/components/footer/Footer.module.css +1 -1
- package/dist/components/table/Table.module.css +4 -0
- package/dist/components/table/components/TableRow.cjs +1 -1
- package/dist/components/table/components/TableRow.js +2 -2
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +2 -0
- package/dist/index.css +1 -0
- package/dist/styles/themes/dbc/base.css +1 -1
- package/dist/styles/themes/dbc/colors.css +1 -1
- package/package.json +1 -1
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';
|
|
@@ -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
|
+
}
|
|
@@ -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-
|
|
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-
|
|
157
|
+
padding-inline: var(--spacing-xl);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
.headerContent {
|
|
@@ -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.
|
|
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 {
|
|
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(
|
|
191
|
+
icon: /* @__PURE__ */ jsx(MoreVertical, { size: 16 }),
|
|
192
192
|
"data-row-context-menu": "true",
|
|
193
193
|
onClick: (e) => {
|
|
194
194
|
e.stopPropagation();
|
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';
|
|
@@ -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)
|
|
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));
|