@dbcdk/react-components 0.0.82 → 0.0.84
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/components/__stories__/story-components/Flex.d.ts +2 -0
- package/dist/components/__stories__/story-components/Flex.js +177 -0
- package/dist/components/__stories__/story-components/Flex.module.css +317 -0
- package/dist/components/forms/input/Input.d.ts +1 -0
- package/dist/components/forms/input/Input.js +3 -1
- package/dist/components/forms/input/Input.module.css +25 -5
- package/dist/components/forms/select/Select.module.css +17 -4
- package/dist/components/forms/text-area/Textarea.js +2 -0
- package/dist/components/forms/text-area/Textarea.module.css +15 -3
- package/dist/components/json-viewer/JsonViewer.module.css +5 -1
- package/dist/components/overlay/tooltip/useTooltipTrigger.d.ts +1 -0
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +6 -3
- package/package.json +1 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CopyButton } from '../../../components/copy-button/CopyButton';
|
|
3
|
+
import { Headline } from '../../../components/headline/Headline';
|
|
4
|
+
import styles from './Flex.module.css';
|
|
5
|
+
const BOXES = ['A', 'B', 'C'];
|
|
6
|
+
const GROUPS = [
|
|
7
|
+
{
|
|
8
|
+
key: 'display',
|
|
9
|
+
title: 'Display',
|
|
10
|
+
description: (_jsxs(_Fragment, { children: ["Start med ", _jsx("code", { className: styles.code, children: "dbc-flex" }), " eller", ' ', _jsx("code", { className: styles.code, children: "dbc-inline-flex" }), " for at aktivere flex layout."] })),
|
|
11
|
+
helpers: [
|
|
12
|
+
{ className: 'dbc-flex', description: 'Opretter en flex-container på blokniveau.' },
|
|
13
|
+
{ className: 'dbc-inline-flex', description: 'Opretter en flex-container på inline-niveau.' },
|
|
14
|
+
{
|
|
15
|
+
className: 'dbc-flex-center',
|
|
16
|
+
description: 'Shortcut der både sætter display:flex og centrerer indhold vandret og lodret.',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
key: 'direction',
|
|
22
|
+
title: 'Retning',
|
|
23
|
+
description: 'Bestemmer om elementer lægges vandret eller lodret.',
|
|
24
|
+
helpers: [
|
|
25
|
+
{ className: 'dbc-flex-row', description: 'Placerer elementer i en række.' },
|
|
26
|
+
{ className: 'dbc-flex-column', description: 'Placerer elementer i en kolonne.' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'wrap',
|
|
31
|
+
title: 'Wrap',
|
|
32
|
+
description: 'Styrer om elementer må bryde over på flere linjer.',
|
|
33
|
+
helpers: [
|
|
34
|
+
{ className: 'dbc-flex-wrap', description: 'Tillader linjeskift når der ikke er plads.' },
|
|
35
|
+
{ className: 'dbc-flex-nowrap', description: 'Holder alle elementer på samme linje.' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: 'justify',
|
|
40
|
+
title: 'Justify',
|
|
41
|
+
description: 'Fordeler elementer langs hovedaksen.',
|
|
42
|
+
helpers: [
|
|
43
|
+
{ className: 'dbc-justify-start', description: 'Pakker elementer mod starten.' },
|
|
44
|
+
{ className: 'dbc-justify-center', description: 'Centrerer elementer.' },
|
|
45
|
+
{ className: 'dbc-justify-end', description: 'Pakker elementer mod slutningen.' },
|
|
46
|
+
{ className: 'dbc-justify-between', description: 'Lægger plads mellem elementerne.' },
|
|
47
|
+
{ className: 'dbc-justify-around', description: 'Giver plads omkring hvert element.' },
|
|
48
|
+
{ className: 'dbc-justify-evenly', description: 'Fordeler pladsen helt jævnt.' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'items',
|
|
53
|
+
title: 'Align Items',
|
|
54
|
+
description: 'Justerer alle elementer på tværs af hovedaksen.',
|
|
55
|
+
helpers: [
|
|
56
|
+
{ className: 'dbc-items-start', description: 'Justerer alle elementer mod starten.' },
|
|
57
|
+
{ className: 'dbc-items-center', description: 'Centrerer alle elementer.' },
|
|
58
|
+
{ className: 'dbc-items-end', description: 'Justerer alle elementer mod slutningen.' },
|
|
59
|
+
{ className: 'dbc-items-stretch', description: 'Lader elementer strække sig i højden.' },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: 'self',
|
|
64
|
+
title: 'Align Self',
|
|
65
|
+
description: 'Overstyrer ét barns placering i forhold til resten af rækken.',
|
|
66
|
+
helpers: [
|
|
67
|
+
{ className: 'dbc-self-start', description: 'Justerer det enkelte element mod starten.' },
|
|
68
|
+
{ className: 'dbc-self-center', description: 'Centrerer det enkelte element.' },
|
|
69
|
+
{ className: 'dbc-self-end', description: 'Justerer det enkelte element mod slutningen.' },
|
|
70
|
+
{ className: 'dbc-self-stretch', description: 'Lader det enkelte element strække sig.' },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: 'gap',
|
|
75
|
+
title: 'Gap',
|
|
76
|
+
description: 'Bruger de samme spacing tokens som spacing-hjælperne.',
|
|
77
|
+
helpers: [
|
|
78
|
+
{
|
|
79
|
+
className: 'dbc-gap-xxs',
|
|
80
|
+
description: 'Mindste afstand. Brug til fx chips inde i en inputboks.',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
className: 'dbc-gap-xs',
|
|
84
|
+
description: 'Meget tæt afstand. Brug til fx ikon + label eller label + inputfelt.',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
className: 'dbc-gap-sm',
|
|
88
|
+
description: 'Standard tæt afstand. Brug til fx sideordnede knapper eller handlinger i en toolbar.',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
className: 'dbc-gap-md',
|
|
92
|
+
description: 'Moderat afstand. Brug til elementer, der hører til samme sektion, men ikke direkte sammen.',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
className: 'dbc-gap-lg',
|
|
96
|
+
description: 'Større afstand. Brug til adskillelse af logisk forskellige grupper inden for samme visning.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
className: 'dbc-gap-xl',
|
|
100
|
+
description: 'Størst afstand. Brug til overordnede layoutområder eller markante sektionsskift.',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: 'behavior',
|
|
106
|
+
title: 'Flex adfærd',
|
|
107
|
+
description: 'Styrer hvordan det enkelte barn vokser eller krymper.',
|
|
108
|
+
helpers: [
|
|
109
|
+
{ className: 'dbc-flex-grow', description: 'Lader elementet tage ledig plads.' },
|
|
110
|
+
{ className: 'dbc-flex-shrink', description: 'Tillader elementet at krympe.' },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
function HelperCode({ children }) {
|
|
115
|
+
return _jsx("code", { className: styles.code, children: children });
|
|
116
|
+
}
|
|
117
|
+
function DemoBoxes() {
|
|
118
|
+
return (_jsx(_Fragment, { children: BOXES.map((label, index) => (_jsx("div", { className: `${styles.demoBox} ${index === 1 ? styles.tallBox : ''}`, "data-label": label, children: label }, label))) }));
|
|
119
|
+
}
|
|
120
|
+
function DefaultPreview({ className, baseClassName = 'dbc-flex', }) {
|
|
121
|
+
return (_jsx("div", { className: `${styles.demoSurface} ${baseClassName} ${className}`, children: _jsx(DemoBoxes, {}) }));
|
|
122
|
+
}
|
|
123
|
+
function InlinePreview({ className }) {
|
|
124
|
+
return (_jsxs("div", { className: styles.inlineRow, children: [_jsx("span", { className: styles.inlineLabel, children: "F\u00F8r" }), _jsx("span", { className: `${styles.inlineSurface} ${className}`, children: _jsx(DemoBoxes, {}) }), _jsx("span", { className: styles.inlineLabel, children: "Efter" })] }));
|
|
125
|
+
}
|
|
126
|
+
function SelfPreview({ className }) {
|
|
127
|
+
return (_jsx("div", { className: `${styles.demoSurface} ${styles.tallSurface} dbc-flex dbc-gap-xs dbc-items-stretch`, children: BOXES.map((label, index) => (_jsx("div", { className: `${styles.demoBox} ${index === 1 ? className : ''}`, "data-label": label, children: label }, label))) }));
|
|
128
|
+
}
|
|
129
|
+
function FlexGrowPreview() {
|
|
130
|
+
return (_jsxs("div", { className: `${styles.demoSurface} ${styles.growSurface} dbc-flex dbc-gap-xs`, children: [_jsx("div", { className: styles.growSideBox, children: "A" }), _jsx("div", { className: `${styles.flexBehaviorBox} ${styles.growMainBox} dbc-flex-grow`, children: "B" }), _jsx("div", { className: styles.growSideBox, children: "C" })] }));
|
|
131
|
+
}
|
|
132
|
+
function FlexShrinkPreview() {
|
|
133
|
+
return (_jsxs("div", { className: `${styles.demoSurface} ${styles.shrinkSurface} dbc-flex dbc-gap-xs`, children: [_jsx("div", { className: styles.fixedBox, children: "A" }), _jsx("div", { className: `${styles.shrinkBox} dbc-flex-shrink`, children: "B" }), _jsx("div", { className: styles.fixedBox, children: "C" })] }));
|
|
134
|
+
}
|
|
135
|
+
function CenterPreview({ className }) {
|
|
136
|
+
return (_jsx("div", { className: `${styles.centerSurface} ${className}`, children: _jsx("div", { className: styles.demoBox, children: "Center" }) }));
|
|
137
|
+
}
|
|
138
|
+
function WrapPreview({ className }) {
|
|
139
|
+
return (_jsxs("div", { className: `${styles.demoSurface} ${styles.wrapSurface} dbc-flex dbc-gap-xs ${className}`, children: [_jsx("div", { className: styles.wideBox, children: "Alpha" }), _jsx("div", { className: styles.wideBox, children: "Beta" }), _jsx("div", { className: styles.wideBox, children: "Gamma" })] }));
|
|
140
|
+
}
|
|
141
|
+
function JustifyPreview({ className }) {
|
|
142
|
+
return (_jsx("div", { className: `${styles.demoSurface} dbc-flex ${className}`, children: _jsx(DemoBoxes, {}) }));
|
|
143
|
+
}
|
|
144
|
+
function ItemsPreview({ className }) {
|
|
145
|
+
return (_jsxs("div", { className: `${styles.demoSurface} ${styles.tallSurface} dbc-flex dbc-gap-xs ${className}`, children: [_jsx("div", { className: `${styles.demoBox} ${styles.shortBox}`, children: "A" }), _jsx("div", { className: `${styles.demoBox} ${styles.midBox}`, children: "B" }), _jsx("div", { className: `${styles.demoBox} ${styles.tallBox}`, children: "C" })] }));
|
|
146
|
+
}
|
|
147
|
+
function Preview({ className, groupKey }) {
|
|
148
|
+
if (className === 'dbc-inline-flex')
|
|
149
|
+
return _jsx(InlinePreview, { className: className });
|
|
150
|
+
if (className === 'dbc-flex-center')
|
|
151
|
+
return _jsx(CenterPreview, { className: className });
|
|
152
|
+
if (groupKey === 'wrap')
|
|
153
|
+
return _jsx(WrapPreview, { className: className });
|
|
154
|
+
if (groupKey === 'justify')
|
|
155
|
+
return _jsx(JustifyPreview, { className: className });
|
|
156
|
+
if (groupKey === 'items')
|
|
157
|
+
return _jsx(ItemsPreview, { className: className });
|
|
158
|
+
if (groupKey === 'self')
|
|
159
|
+
return _jsx(SelfPreview, { className: className });
|
|
160
|
+
if (className === 'dbc-flex-grow')
|
|
161
|
+
return _jsx(FlexGrowPreview, {});
|
|
162
|
+
if (className === 'dbc-flex-shrink')
|
|
163
|
+
return _jsx(FlexShrinkPreview, {});
|
|
164
|
+
if (groupKey === 'gap') {
|
|
165
|
+
return _jsx(DefaultPreview, { className: className, baseClassName: "dbc-flex" });
|
|
166
|
+
}
|
|
167
|
+
return _jsx(DefaultPreview, { className: className });
|
|
168
|
+
}
|
|
169
|
+
function HelperCard({ helper, groupKey }) {
|
|
170
|
+
return (_jsxs("article", { className: styles.card, children: [_jsxs("div", { className: styles.cardHeader, children: [_jsxs("div", { className: styles.classNameRow, children: [_jsx(HelperCode, { children: helper.className }), _jsx(CopyButton, { text: helper.className, variant: "inline", size: "sm" })] }), _jsx("p", { className: styles.cardDescription, children: helper.description })] }), _jsx(Preview, { className: helper.className, groupKey: groupKey })] }));
|
|
171
|
+
}
|
|
172
|
+
function Group({ group }) {
|
|
173
|
+
return (_jsxs("section", { className: styles.section, children: [_jsx(Headline, { marker: true, severity: "info", disableMargin: true, size: 2, children: group.title }), _jsx("p", { className: styles.paragraph, children: group.description }), _jsx("div", { className: styles.grid, children: group.helpers.map(helper => (_jsx(HelperCard, { helper: helper, groupKey: group.key }, helper.className))) })] }));
|
|
174
|
+
}
|
|
175
|
+
export function Flex() {
|
|
176
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("header", { className: styles.header, children: _jsx(Headline, { disableMargin: true, children: "Flex-hj\u00E6lpere" }) }), _jsxs("section", { className: styles.intro, children: [_jsx("h2", { className: styles.h2, children: "Baggrund" }), _jsx("p", { className: styles.paragraph, children: "Biblioteket stiller et s\u00E6t flex-hj\u00E6lpeklasser til r\u00E5dighed, s\u00E5 du kan sammens\u00E6tte layout direkte i markup uden at oprette lokale CSS-filer til trivielle regler. Form\u00E5l er bl.a.:" }), _jsxs("ul", { className: styles.list, children: [_jsx("li", { children: "At hj\u00E6lpe med at sikre konsistent layout p\u00E5 tv\u00E6rs af sider og DBC-apps." }), _jsxs("li", { children: ["Undg\u00E5 CSS-filer, der kun indeholder trivielle regler som", ' ', _jsx(HelperCode, { children: "display: flex" }), ", ", _jsx(HelperCode, { children: "gap" }), " eller", ' ', _jsx(HelperCode, { children: "align-items" }), "."] }), _jsx("li", { children: "Mindre boilerplate og f\u00E6rre one-off-overrides p\u00E5 tv\u00E6rs af features." }), _jsx("li", { children: "Et f\u00E6lles, dokumenteret sprog for layoutkomposition, der holder sig inden for design-systemet." }), _jsxs("li", { children: ["Semantiske afstandsrelationer \u2014 ", _jsx(HelperCode, { children: "dbc-gap-sm" }), " frem for r\u00E5 pixelv\u00E6rdier i feature-kode."] })] }), _jsx("p", { className: styles.paragraph, children: "CSS-moduler har stadig en vigtig plads til komponent-specifik eller kompleks styling \u2014 pointen er blot, at de ikke beh\u00F8ver v\u00E6re standardl\u00F8sningen til rutinelayout." }), _jsx("h2", { className: styles.h2, children: "Navngivningskonvention" }), _jsx("p", { className: styles.paragraph, children: "Flex-hj\u00E6lperne er sm\u00E5 utility-klasser, som kan kombineres direkte i markup." }), _jsx("div", { className: styles.example, children: _jsx(HelperCode, { children: "dbc-flex dbc-flex-row dbc-gap-sm dbc-items-center" }) }), _jsxs("ul", { className: styles.list, children: [_jsxs("li", { children: ["Brug ", _jsx(HelperCode, { children: "dbc-flex" }), " eller ", _jsx(HelperCode, { children: "dbc-inline-flex" }), ' ', "som base."] }), _jsx("li", { children: "Tilf\u00F8j derefter helpers for retning, justering, gap og evt. flex-adf\u00E6rd p\u00E5 b\u00F8rnene." }), _jsxs("li", { children: [_jsx(HelperCode, { children: "dbc-gap-*" }), " f\u00F8lger spacing tokens: ", _jsx(HelperCode, { children: "xxs" }), ",", ' ', _jsx(HelperCode, { children: "xs" }), ", ", _jsx(HelperCode, { children: "sm" }), ", ", _jsx(HelperCode, { children: "md" }), ",", ' ', _jsx(HelperCode, { children: "lg" }), " og ", _jsx(HelperCode, { children: "xl" }), "."] })] })] }), GROUPS.map(group => (_jsx(Group, { group: group }, group.title)))] }));
|
|
177
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
margin-inline: auto;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 2rem;
|
|
6
|
+
padding: 1.5rem;
|
|
7
|
+
color: var(--color-text);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.header {
|
|
11
|
+
display: grid;
|
|
12
|
+
gap: 0.5rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.intro {
|
|
16
|
+
display: grid;
|
|
17
|
+
gap: 1rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.section {
|
|
21
|
+
display: grid;
|
|
22
|
+
gap: 1rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.grid {
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
|
28
|
+
gap: 1rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.card {
|
|
32
|
+
display: grid;
|
|
33
|
+
gap: 1rem;
|
|
34
|
+
padding: 1rem;
|
|
35
|
+
border: 1px solid var(--color-border);
|
|
36
|
+
border-radius: 0.75rem;
|
|
37
|
+
background: var(--color-surface);
|
|
38
|
+
box-shadow: var(--shadow-xs);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.cardHeader {
|
|
42
|
+
display: grid;
|
|
43
|
+
gap: 0.5rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.classNameRow {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: var(--spacing-xs);
|
|
50
|
+
flex-wrap: wrap;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cardDescription,
|
|
54
|
+
.paragraph {
|
|
55
|
+
margin: 0;
|
|
56
|
+
color: var(--color-text-secondary, #374151);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.h2 {
|
|
60
|
+
margin: 0;
|
|
61
|
+
margin-top: 0.75rem;
|
|
62
|
+
font-size: 1rem;
|
|
63
|
+
font-weight: 500;
|
|
64
|
+
color: #27272a;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.h2:first-child {
|
|
68
|
+
margin-top: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.example {
|
|
72
|
+
margin-top: 0.25rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.list {
|
|
76
|
+
margin: 0.25rem 0 0 1rem;
|
|
77
|
+
display: grid;
|
|
78
|
+
gap: 0.5rem;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.code {
|
|
82
|
+
border-radius: var(--border-radius-default);
|
|
83
|
+
background: var(--color-bg-default);
|
|
84
|
+
padding: 0 var(--spacing-xs);
|
|
85
|
+
line-height: 1.5;
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
font-family: var(--font-family-mono, monospace);
|
|
88
|
+
color: var(--color-text-secondary);
|
|
89
|
+
box-shadow: var(--shadow-xs);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.demoSurface {
|
|
93
|
+
min-height: 88px;
|
|
94
|
+
width: 100%;
|
|
95
|
+
padding: 0.75rem;
|
|
96
|
+
border-radius: 0.75rem;
|
|
97
|
+
border: 1px dashed var(--color-border-strong, var(--color-border));
|
|
98
|
+
background:
|
|
99
|
+
linear-gradient(180deg, rgb(255 255 255 / 0.35), transparent),
|
|
100
|
+
repeating-linear-gradient(
|
|
101
|
+
90deg,
|
|
102
|
+
var(--color-bg-default) 0,
|
|
103
|
+
var(--color-bg-default) 24px,
|
|
104
|
+
transparent 24px,
|
|
105
|
+
transparent 48px
|
|
106
|
+
),
|
|
107
|
+
var(--color-background);
|
|
108
|
+
background-size:
|
|
109
|
+
auto,
|
|
110
|
+
auto 100%,
|
|
111
|
+
auto;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.tallSurface {
|
|
115
|
+
min-height: 140px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.centerSurface {
|
|
119
|
+
min-height: 120px;
|
|
120
|
+
padding: 0.75rem;
|
|
121
|
+
border-radius: 0.75rem;
|
|
122
|
+
border: 1px dashed var(--color-border-strong, var(--color-border));
|
|
123
|
+
background:
|
|
124
|
+
radial-gradient(circle at center, var(--color-bg-info) 0, transparent 70%),
|
|
125
|
+
repeating-linear-gradient(
|
|
126
|
+
90deg,
|
|
127
|
+
var(--color-bg-default) 0,
|
|
128
|
+
var(--color-bg-default) 24px,
|
|
129
|
+
transparent 24px,
|
|
130
|
+
transparent 48px
|
|
131
|
+
),
|
|
132
|
+
var(--color-background);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.inlineRow {
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
gap: 0.5rem;
|
|
139
|
+
flex-wrap: wrap;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.inlineSurface {
|
|
143
|
+
padding: 0.5rem;
|
|
144
|
+
border-radius: 0.75rem;
|
|
145
|
+
border: 1px dashed var(--color-border-strong, var(--color-border));
|
|
146
|
+
background:
|
|
147
|
+
repeating-linear-gradient(
|
|
148
|
+
90deg,
|
|
149
|
+
var(--color-bg-default) 0,
|
|
150
|
+
var(--color-bg-default) 24px,
|
|
151
|
+
transparent 24px,
|
|
152
|
+
transparent 48px
|
|
153
|
+
),
|
|
154
|
+
var(--color-background);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.inlineLabel {
|
|
158
|
+
font-size: var(--font-size-xs);
|
|
159
|
+
color: var(--color-text-secondary, #374151);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.demoBox,
|
|
163
|
+
.fixedBox,
|
|
164
|
+
.flexBehaviorBox {
|
|
165
|
+
min-width: 2.75rem;
|
|
166
|
+
min-height: 2.75rem;
|
|
167
|
+
padding: 0.5rem 0.75rem;
|
|
168
|
+
border-radius: 0.625rem;
|
|
169
|
+
background: var(--color-status-info-bg, var(--color-bg-selected));
|
|
170
|
+
color: var(--color-fg-default);
|
|
171
|
+
border: 1px solid var(--color-status-info-border, var(--color-border-selected));
|
|
172
|
+
display: flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
font-weight: 500;
|
|
176
|
+
position: relative;
|
|
177
|
+
z-index: 1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.tallBox {
|
|
181
|
+
min-height: 3.75rem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.fixedBox {
|
|
185
|
+
width: 4.5rem;
|
|
186
|
+
flex: none;
|
|
187
|
+
background: var(--color-status-warning-bg, var(--opac-bg-default));
|
|
188
|
+
border-color: var(--color-status-warning-border, var(--color-border-default));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.flexBehaviorBox {
|
|
192
|
+
width: 4.5rem;
|
|
193
|
+
min-width: 0;
|
|
194
|
+
background: var(--color-bg-selected, var(--opac-bg-default));
|
|
195
|
+
border-color: var(--color-border-selected, var(--color-border-default));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.fixedBehaviorBox {
|
|
199
|
+
width: 4rem;
|
|
200
|
+
flex: none;
|
|
201
|
+
min-height: 2.75rem;
|
|
202
|
+
padding: 0.5rem 0.75rem;
|
|
203
|
+
border-radius: 0.625rem;
|
|
204
|
+
background: var(--color-status-warning-bg, var(--opac-bg-default));
|
|
205
|
+
color: var(--color-fg-default);
|
|
206
|
+
border: 1px solid var(--color-status-warning-border, var(--color-border-default));
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
font-weight: 500;
|
|
211
|
+
position: relative;
|
|
212
|
+
z-index: 1;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.growSurface {
|
|
216
|
+
max-width: 320px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.shrinkSurface {
|
|
220
|
+
max-width: 208px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.growSideBox {
|
|
224
|
+
width: 3rem;
|
|
225
|
+
flex: none;
|
|
226
|
+
min-height: 2.75rem;
|
|
227
|
+
padding: 0.5rem;
|
|
228
|
+
border-radius: 0.625rem;
|
|
229
|
+
background: var(--color-status-warning-bg, var(--opac-bg-default));
|
|
230
|
+
color: var(--color-fg-default);
|
|
231
|
+
border: 1px solid var(--color-status-warning-border, var(--color-border-default));
|
|
232
|
+
display: flex;
|
|
233
|
+
align-items: center;
|
|
234
|
+
justify-content: center;
|
|
235
|
+
font-weight: 500;
|
|
236
|
+
position: relative;
|
|
237
|
+
z-index: 1;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.growMainBox {
|
|
241
|
+
width: 4rem;
|
|
242
|
+
min-width: 4rem;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.shrinkBox {
|
|
246
|
+
width: 8rem;
|
|
247
|
+
min-width: 0;
|
|
248
|
+
min-height: 2.75rem;
|
|
249
|
+
padding: 0.5rem 0.75rem;
|
|
250
|
+
border-radius: 0.625rem;
|
|
251
|
+
background: var(--color-bg-selected, var(--opac-bg-default));
|
|
252
|
+
color: var(--color-fg-default);
|
|
253
|
+
border: 1px solid var(--color-border-selected, var(--color-border-default));
|
|
254
|
+
display: flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
justify-content: center;
|
|
257
|
+
font-weight: 500;
|
|
258
|
+
position: relative;
|
|
259
|
+
z-index: 1;
|
|
260
|
+
white-space: nowrap;
|
|
261
|
+
overflow: hidden;
|
|
262
|
+
text-overflow: ellipsis;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.wrapSurface {
|
|
266
|
+
max-width: 220px;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.wideBox {
|
|
270
|
+
min-width: 5rem;
|
|
271
|
+
min-height: 2.75rem;
|
|
272
|
+
padding: 0.5rem 0.75rem;
|
|
273
|
+
border-radius: 0.625rem;
|
|
274
|
+
background: var(--color-status-info-bg, var(--color-bg-selected));
|
|
275
|
+
color: var(--color-fg-default);
|
|
276
|
+
border: 1px solid var(--color-status-info-border, var(--color-border-selected));
|
|
277
|
+
display: flex;
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
font-weight: 500;
|
|
281
|
+
position: relative;
|
|
282
|
+
z-index: 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.shortBox,
|
|
286
|
+
.midBox {
|
|
287
|
+
min-width: 2.75rem;
|
|
288
|
+
padding: 0.5rem 0.75rem;
|
|
289
|
+
border-radius: 0.625rem;
|
|
290
|
+
background: var(--color-status-info-bg, var(--color-bg-selected));
|
|
291
|
+
color: var(--color-fg-default);
|
|
292
|
+
border: 1px solid var(--color-status-info-border, var(--color-border-selected));
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
justify-content: center;
|
|
296
|
+
font-weight: 500;
|
|
297
|
+
position: relative;
|
|
298
|
+
z-index: 1;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.shortBox {
|
|
302
|
+
min-height: 2.25rem;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.midBox {
|
|
306
|
+
min-height: 3.25rem;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@media (max-width: 640px) {
|
|
310
|
+
.container {
|
|
311
|
+
padding: 1rem;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.card {
|
|
315
|
+
padding: 0.875rem;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -16,6 +16,7 @@ export type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size
|
|
|
16
16
|
buttonIcon?: React.ReactNode;
|
|
17
17
|
tooltip?: React.ReactNode;
|
|
18
18
|
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
19
|
+
tooltipOpenOnFocus?: boolean;
|
|
19
20
|
modified?: boolean;
|
|
20
21
|
/**
|
|
21
22
|
* Custom content to render inside the input field, before the input element (e.g. chips)
|
|
@@ -18,7 +18,7 @@ function mergeRefs(...refs) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
export const Input = forwardRef(function Input({ label, error, helpText, orientation = 'vertical', labelWidth = '160px', fullWidth = false, required, tooltip, tooltipPlacement = 'right', modified = false, icon, autoFocus, minWidth, width, maxWidth, inputSize = 'md', variant = 'outlined', onClear, onButtonClick, buttonLabel, buttonIcon, id, style, className, fieldClassName, inputClassName, startAdornment, endAdornment, ...inputProps }, ref) {
|
|
21
|
+
export const Input = forwardRef(function Input({ label, error, helpText, orientation = 'vertical', labelWidth = '160px', fullWidth = false, required, tooltip, tooltipPlacement = 'right', modified = false, icon, autoFocus, minWidth, width, maxWidth, inputSize = 'md', variant = 'outlined', onClear, onButtonClick, buttonLabel, buttonIcon, id, tooltipOpenOnFocus = true, style, className, fieldClassName, inputClassName, startAdornment, endAdornment, ...inputProps }, ref) {
|
|
22
22
|
const inputRef = useRef(null);
|
|
23
23
|
const reactId = useId();
|
|
24
24
|
const inputId = id !== null && id !== void 0 ? id : `input-${reactId}`;
|
|
@@ -43,6 +43,8 @@ export const Input = forwardRef(function Input({ label, error, helpText, orienta
|
|
|
43
43
|
content: tooltip,
|
|
44
44
|
placement: tooltipPlacement,
|
|
45
45
|
offset: 8,
|
|
46
|
+
delayOpenMs: 0,
|
|
47
|
+
focusOpenMode: tooltipOpenOnFocus ? 'any' : 'focus-visible',
|
|
46
48
|
});
|
|
47
49
|
const trailingButtonVariant = variant === 'outlined' || variant === 'standalone' ? 'outlined' : 'default';
|
|
48
50
|
return (_jsx(InputContainer, { label: label, htmlFor: inputId, fullWidth: fullWidth, error: error, helpText: helpText, orientation: orientation, labelWidth: labelWidth, required: required, modified: modified, children: _jsxs("div", { style: rootStyle, className: [
|
|
@@ -191,7 +191,11 @@
|
|
|
191
191
|
|
|
192
192
|
.modified {
|
|
193
193
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 22%, var(--color-bg-surface));
|
|
194
|
-
border-color: color-mix(
|
|
194
|
+
border-color: color-mix(
|
|
195
|
+
in srgb,
|
|
196
|
+
var(--color-status-warning-border) 45%,
|
|
197
|
+
var(--color-border-default)
|
|
198
|
+
);
|
|
195
199
|
border-left-color: var(--color-status-warning-border);
|
|
196
200
|
border-left-width: 4px;
|
|
197
201
|
}
|
|
@@ -199,14 +203,22 @@
|
|
|
199
203
|
/* Hover should stay warm, not switch back to the normal border */
|
|
200
204
|
.modified:hover:not([aria-disabled='true']) {
|
|
201
205
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
202
|
-
border-color: color-mix(
|
|
206
|
+
border-color: color-mix(
|
|
207
|
+
in srgb,
|
|
208
|
+
var(--color-status-warning-border) 60%,
|
|
209
|
+
var(--color-border-default)
|
|
210
|
+
);
|
|
203
211
|
border-left-color: var(--color-status-warning-border);
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
/* Focus should also stay warm and readable */
|
|
207
215
|
.modified:focus-within:not([aria-disabled='true']) {
|
|
208
216
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
209
|
-
border-color: color-mix(
|
|
217
|
+
border-color: color-mix(
|
|
218
|
+
in srgb,
|
|
219
|
+
var(--color-status-warning-border) 75%,
|
|
220
|
+
var(--color-border-default)
|
|
221
|
+
);
|
|
210
222
|
border-left-color: var(--color-status-warning-border);
|
|
211
223
|
box-shadow: inset 0 0 0 1px
|
|
212
224
|
color-mix(in srgb, var(--color-status-warning-border) 55%, var(--color-border-default));
|
|
@@ -235,11 +247,19 @@
|
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
.subtle.modified:hover:not([aria-disabled='true']) {
|
|
238
|
-
background-color: color-mix(
|
|
250
|
+
background-color: color-mix(
|
|
251
|
+
in srgb,
|
|
252
|
+
var(--color-status-warning-bg) 36%,
|
|
253
|
+
var(--color-bg-toolbar-hover)
|
|
254
|
+
);
|
|
239
255
|
}
|
|
240
256
|
|
|
241
257
|
.subtle.modified:focus-within:not([aria-disabled='true']) {
|
|
242
|
-
border-color: color-mix(
|
|
258
|
+
border-color: color-mix(
|
|
259
|
+
in srgb,
|
|
260
|
+
var(--color-status-warning-border) 75%,
|
|
261
|
+
var(--color-border-default)
|
|
262
|
+
);
|
|
243
263
|
border-left-color: var(--color-status-warning-border);
|
|
244
264
|
box-shadow: inset 0 0 0 1px
|
|
245
265
|
color-mix(in srgb, var(--color-status-warning-border) 55%, var(--color-border-default));
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
.triggerModified {
|
|
2
2
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 22%, var(--color-bg-surface));
|
|
3
|
-
border-color: color-mix(
|
|
3
|
+
border-color: color-mix(
|
|
4
|
+
in srgb,
|
|
5
|
+
var(--color-status-warning-border) 45%,
|
|
6
|
+
var(--color-border-default)
|
|
7
|
+
);
|
|
4
8
|
border-left-color: var(--color-status-warning-border);
|
|
5
9
|
border-left-width: 4px;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
.triggerModified:hover:not([disabled]) {
|
|
9
13
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
10
|
-
border-color: color-mix(
|
|
14
|
+
border-color: color-mix(
|
|
15
|
+
in srgb,
|
|
16
|
+
var(--color-status-warning-border) 60%,
|
|
17
|
+
var(--color-border-default)
|
|
18
|
+
);
|
|
11
19
|
border-left-color: var(--color-status-warning-border);
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
.triggerModified:focus-visible {
|
|
15
23
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
16
|
-
border-color: color-mix(
|
|
24
|
+
border-color: color-mix(
|
|
25
|
+
in srgb,
|
|
26
|
+
var(--color-status-warning-border) 75%,
|
|
27
|
+
var(--color-border-default)
|
|
28
|
+
);
|
|
17
29
|
border-left-color: var(--color-status-warning-border);
|
|
18
|
-
box-shadow: inset 0 0 0 1px
|
|
30
|
+
box-shadow: inset 0 0 0 1px
|
|
31
|
+
color-mix(in srgb, var(--color-status-warning-border) 55%, var(--color-border-default));
|
|
19
32
|
}
|
|
@@ -38,6 +38,8 @@ className, ...rest }) {
|
|
|
38
38
|
content: tooltipEnabled ? tooltip : null,
|
|
39
39
|
placement: tooltipPlacement,
|
|
40
40
|
offset: 8,
|
|
41
|
+
delayOpenMs: 0,
|
|
42
|
+
focusOpenMode: 'any',
|
|
41
43
|
});
|
|
42
44
|
return (_jsx(InputContainer, { modified: modified, label: label, htmlFor: textareaId, error: error, helpText: helpText, helpTextAddition: showCount ? `${value === null || value === void 0 ? void 0 : value.length} tegn i denne boks` : undefined, orientation: orientation, labelWidth: labelWidth, fullWidth: fullWidth, required: required, children: _jsx("div", { className: [styles.container, modified ? styles.modified : ''].filter(Boolean).join(' '), children: _jsx("div", { ...(tooltipEnabled ? triggerProps : {}), children: inputField }) }) }));
|
|
43
45
|
};
|
|
@@ -4,20 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
.container.modified textarea {
|
|
6
6
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 22%, var(--color-bg-surface));
|
|
7
|
-
border-color: color-mix(
|
|
7
|
+
border-color: color-mix(
|
|
8
|
+
in srgb,
|
|
9
|
+
var(--color-status-warning-border) 45%,
|
|
10
|
+
var(--color-border-default)
|
|
11
|
+
);
|
|
8
12
|
border-left-color: var(--color-status-warning-border);
|
|
9
13
|
border-left-width: 4px;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
.container.modified textarea:hover {
|
|
13
17
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
14
|
-
border-color: color-mix(
|
|
18
|
+
border-color: color-mix(
|
|
19
|
+
in srgb,
|
|
20
|
+
var(--color-status-warning-border) 60%,
|
|
21
|
+
var(--color-border-default)
|
|
22
|
+
);
|
|
15
23
|
border-left-color: var(--color-status-warning-border);
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
.container.modified textarea:focus-visible {
|
|
19
27
|
background-color: color-mix(in srgb, var(--color-status-warning-bg) 28%, var(--color-bg-surface));
|
|
20
|
-
border-color: color-mix(
|
|
28
|
+
border-color: color-mix(
|
|
29
|
+
in srgb,
|
|
30
|
+
var(--color-status-warning-border) 75%,
|
|
31
|
+
var(--color-border-default)
|
|
32
|
+
);
|
|
21
33
|
border-left-color: var(--color-status-warning-border);
|
|
22
34
|
box-shadow: inset 0 0 0 1px
|
|
23
35
|
color-mix(in srgb, var(--color-status-warning-border) 55%, var(--color-border-default));
|
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
--json-pane-subtle: color-mix(in oklab, var(--color-fg-inverse) 44%, transparent);
|
|
8
8
|
--json-pane-hover: color-mix(in oklab, var(--color-fg-inverse) 8%, transparent);
|
|
9
9
|
--json-pane-selected: color-mix(in oklab, var(--color-brand) 24%, transparent);
|
|
10
|
-
--json-pane-highlight: color-mix(
|
|
10
|
+
--json-pane-highlight: color-mix(
|
|
11
|
+
in oklab,
|
|
12
|
+
var(--color-brand) 68%,
|
|
13
|
+
var(--color-syntax-accent) 32%
|
|
14
|
+
);
|
|
11
15
|
--color-highlight-bg: color-mix(in oklab, var(--json-pane-highlight) 58%, transparent);
|
|
12
16
|
--color-highlight-fg: var(--color-fg-inverse);
|
|
13
17
|
--json-pane-key: color-mix(in oklab, var(--color-fg-inverse) 88%, var(--color-syntax-accent) 12%);
|
|
@@ -5,7 +5,7 @@ export function useTooltipTrigger(options) {
|
|
|
5
5
|
const ctx = useContext(TooltipContext);
|
|
6
6
|
if (!ctx)
|
|
7
7
|
throw new Error('useTooltipTrigger must be used within <TooltipProvider>.');
|
|
8
|
-
const { content, placement = 'top', offset = 8, open, defaultOpen = false, delayOpenMs = 150, delayCloseMs = 50, } = options;
|
|
8
|
+
const { content, placement = 'top', offset = 8, open, defaultOpen = false, delayOpenMs = 150, delayCloseMs = 50, focusOpenMode = 'focus-visible', } = options;
|
|
9
9
|
const id = useId();
|
|
10
10
|
const triggerElRef = useRef(null);
|
|
11
11
|
const isControlled = open !== undefined;
|
|
@@ -88,8 +88,11 @@ export function useTooltipTrigger(options) {
|
|
|
88
88
|
};
|
|
89
89
|
const onFocus = (e) => {
|
|
90
90
|
clearTimers();
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
if (focusOpenMode === 'off')
|
|
92
|
+
return;
|
|
93
|
+
const shouldOpen = focusOpenMode === 'any' || e.currentTarget.matches(':focus-visible');
|
|
94
|
+
// By default we only show for keyboard focus. Callers can opt into opening on any focus.
|
|
95
|
+
if (!isControlled && shouldOpen)
|
|
93
96
|
setTimeout(() => {
|
|
94
97
|
setOpen(true);
|
|
95
98
|
}, MOTION_MS.tooltipOpen);
|