@robert-stackflow/oneui 0.6.21 → 0.6.23
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/CHANGELOG.md +30 -18
- package/README.md +270 -264
- package/components/AccountItem.module.css +103 -103
- package/components/AppShell.module.css +223 -223
- package/components/Badge.module.css +30 -30
- package/components/BarChart.module.css +35 -35
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Checkbox.module.css +95 -95
- package/components/ContextMenu.d.ts +3 -1
- package/components/ContextMenu.js +24 -4
- package/components/ContributionCalendar.module.css +121 -121
- package/components/Control.module.css +86 -86
- package/components/DataTable.module.css +75 -75
- package/components/Dialog.module.css +139 -139
- package/components/EditableHeading.d.ts +12 -0
- package/components/EditableHeading.js +76 -0
- package/components/EditableHeading.module.css +16 -0
- package/components/HierarchyPicker.module.css +185 -185
- package/components/IconButton.d.ts +3 -1
- package/components/IconButton.js +13 -2
- package/components/IconButton.module.css +13 -0
- package/components/Indicator.module.css +83 -83
- package/components/Layout.d.ts +1 -0
- package/components/Layout.module.css +82 -82
- package/components/Markdown.module.css +227 -227
- package/components/MenuItem.module.css +172 -172
- package/components/NavBar.module.css +130 -130
- package/components/Popover.d.ts +5 -1
- package/components/Popover.js +59 -28
- package/components/Popover.module.css +52 -0
- package/components/Progress.module.css +33 -33
- package/components/RadioGroup.module.css +87 -87
- package/components/RangeSlider.module.css +141 -141
- package/components/ResizablePanel.module.css +101 -101
- package/components/ResourceCard.module.css +98 -98
- package/components/Segmented.module.css +85 -85
- package/components/SidebarNavigation.js +4 -2
- package/components/SidebarNavigation.module.css +7 -2
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Tab.module.css +148 -148
- package/components/Table.module.css +87 -87
- package/components/TableOfContents.module.css +252 -252
- package/components/ThemePicker.module.css +178 -178
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/TreeTable.module.css +57 -57
- package/components/UptimeChart.module.css +15 -15
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -0
- package/components/motion.d.ts +1 -0
- package/components/motion.js +16 -2
- package/package.json +1 -1
- package/styles/base.css +206 -206
- package/styles/blue.css +270 -270
- package/styles/minimal.css +319 -319
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
min-width: 0;
|
|
3
|
-
}
|
|
4
|
-
.toolbar {
|
|
5
|
-
display: flex;
|
|
6
|
-
justify-content: flex-end;
|
|
7
|
-
align-items: center;
|
|
8
|
-
gap: 8px;
|
|
9
|
-
flex-wrap: wrap;
|
|
10
|
-
margin-bottom: 12px;
|
|
11
|
-
}
|
|
12
|
-
.columnMenu {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
}
|
|
16
|
-
.scroll {
|
|
17
|
-
composes: scroll from "./Table.module.css";
|
|
18
|
-
}
|
|
19
|
-
.table {
|
|
20
|
-
composes: table from "./Table.module.css";
|
|
21
|
-
}
|
|
22
|
-
.heading {
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: space-between;
|
|
26
|
-
gap: 8px;
|
|
27
|
-
}
|
|
28
|
-
.sort,
|
|
29
|
-
.filter {
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
gap: 7px;
|
|
33
|
-
border: 0;
|
|
34
|
-
background: transparent;
|
|
35
|
-
padding: 4px;
|
|
36
|
-
border-radius: 5px;
|
|
37
|
-
color: inherit;
|
|
38
|
-
}
|
|
39
|
-
.sort:hover,
|
|
40
|
-
.filter:hover {
|
|
41
|
-
background: var(--hover);
|
|
42
|
-
color: var(--fg);
|
|
43
|
-
}
|
|
44
|
-
.sort svg,
|
|
45
|
-
.filter svg {
|
|
46
|
-
width: 14px;
|
|
47
|
-
height: 14px;
|
|
48
|
-
}
|
|
49
|
-
.filter[data-active="true"] {
|
|
50
|
-
color: var(--accent-ink, var(--accent));
|
|
51
|
-
background: var(--selected);
|
|
52
|
-
}
|
|
53
|
-
.filterPanel {
|
|
54
|
-
max-height: 300px;
|
|
55
|
-
overflow: auto;
|
|
56
|
-
}
|
|
57
|
-
.selection {
|
|
58
|
-
width: 44px;
|
|
59
|
-
}
|
|
60
|
-
.selection label > span:last-child {
|
|
61
|
-
position: absolute;
|
|
62
|
-
width: 1px;
|
|
63
|
-
height: 1px;
|
|
64
|
-
overflow: hidden;
|
|
65
|
-
clip-path: inset(50%);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.filterReset {
|
|
69
|
-
display: flex;
|
|
70
|
-
justify-content: flex-end;
|
|
71
|
-
margin-top: 6px;
|
|
72
|
-
padding-top: 6px;
|
|
73
|
-
border-top: var(--separator-width) var(--separator-style)
|
|
74
|
-
var(--separator-color);
|
|
75
|
-
}
|
|
1
|
+
.container {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
}
|
|
4
|
+
.toolbar {
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: flex-end;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 8px;
|
|
9
|
+
flex-wrap: wrap;
|
|
10
|
+
margin-bottom: 12px;
|
|
11
|
+
}
|
|
12
|
+
.columnMenu {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
.scroll {
|
|
17
|
+
composes: scroll from "./Table.module.css";
|
|
18
|
+
}
|
|
19
|
+
.table {
|
|
20
|
+
composes: table from "./Table.module.css";
|
|
21
|
+
}
|
|
22
|
+
.heading {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
}
|
|
28
|
+
.sort,
|
|
29
|
+
.filter {
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 7px;
|
|
33
|
+
border: 0;
|
|
34
|
+
background: transparent;
|
|
35
|
+
padding: 4px;
|
|
36
|
+
border-radius: 5px;
|
|
37
|
+
color: inherit;
|
|
38
|
+
}
|
|
39
|
+
.sort:hover,
|
|
40
|
+
.filter:hover {
|
|
41
|
+
background: var(--hover);
|
|
42
|
+
color: var(--fg);
|
|
43
|
+
}
|
|
44
|
+
.sort svg,
|
|
45
|
+
.filter svg {
|
|
46
|
+
width: 14px;
|
|
47
|
+
height: 14px;
|
|
48
|
+
}
|
|
49
|
+
.filter[data-active="true"] {
|
|
50
|
+
color: var(--accent-ink, var(--accent));
|
|
51
|
+
background: var(--selected);
|
|
52
|
+
}
|
|
53
|
+
.filterPanel {
|
|
54
|
+
max-height: 300px;
|
|
55
|
+
overflow: auto;
|
|
56
|
+
}
|
|
57
|
+
.selection {
|
|
58
|
+
width: 44px;
|
|
59
|
+
}
|
|
60
|
+
.selection label > span:last-child {
|
|
61
|
+
position: absolute;
|
|
62
|
+
width: 1px;
|
|
63
|
+
height: 1px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
clip-path: inset(50%);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.filterReset {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
margin-top: 6px;
|
|
72
|
+
padding-top: 6px;
|
|
73
|
+
border-top: var(--separator-width) var(--separator-style)
|
|
74
|
+
var(--separator-color);
|
|
75
|
+
}
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
.dialog {
|
|
2
|
-
width: min(var(--dialog-width), calc(100vw - 32px));
|
|
3
|
-
max-height: calc(100dvh - var(--dialog-inset));
|
|
4
|
-
padding: 0;
|
|
5
|
-
color: var(--fg);
|
|
6
|
-
background: var(--surface);
|
|
7
|
-
border: 1px solid var(--line);
|
|
8
|
-
border-radius: calc(var(--radius) + 3px);
|
|
9
|
-
box-shadow: var(--shadow-dialog);
|
|
10
|
-
overflow: auto;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.dialog::backdrop {
|
|
14
|
-
background: var(--overlay);
|
|
15
|
-
backdrop-filter: blur(3px);
|
|
16
|
-
animation: fade-in var(--popup-enter);
|
|
17
|
-
}
|
|
18
|
-
.dialogHeader {
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: flex-start;
|
|
21
|
-
justify-content: space-between;
|
|
22
|
-
gap: 16px;
|
|
23
|
-
padding: 24px 24px 20px;
|
|
24
|
-
}
|
|
25
|
-
.dialogHeading {
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
gap: 14px;
|
|
29
|
-
min-width: 0;
|
|
30
|
-
}
|
|
31
|
-
.dialogHeading h2 {
|
|
32
|
-
min-width: 0;
|
|
33
|
-
overflow-wrap: anywhere;
|
|
34
|
-
font-size: 18px;
|
|
35
|
-
font-weight: 600;
|
|
36
|
-
line-height: 1.5;
|
|
37
|
-
}
|
|
38
|
-
.dialogHeader > button {
|
|
39
|
-
flex-shrink: 0;
|
|
40
|
-
margin-top: -3px;
|
|
41
|
-
margin-right: -6px;
|
|
42
|
-
color: var(--muted);
|
|
43
|
-
}
|
|
44
|
-
.dialogIcon {
|
|
45
|
-
display: inline-flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
flex: 0 0 21px;
|
|
49
|
-
width: 21px;
|
|
50
|
-
height: 25px;
|
|
51
|
-
color: var(--dialog-tone, var(--accent-ink, var(--accent)));
|
|
52
|
-
}
|
|
53
|
-
.dialogIcon > svg {
|
|
54
|
-
width: 21px;
|
|
55
|
-
height: 21px;
|
|
56
|
-
stroke-width: 1.7;
|
|
57
|
-
}
|
|
58
|
-
.dialog[data-tone="info"] {
|
|
59
|
-
--dialog-tone: var(--accent-ink, var(--accent));
|
|
60
|
-
}
|
|
61
|
-
.dialog[data-tone="success"] {
|
|
62
|
-
--dialog-tone: var(--success);
|
|
63
|
-
}
|
|
64
|
-
.dialog[data-tone="warning"] {
|
|
65
|
-
--dialog-tone: var(--warning);
|
|
66
|
-
}
|
|
67
|
-
.dialog[data-tone="danger"] {
|
|
68
|
-
--dialog-tone: var(--danger);
|
|
69
|
-
}
|
|
70
|
-
.dialogBody {
|
|
71
|
-
padding: 0 24px 24px;
|
|
72
|
-
}
|
|
73
|
-
.dialogBody > p {
|
|
74
|
-
color: var(--muted);
|
|
75
|
-
font-size: 12px;
|
|
76
|
-
line-height: 1.8;
|
|
77
|
-
}
|
|
78
|
-
.dialogFooter {
|
|
79
|
-
flex-wrap: wrap;
|
|
80
|
-
display: flex;
|
|
81
|
-
justify-content: flex-end;
|
|
82
|
-
gap: 8px;
|
|
83
|
-
padding: 14px 24px;
|
|
84
|
-
border-top: var(--separator-width) var(--separator-style)
|
|
85
|
-
var(--separator-color);
|
|
86
|
-
background: var(--canvas);
|
|
87
|
-
}
|
|
88
|
-
.wide {
|
|
89
|
-
width: min(var(--dialog-wide-width), calc(100vw - 32px));
|
|
90
|
-
}
|
|
91
|
-
.small {
|
|
92
|
-
width: min(420px, calc(100vw - 32px));
|
|
93
|
-
}
|
|
94
|
-
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeader {
|
|
95
|
-
padding: 22px 24px 12px;
|
|
96
|
-
}
|
|
97
|
-
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeading {
|
|
98
|
-
gap: 10px;
|
|
99
|
-
}
|
|
100
|
-
.dialog:is([data-variant="message"], [data-variant="confirm"])
|
|
101
|
-
.dialogHeader
|
|
102
|
-
h2 {
|
|
103
|
-
font-size: 17px;
|
|
104
|
-
}
|
|
105
|
-
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogBody {
|
|
106
|
-
padding: 0 24px 24px;
|
|
107
|
-
}
|
|
108
|
-
.closing {
|
|
109
|
-
pointer-events: none;
|
|
110
|
-
}
|
|
111
|
-
.dialog.closing::backdrop {
|
|
112
|
-
background: transparent;
|
|
113
|
-
backdrop-filter: blur(0);
|
|
114
|
-
transition:
|
|
115
|
-
background var(--popup-exit),
|
|
116
|
-
backdrop-filter var(--popup-exit);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@media (max-width: 600px) {
|
|
120
|
-
.dialog {
|
|
121
|
-
max-height: calc(100dvh - 24px);
|
|
122
|
-
}
|
|
123
|
-
.dialogBody {
|
|
124
|
-
padding: 0 20px 20px;
|
|
125
|
-
}
|
|
126
|
-
.dialogHeader,
|
|
127
|
-
.dialogFooter {
|
|
128
|
-
padding: 18px 20px;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@keyframes fade-in {
|
|
133
|
-
from {
|
|
134
|
-
opacity: 0;
|
|
135
|
-
}
|
|
136
|
-
to {
|
|
137
|
-
opacity: 1;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
1
|
+
.dialog {
|
|
2
|
+
width: min(var(--dialog-width), calc(100vw - 32px));
|
|
3
|
+
max-height: calc(100dvh - var(--dialog-inset));
|
|
4
|
+
padding: 0;
|
|
5
|
+
color: var(--fg);
|
|
6
|
+
background: var(--surface);
|
|
7
|
+
border: 1px solid var(--line);
|
|
8
|
+
border-radius: calc(var(--radius) + 3px);
|
|
9
|
+
box-shadow: var(--shadow-dialog);
|
|
10
|
+
overflow: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.dialog::backdrop {
|
|
14
|
+
background: var(--overlay);
|
|
15
|
+
backdrop-filter: blur(3px);
|
|
16
|
+
animation: fade-in var(--popup-enter);
|
|
17
|
+
}
|
|
18
|
+
.dialogHeader {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: flex-start;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
gap: 16px;
|
|
23
|
+
padding: 24px 24px 20px;
|
|
24
|
+
}
|
|
25
|
+
.dialogHeading {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 14px;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
}
|
|
31
|
+
.dialogHeading h2 {
|
|
32
|
+
min-width: 0;
|
|
33
|
+
overflow-wrap: anywhere;
|
|
34
|
+
font-size: 18px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
line-height: 1.5;
|
|
37
|
+
}
|
|
38
|
+
.dialogHeader > button {
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
margin-top: -3px;
|
|
41
|
+
margin-right: -6px;
|
|
42
|
+
color: var(--muted);
|
|
43
|
+
}
|
|
44
|
+
.dialogIcon {
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
flex: 0 0 21px;
|
|
49
|
+
width: 21px;
|
|
50
|
+
height: 25px;
|
|
51
|
+
color: var(--dialog-tone, var(--accent-ink, var(--accent)));
|
|
52
|
+
}
|
|
53
|
+
.dialogIcon > svg {
|
|
54
|
+
width: 21px;
|
|
55
|
+
height: 21px;
|
|
56
|
+
stroke-width: 1.7;
|
|
57
|
+
}
|
|
58
|
+
.dialog[data-tone="info"] {
|
|
59
|
+
--dialog-tone: var(--accent-ink, var(--accent));
|
|
60
|
+
}
|
|
61
|
+
.dialog[data-tone="success"] {
|
|
62
|
+
--dialog-tone: var(--success);
|
|
63
|
+
}
|
|
64
|
+
.dialog[data-tone="warning"] {
|
|
65
|
+
--dialog-tone: var(--warning);
|
|
66
|
+
}
|
|
67
|
+
.dialog[data-tone="danger"] {
|
|
68
|
+
--dialog-tone: var(--danger);
|
|
69
|
+
}
|
|
70
|
+
.dialogBody {
|
|
71
|
+
padding: 0 24px 24px;
|
|
72
|
+
}
|
|
73
|
+
.dialogBody > p {
|
|
74
|
+
color: var(--muted);
|
|
75
|
+
font-size: 12px;
|
|
76
|
+
line-height: 1.8;
|
|
77
|
+
}
|
|
78
|
+
.dialogFooter {
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: flex-end;
|
|
82
|
+
gap: 8px;
|
|
83
|
+
padding: 14px 24px;
|
|
84
|
+
border-top: var(--separator-width) var(--separator-style)
|
|
85
|
+
var(--separator-color);
|
|
86
|
+
background: var(--canvas);
|
|
87
|
+
}
|
|
88
|
+
.wide {
|
|
89
|
+
width: min(var(--dialog-wide-width), calc(100vw - 32px));
|
|
90
|
+
}
|
|
91
|
+
.small {
|
|
92
|
+
width: min(420px, calc(100vw - 32px));
|
|
93
|
+
}
|
|
94
|
+
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeader {
|
|
95
|
+
padding: 22px 24px 12px;
|
|
96
|
+
}
|
|
97
|
+
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeading {
|
|
98
|
+
gap: 10px;
|
|
99
|
+
}
|
|
100
|
+
.dialog:is([data-variant="message"], [data-variant="confirm"])
|
|
101
|
+
.dialogHeader
|
|
102
|
+
h2 {
|
|
103
|
+
font-size: 17px;
|
|
104
|
+
}
|
|
105
|
+
.dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogBody {
|
|
106
|
+
padding: 0 24px 24px;
|
|
107
|
+
}
|
|
108
|
+
.closing {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
111
|
+
.dialog.closing::backdrop {
|
|
112
|
+
background: transparent;
|
|
113
|
+
backdrop-filter: blur(0);
|
|
114
|
+
transition:
|
|
115
|
+
background var(--popup-exit),
|
|
116
|
+
backdrop-filter var(--popup-exit);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@media (max-width: 600px) {
|
|
120
|
+
.dialog {
|
|
121
|
+
max-height: calc(100dvh - 24px);
|
|
122
|
+
}
|
|
123
|
+
.dialogBody {
|
|
124
|
+
padding: 0 20px 20px;
|
|
125
|
+
}
|
|
126
|
+
.dialogHeader,
|
|
127
|
+
.dialogFooter {
|
|
128
|
+
padding: 18px 20px;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@keyframes fade-in {
|
|
133
|
+
from {
|
|
134
|
+
opacity: 0;
|
|
135
|
+
}
|
|
136
|
+
to {
|
|
137
|
+
opacity: 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type EditableHeadingProps = {
|
|
2
|
+
value: string;
|
|
3
|
+
onChange(value: string): void;
|
|
4
|
+
label: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
order?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
9
|
+
fz?: number;
|
|
10
|
+
};
|
|
11
|
+
/** A plain-text heading edited directly, without replacing it with a form field. */
|
|
12
|
+
export declare function EditableHeading({ value, onChange, label, placeholder, readOnly, maxLength, order, fz, }: EditableHeadingProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { Heading } from "./Layout.js";
|
|
5
|
+
import s from "./EditableHeading.module.css";
|
|
6
|
+
function EditableHeading({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
label,
|
|
10
|
+
placeholder = "",
|
|
11
|
+
readOnly = false,
|
|
12
|
+
maxLength = 240,
|
|
13
|
+
order = 1,
|
|
14
|
+
fz = 30
|
|
15
|
+
}) {
|
|
16
|
+
const node = useRef(null), initial = useRef(value), before = useRef(value);
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
if (node.current && document.activeElement !== node.current)
|
|
19
|
+
node.current.textContent = value;
|
|
20
|
+
}, [value]);
|
|
21
|
+
const commit = () => {
|
|
22
|
+
const heading = node.current;
|
|
23
|
+
if (!heading) return;
|
|
24
|
+
const next = (heading.textContent || "").replace(/[\r\n]+/g, " ").slice(0, maxLength);
|
|
25
|
+
if (next !== heading.textContent) heading.textContent = next;
|
|
26
|
+
if (next !== value) onChange(next);
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
Heading,
|
|
30
|
+
{
|
|
31
|
+
order,
|
|
32
|
+
fz,
|
|
33
|
+
ref: node,
|
|
34
|
+
className: s.heading,
|
|
35
|
+
contentEditable: readOnly ? false : "plaintext-only",
|
|
36
|
+
suppressContentEditableWarning: true,
|
|
37
|
+
role: readOnly ? void 0 : "textbox",
|
|
38
|
+
"aria-label": label,
|
|
39
|
+
"aria-placeholder": placeholder,
|
|
40
|
+
"aria-multiline": readOnly ? void 0 : false,
|
|
41
|
+
"data-placeholder": placeholder,
|
|
42
|
+
tabIndex: readOnly ? void 0 : 0,
|
|
43
|
+
onFocus: () => {
|
|
44
|
+
before.current = value;
|
|
45
|
+
},
|
|
46
|
+
onInput: (event) => {
|
|
47
|
+
if (!event.nativeEvent.isComposing) commit();
|
|
48
|
+
},
|
|
49
|
+
onCompositionEnd: commit,
|
|
50
|
+
onBlur: commit,
|
|
51
|
+
onBeforeInput: (event) => {
|
|
52
|
+
if (["insertParagraph", "insertLineBreak"].includes(
|
|
53
|
+
event.nativeEvent.inputType
|
|
54
|
+
))
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
},
|
|
57
|
+
onKeyDown: (event) => {
|
|
58
|
+
if (event.nativeEvent.isComposing) return;
|
|
59
|
+
if (event.key === "Enter") {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
event.currentTarget.blur();
|
|
62
|
+
}
|
|
63
|
+
if (event.key === "Escape") {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
event.currentTarget.textContent = before.current;
|
|
66
|
+
onChange(before.current);
|
|
67
|
+
event.currentTarget.blur();
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
children: initial.current
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
EditableHeading
|
|
76
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.heading {
|
|
2
|
+
min-height: 1.4em;
|
|
3
|
+
white-space: pre-wrap;
|
|
4
|
+
overflow-wrap: anywhere;
|
|
5
|
+
cursor: text;
|
|
6
|
+
}
|
|
7
|
+
.heading:empty::before {
|
|
8
|
+
content: attr(data-placeholder);
|
|
9
|
+
color: var(--muted);
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
}
|
|
12
|
+
.heading:focus-visible {
|
|
13
|
+
outline: 2px solid var(--focus, var(--accent));
|
|
14
|
+
outline-offset: 6px;
|
|
15
|
+
border-radius: var(--radius-sm, 4px);
|
|
16
|
+
}
|