oneslash-design-system 2.27.1 → 2.28.1
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/cases/api-keys/list.jsx +30 -3
- package/dist/cases/api-keys.md +35 -3
- package/dist/cases/date-field/calendar.jsx +1 -1
- package/dist/cases/date-field.md +2 -2
- package/dist/cases/members-list/rows.jsx +37 -6
- package/dist/cases/members-list/table.jsx +37 -6
- package/dist/cases/members-list.md +81 -12
- package/dist/cases.json +7 -5
- package/dist/components/modal.d.ts +6 -1
- package/dist/components/modal.jsx +8 -3
- package/dist/components/tooltip.jsx +8 -3
- package/dist/internal/overlayStack.d.ts +1 -0
- package/dist/internal/overlayStack.js +6 -0
- package/dist/stories/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +28 -0
- package/dist/stories/Tooltip.stories.d.ts +1 -0
- package/dist/stories/Tooltip.stories.jsx +17 -0
- package/package.json +3 -1
|
@@ -47,12 +47,23 @@ export default function ApiKeysList() {
|
|
|
47
47
|
// Gives each new key its own id, so no two rows share a key.
|
|
48
48
|
var keyCount = useRef(0);
|
|
49
49
|
var toastIds = useRef([]);
|
|
50
|
+
var createButton = useRef(null);
|
|
51
|
+
var cancelRevoke = useRef(null);
|
|
52
|
+
// Each row's Revoke button by key id, so focus can move to one when the button that had it is gone.
|
|
53
|
+
var revokeButtons = useRef({});
|
|
54
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
55
|
+
var focusNext = useRef();
|
|
50
56
|
// On unmount it stops every request and closes every toast it opened.
|
|
51
57
|
useEffect(function () { return function () {
|
|
52
58
|
timers.current.forEach(clearTimeout);
|
|
53
59
|
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
54
60
|
toastIds.current = [];
|
|
55
61
|
}; }, []);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var move = focusNext.current;
|
|
64
|
+
focusNext.current = undefined;
|
|
65
|
+
move === null || move === void 0 ? void 0 : move();
|
|
66
|
+
});
|
|
56
67
|
// Stands in for the request to the server.
|
|
57
68
|
function later(callback, ms) {
|
|
58
69
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -92,14 +103,30 @@ export default function ApiKeysList() {
|
|
|
92
103
|
setShownKey(madeKey);
|
|
93
104
|
}, 1200);
|
|
94
105
|
}
|
|
106
|
+
// The confirm opens in the row, with focus on 'Cancel'.
|
|
107
|
+
function askToRevoke(key) {
|
|
108
|
+
setConfirming(key.id);
|
|
109
|
+
focusNext.current = function () { var _a; return (_a = cancelRevoke.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
110
|
+
}
|
|
111
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's Revoke button.
|
|
112
|
+
function keepKey(key) {
|
|
113
|
+
setConfirming(null);
|
|
114
|
+
focusNext.current = function () { var _a; return (_a = revokeButtons.current[key.id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
115
|
+
}
|
|
95
116
|
function handleRevoke(key) {
|
|
117
|
+
var _a;
|
|
96
118
|
if (revoking)
|
|
97
119
|
return;
|
|
120
|
+
var at = keys.findIndex(function (k) { return k.id === key.id; });
|
|
121
|
+
var neighbor = (_a = keys[at + 1]) !== null && _a !== void 0 ? _a : keys[at - 1];
|
|
98
122
|
setRevoking(key.id);
|
|
99
123
|
later(function () {
|
|
100
124
|
setRevoking(null);
|
|
101
125
|
setConfirming(null);
|
|
102
126
|
setKeys(function (list) { return list.filter(function (k) { return k.id !== key.id; }); });
|
|
127
|
+
// The row is gone: focus goes to the next row's Revoke, or the one before it when it was the last.
|
|
128
|
+
// With no key left, it goes to 'Create Key'.
|
|
129
|
+
focusNext.current = function () { var _a; return (_a = (neighbor ? revokeButtons.current[neighbor.id] : createButton.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
103
130
|
toastIds.current.push(toast({ type: 'success', message: "".concat(key.name, " key revoked.") }));
|
|
104
131
|
}, 1200);
|
|
105
132
|
}
|
|
@@ -110,7 +137,7 @@ export default function ApiKeysList() {
|
|
|
110
137
|
<Stack gap="small">
|
|
111
138
|
<Cluster justify="between">
|
|
112
139
|
<Heading level={1} size="h5">API keys</Heading>
|
|
113
|
-
<Button size="small" type="primary" state="enabled" label="Create Key" decoIcon="Plus" onClickButton={handleOpen}/>
|
|
140
|
+
<Button ref={createButton} size="small" type="primary" state="enabled" label="Create Key" decoIcon="Plus" onClickButton={handleOpen}/>
|
|
114
141
|
</Cluster>
|
|
115
142
|
<Paragraph tone="secondary" size="body2" measure="none">Keys let a script or a service use Acme as you. The list shows the start of each key, never the whole key.</Paragraph>
|
|
116
143
|
</Stack>
|
|
@@ -137,10 +164,10 @@ export default function ApiKeysList() {
|
|
|
137
164
|
{confirming === k.id ? (<Stack gap="small">
|
|
138
165
|
<Paragraph size="body2" measure="none">Revoke {k.name}?</Paragraph>
|
|
139
166
|
<Cluster gap="small">
|
|
140
|
-
<Button size="small" type="tertiary" state={revoking === k.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking ".concat(k.name)} onClickButton={function () { return
|
|
167
|
+
<Button ref={cancelRevoke} size="small" type="tertiary" state={revoking === k.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking ".concat(k.name)} onClickButton={function () { return keepKey(k); }}/>
|
|
141
168
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke ".concat(k.name)} loading={revoking === k.id} onClickButton={function () { return handleRevoke(k); }}/>
|
|
142
169
|
</Cluster>
|
|
143
|
-
</Stack>) : (<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={"Revoke ".concat(k.name)} onClickButton={function () { return
|
|
170
|
+
</Stack>) : (<Button ref={function (el) { revokeButtons.current[k.id] = el; }} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={"Revoke ".concat(k.name)} onClickButton={function () { return askToRevoke(k); }}/>)}
|
|
144
171
|
</TableCell>
|
|
145
172
|
</TableRow>); })}
|
|
146
173
|
</TableContainer>) : (<EmptyBox size="small" icon="KeyRound" text="No API keys" secondText="Keys you create appear here."/>)}
|
package/dist/cases/api-keys.md
CHANGED
|
@@ -12,6 +12,7 @@ A person makes keys that let a script or a service use the product as them, and
|
|
|
12
12
|
- Give the Modal one Button, 'Done'. Ignore Escape and a click outside while the key shows, so a stray click cannot lose it.
|
|
13
13
|
- Confirm 'Revoke' in the row, as the case 'Delete confirm' does: the row asks 'Revoke CI pipeline?' and shows 'Cancel' and a danger 'Revoke'. Then show a toast: 'CI pipeline key revoked.'
|
|
14
14
|
- Give each row's 'Revoke', and the confirm's 'Cancel' and 'Revoke', an `aria-label` that names the key: 'Revoke CI pipeline' and 'Cancel revoking CI pipeline'.
|
|
15
|
+
- Move focus with the confirm, since the button that had it goes away: to 'Cancel' when the confirm opens, back to the row's 'Revoke' on Cancel, and after a revoke to the next row's 'Revoke', or the one before it on the last row. With no key left, focus goes to 'Create Key'.
|
|
15
16
|
- Show `EmptyBox` with 'No API keys' when the list is empty, as the rule 'An empty list says what will fill it' says.
|
|
16
17
|
- Disable the name field while the key is made, and show `loading` on the Button without changing its label.
|
|
17
18
|
|
|
@@ -58,6 +59,8 @@ const firstKeys: Key[] = [
|
|
|
58
59
|
const madeKey = 'acme_live_4f9kQ27xLmT4vB8cRw1ZdN6yHs3P';
|
|
59
60
|
const prefixLength = 14;
|
|
60
61
|
|
|
62
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
63
|
+
|
|
61
64
|
export default function ApiKeysList() {
|
|
62
65
|
// Opens on the new key, as if the person just chose Create. The list already holds it, without the key.
|
|
63
66
|
const [keys, setKeys] = useState<Key[]>(() => [
|
|
@@ -75,6 +78,12 @@ export default function ApiKeysList() {
|
|
|
75
78
|
// Gives each new key its own id, so no two rows share a key.
|
|
76
79
|
const keyCount = useRef(0);
|
|
77
80
|
const toastIds = useRef<string[]>([]);
|
|
81
|
+
const createButton = useRef<Focusable>(null);
|
|
82
|
+
const cancelRevoke = useRef<Focusable>(null);
|
|
83
|
+
// Each row's Revoke button by key id, so focus can move to one when the button that had it is gone.
|
|
84
|
+
const revokeButtons = useRef<Record<string, Focusable>>({});
|
|
85
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
86
|
+
const focusNext = useRef<() => void>();
|
|
78
87
|
|
|
79
88
|
// On unmount it stops every request and closes every toast it opened.
|
|
80
89
|
useEffect(() => () => {
|
|
@@ -83,6 +92,12 @@ export default function ApiKeysList() {
|
|
|
83
92
|
toastIds.current = [];
|
|
84
93
|
}, []);
|
|
85
94
|
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const move = focusNext.current;
|
|
97
|
+
focusNext.current = undefined;
|
|
98
|
+
move?.();
|
|
99
|
+
});
|
|
100
|
+
|
|
86
101
|
// Stands in for the request to the server.
|
|
87
102
|
function later(callback: () => void, ms: number) {
|
|
88
103
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -125,13 +140,30 @@ export default function ApiKeysList() {
|
|
|
125
140
|
}, 1200);
|
|
126
141
|
}
|
|
127
142
|
|
|
143
|
+
// The confirm opens in the row, with focus on 'Cancel'.
|
|
144
|
+
function askToRevoke(key: Key) {
|
|
145
|
+
setConfirming(key.id);
|
|
146
|
+
focusNext.current = () => cancelRevoke.current?.focus();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's Revoke button.
|
|
150
|
+
function keepKey(key: Key) {
|
|
151
|
+
setConfirming(null);
|
|
152
|
+
focusNext.current = () => revokeButtons.current[key.id]?.focus();
|
|
153
|
+
}
|
|
154
|
+
|
|
128
155
|
function handleRevoke(key: Key) {
|
|
129
156
|
if (revoking) return;
|
|
157
|
+
const at = keys.findIndex((k) => k.id === key.id);
|
|
158
|
+
const neighbor = keys[at + 1] ?? keys[at - 1];
|
|
130
159
|
setRevoking(key.id);
|
|
131
160
|
later(() => {
|
|
132
161
|
setRevoking(null);
|
|
133
162
|
setConfirming(null);
|
|
134
163
|
setKeys((list) => list.filter((k) => k.id !== key.id));
|
|
164
|
+
// The row is gone: focus goes to the next row's Revoke, or the one before it when it was the last.
|
|
165
|
+
// With no key left, it goes to 'Create Key'.
|
|
166
|
+
focusNext.current = () => (neighbor ? revokeButtons.current[neighbor.id] : createButton.current)?.focus();
|
|
135
167
|
toastIds.current.push(toast({ type: 'success', message: `${key.name} key revoked.` }));
|
|
136
168
|
}, 1200);
|
|
137
169
|
}
|
|
@@ -144,7 +176,7 @@ export default function ApiKeysList() {
|
|
|
144
176
|
<Stack gap="small">
|
|
145
177
|
<Cluster justify="between">
|
|
146
178
|
<Heading level={1} size="h5">API keys</Heading>
|
|
147
|
-
<Button size="small" type="primary" state="enabled" label="Create Key" decoIcon="Plus" onClickButton={handleOpen} />
|
|
179
|
+
<Button ref={createButton} size="small" type="primary" state="enabled" label="Create Key" decoIcon="Plus" onClickButton={handleOpen} />
|
|
148
180
|
</Cluster>
|
|
149
181
|
<Paragraph tone="secondary" size="body2" measure="none">Keys let a script or a service use Acme as you. The list shows the start of each key, never the whole key.</Paragraph>
|
|
150
182
|
</Stack>
|
|
@@ -174,12 +206,12 @@ export default function ApiKeysList() {
|
|
|
174
206
|
<Stack gap="small">
|
|
175
207
|
<Paragraph size="body2" measure="none">Revoke {k.name}?</Paragraph>
|
|
176
208
|
<Cluster gap="small">
|
|
177
|
-
<Button size="small" type="tertiary" state={revoking === k.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking ${k.name}`} onClickButton={() =>
|
|
209
|
+
<Button ref={cancelRevoke} size="small" type="tertiary" state={revoking === k.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel revoking ${k.name}`} onClickButton={() => keepKey(k)} />
|
|
178
210
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={`Revoke ${k.name}`} loading={revoking === k.id} onClickButton={() => handleRevoke(k)} />
|
|
179
211
|
</Cluster>
|
|
180
212
|
</Stack>
|
|
181
213
|
) : (
|
|
182
|
-
<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={`Revoke ${k.name}`} onClickButton={() =>
|
|
214
|
+
<Button ref={(el) => { revokeButtons.current[k.id] = el; }} size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={`Revoke ${k.name}`} onClickButton={() => askToRevoke(k)} />
|
|
183
215
|
)}
|
|
184
216
|
</TableCell>
|
|
185
217
|
</TableRow>
|
|
@@ -70,7 +70,7 @@ export default function DateFieldCalendar() {
|
|
|
70
70
|
</FormField>
|
|
71
71
|
{/* Typed as MM/DD/YYYY or picked from the calendar. A day before today says 'Choose Nov 16, 2026 or later.'
|
|
72
72
|
The second argument of onChange tells an empty field (no error) from a date typed wrong. */}
|
|
73
|
-
<DateField id="date-field-expires" label="Expires on" value={expires} onChange={function (day, detail) { setExpires(day); setExpiresError(detail.error); }} min={today} disabled={creating} helperText="MM/DD/YYYY
|
|
73
|
+
<DateField id="date-field-expires" label="Expires on" value={expires} onChange={function (day, detail) { setExpires(day); setExpiresError(detail.error); }} min={today} disabled={creating} helperText="MM/DD/YYYY, or empty for no end date."/>
|
|
74
74
|
<Cluster>
|
|
75
75
|
<Button size="medium" type="primary" state="enabled" label="Create Token" htmlType="submit" loading={creating}/>
|
|
76
76
|
</Cluster>
|
package/dist/cases/date-field.md
CHANGED
|
@@ -9,7 +9,7 @@ A person gives one day, such as when a token expires or their date of birth.
|
|
|
9
9
|
- Pass `min` or `max` as an ISO day when only some days can be chosen. Days outside them cannot be picked in the calendar.
|
|
10
10
|
- Let the field say why a date cannot be used: 'Choose Nov 16, 2026 or later.' for a day before `min`, and 'Choose Dec 31, 2026 or earlier.' for a day after `max`.
|
|
11
11
|
- Let the field say how to fix a date that is not real, such as '02/30/2026': 'Enter a real date as MM/DD/YYYY.' A two-digit year says 'Enter the year in four digits, like 2026.'
|
|
12
|
-
- Name the format in the helper text, and say what an empty field means: 'MM/DD/YYYY
|
|
12
|
+
- Name the format in the helper text, and say what an empty field means: 'MM/DD/YYYY, or empty for no end date.'
|
|
13
13
|
- Pass `calendar={false}` for a date years away, such as a date of birth. Paging a calendar back 30 years takes too long.
|
|
14
14
|
- Read the second argument of `onChange`: `''` with `error: null` is an empty field, and `''` with an error is a date typed wrong. Do not submit while `error` is set. The field already shows why under itself.
|
|
15
15
|
- Treat an empty optional date as no date, such as no end date for a token.
|
|
@@ -130,7 +130,7 @@ export default function DateFieldCalendar() {
|
|
|
130
130
|
onChange={(day, detail) => { setExpires(day); setExpiresError(detail.error); }}
|
|
131
131
|
min={today}
|
|
132
132
|
disabled={creating}
|
|
133
|
-
helperText="MM/DD/YYYY
|
|
133
|
+
helperText="MM/DD/YYYY, or empty for no end date."
|
|
134
134
|
/>
|
|
135
135
|
<Cluster>
|
|
136
136
|
<Button size="medium" type="primary" state="enabled" label="Create Token" htmlType="submit" loading={creating} />
|
|
@@ -85,6 +85,12 @@ export default function MembersListRows() {
|
|
|
85
85
|
var copyTimer = useRef();
|
|
86
86
|
var mounted = useRef(true);
|
|
87
87
|
var toastIds = useRef([]);
|
|
88
|
+
var inviteButton = useRef(null);
|
|
89
|
+
var cancelConfirm = useRef(null);
|
|
90
|
+
// Each row's Remove or Revoke Invite button by row id, so focus can move to one when the button that had it is gone.
|
|
91
|
+
var rowButtons = useRef({});
|
|
92
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
93
|
+
var focusNext = useRef();
|
|
88
94
|
// Gives each new invite its own id, so no two rows share a key.
|
|
89
95
|
var inviteCount = useRef(0);
|
|
90
96
|
// On unmount it stops every request and closes every toast it opened.
|
|
@@ -98,6 +104,11 @@ export default function MembersListRows() {
|
|
|
98
104
|
toastIds.current = [];
|
|
99
105
|
};
|
|
100
106
|
}, []);
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
var move = focusNext.current;
|
|
109
|
+
focusNext.current = undefined;
|
|
110
|
+
move === null || move === void 0 ? void 0 : move();
|
|
111
|
+
});
|
|
101
112
|
// Stands in for the request to the server.
|
|
102
113
|
function later(callback, ms) {
|
|
103
114
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -134,30 +145,50 @@ export default function MembersListRows() {
|
|
|
134
145
|
}
|
|
135
146
|
}, 900);
|
|
136
147
|
}
|
|
137
|
-
// Starting a confirm on one row cancels the confirm on any other.
|
|
148
|
+
// Starting a confirm on one row cancels the confirm on any other. It opens in the row, with focus on 'Cancel'.
|
|
138
149
|
function startConfirm(kind, id) {
|
|
139
150
|
setConfirmingMember(kind === 'member' ? id : null);
|
|
140
151
|
setConfirmingInvite(kind === 'invite' ? id : null);
|
|
152
|
+
focusNext.current = function () { var _a; return (_a = cancelConfirm.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
153
|
+
}
|
|
154
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's button.
|
|
155
|
+
function cancelConfirmOn(id) {
|
|
156
|
+
setConfirmingMember(null);
|
|
157
|
+
setConfirmingInvite(null);
|
|
158
|
+
focusNext.current = function () { var _a; return (_a = rowButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
159
|
+
}
|
|
160
|
+
// The row is gone: focus goes to the next row's button, or the one before it when it was the last.
|
|
161
|
+
// With no such row left, it goes to 'Invite Member'.
|
|
162
|
+
function focusAfterRemoving(ids, id) {
|
|
163
|
+
var _a;
|
|
164
|
+
var at = ids.indexOf(id);
|
|
165
|
+
var neighbor = (_a = ids[at + 1]) !== null && _a !== void 0 ? _a : ids[at - 1];
|
|
166
|
+
focusNext.current = function () { var _a; return (_a = (neighbor ? rowButtons.current[neighbor] : inviteButton.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
141
167
|
}
|
|
142
168
|
function handleRemove(member) {
|
|
143
169
|
if (busyRow)
|
|
144
170
|
return;
|
|
171
|
+
// Only other people's rows have Remove, in the order they show
|
|
172
|
+
var removable = members.filter(function (m) { return m.id !== youId; }).map(function (m) { return m.id; });
|
|
145
173
|
setBusyRow(member.id);
|
|
146
174
|
later(function () {
|
|
147
175
|
setBusyRow(null);
|
|
148
176
|
setConfirmingMember(null);
|
|
149
177
|
setMembers(function (list) { return list.filter(function (m) { return m.id !== member.id; }); });
|
|
178
|
+
focusAfterRemoving(removable, member.id);
|
|
150
179
|
toastIds.current.push(toast({ type: 'success', message: "".concat(member.name, " removed from Acme.") }));
|
|
151
180
|
}, 1200);
|
|
152
181
|
}
|
|
153
182
|
function handleRevokeInvite(invite) {
|
|
154
183
|
if (busyRow)
|
|
155
184
|
return;
|
|
185
|
+
var shown = invites.map(function (i) { return i.id; });
|
|
156
186
|
setBusyRow(invite.id);
|
|
157
187
|
later(function () {
|
|
158
188
|
setBusyRow(null);
|
|
159
189
|
setConfirmingInvite(null);
|
|
160
190
|
setInvites(function (list) { return list.filter(function (i) { return i.id !== invite.id; }); });
|
|
191
|
+
focusAfterRemoving(shown, invite.id);
|
|
161
192
|
toastIds.current.push(toast({ type: 'success', message: "Invite for ".concat(invite.email, " revoked.") }));
|
|
162
193
|
}, 1200);
|
|
163
194
|
}
|
|
@@ -228,7 +259,7 @@ export default function MembersListRows() {
|
|
|
228
259
|
<Stack gap="small">
|
|
229
260
|
<Cluster justify="between">
|
|
230
261
|
<Heading level={1} size="h5">Members</Heading>
|
|
231
|
-
{canManage && <Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember}/>}
|
|
262
|
+
{canManage && <Button ref={inviteButton} size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember}/>}
|
|
232
263
|
</Cluster>
|
|
233
264
|
<Paragraph tone="secondary" size="body2" measure="none">{seatsUsed} of {seatLimit} seats used on the Free plan.</Paragraph>
|
|
234
265
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
@@ -262,9 +293,9 @@ export default function MembersListRows() {
|
|
|
262
293
|
<TableCell width="340px">
|
|
263
294
|
{canManage && !isYou && (confirmingMember === m.id ? (<Cluster gap="small">
|
|
264
295
|
<Paragraph size="body2" measure="none">Remove {m.name}?</Paragraph>
|
|
265
|
-
<Button size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel removing ".concat(m.name)} onClickButton={function () { return
|
|
296
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel removing ".concat(m.name)} onClickButton={function () { return cancelConfirmOn(m.id); }}/>
|
|
266
297
|
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={"Remove ".concat(m.name)} loading={busyRow === m.id} onClickButton={function () { return handleRemove(m); }}/>
|
|
267
|
-
</Cluster>) : (<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={"Remove ".concat(m.name)} onClickButton={function () { return startConfirm('member', m.id); }}/>))}
|
|
298
|
+
</Cluster>) : (<Button ref={function (el) { rowButtons.current[m.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={"Remove ".concat(m.name)} onClickButton={function () { return startConfirm('member', m.id); }}/>))}
|
|
268
299
|
</TableCell>
|
|
269
300
|
</TableRow>);
|
|
270
301
|
})}
|
|
@@ -284,12 +315,12 @@ export default function MembersListRows() {
|
|
|
284
315
|
<TableCell width="340px">
|
|
285
316
|
{confirmingInvite === i.id ? (<Cluster gap="small">
|
|
286
317
|
<Paragraph size="body2" measure="none">Revoke this invite?</Paragraph>
|
|
287
|
-
<Button size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking the invite for ".concat(i.email)} onClickButton={function () { return
|
|
318
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking the invite for ".concat(i.email)} onClickButton={function () { return cancelConfirmOn(i.id); }}/>
|
|
288
319
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke invite for ".concat(i.email)} loading={busyRow === i.id} onClickButton={function () { return handleRevokeInvite(i); }}/>
|
|
289
320
|
</Cluster>) : (<Stack gap="small">
|
|
290
321
|
<Cluster gap="small">
|
|
291
322
|
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label={copiedInvite === i.id ? 'Copied' : 'Copy Link'} aria-label={"".concat(copiedInvite === i.id ? 'Copied' : 'Copy Link', " for ").concat(i.email)} onClickButton={function () { return handleCopy(i); }}/>
|
|
292
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={"Revoke invite for ".concat(i.email)} onClickButton={function () { return startConfirm('invite', i.id); }}/>
|
|
323
|
+
<Button ref={function (el) { rowButtons.current[i.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={"Revoke invite for ".concat(i.email)} onClickButton={function () { return startConfirm('invite', i.id); }}/>
|
|
293
324
|
</Cluster>
|
|
294
325
|
{copyBlocked === i.id && <Paragraph tone="secondary" size="caption" measure="none">Copying is blocked here. Select the link and copy it: {i.link}</Paragraph>}
|
|
295
326
|
</Stack>)}
|
|
@@ -94,6 +94,12 @@ export default function MembersListTable() {
|
|
|
94
94
|
var copyTimer = useRef();
|
|
95
95
|
var mounted = useRef(true);
|
|
96
96
|
var toastIds = useRef([]);
|
|
97
|
+
var inviteButton = useRef(null);
|
|
98
|
+
var cancelConfirm = useRef(null);
|
|
99
|
+
// Each row's Remove or Revoke Invite button by row id, so focus can move to one when the button that had it is gone.
|
|
100
|
+
var rowButtons = useRef({});
|
|
101
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
102
|
+
var focusNext = useRef();
|
|
97
103
|
// Gives each new invite its own id, so no two rows share a key.
|
|
98
104
|
var inviteCount = useRef(0);
|
|
99
105
|
// On unmount it stops every request and closes every toast it opened.
|
|
@@ -107,6 +113,11 @@ export default function MembersListTable() {
|
|
|
107
113
|
toastIds.current = [];
|
|
108
114
|
};
|
|
109
115
|
}, []);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
var move = focusNext.current;
|
|
118
|
+
focusNext.current = undefined;
|
|
119
|
+
move === null || move === void 0 ? void 0 : move();
|
|
120
|
+
});
|
|
110
121
|
// Stands in for the request to the server.
|
|
111
122
|
function later(callback, ms) {
|
|
112
123
|
timers.current.push(setTimeout(callback, ms));
|
|
@@ -158,30 +169,50 @@ export default function MembersListTable() {
|
|
|
158
169
|
}
|
|
159
170
|
}, 900);
|
|
160
171
|
}
|
|
161
|
-
// Starting a confirm on one row cancels the confirm on any other.
|
|
172
|
+
// Starting a confirm on one row cancels the confirm on any other. It opens in the row, with focus on 'Cancel'.
|
|
162
173
|
function startConfirm(kind, id) {
|
|
163
174
|
setConfirmingMember(kind === 'member' ? id : null);
|
|
164
175
|
setConfirmingInvite(kind === 'invite' ? id : null);
|
|
176
|
+
focusNext.current = function () { var _a; return (_a = cancelConfirm.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
177
|
+
}
|
|
178
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's button.
|
|
179
|
+
function cancelConfirmOn(id) {
|
|
180
|
+
setConfirmingMember(null);
|
|
181
|
+
setConfirmingInvite(null);
|
|
182
|
+
focusNext.current = function () { var _a; return (_a = rowButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
183
|
+
}
|
|
184
|
+
// The row is gone: focus goes to the next row's button, or the one before it when it was the last.
|
|
185
|
+
// With no such row left, it goes to 'Invite Member'.
|
|
186
|
+
function focusAfterRemoving(ids, id) {
|
|
187
|
+
var _a;
|
|
188
|
+
var at = ids.indexOf(id);
|
|
189
|
+
var neighbor = (_a = ids[at + 1]) !== null && _a !== void 0 ? _a : ids[at - 1];
|
|
190
|
+
focusNext.current = function () { var _a; return (_a = (neighbor ? rowButtons.current[neighbor] : inviteButton.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
165
191
|
}
|
|
166
192
|
function handleRemove(member) {
|
|
167
193
|
if (busyRow)
|
|
168
194
|
return;
|
|
195
|
+
// Only other people's rows have Remove, in the order they show
|
|
196
|
+
var removable = sorted.filter(function (m) { return m.id !== youId; }).map(function (m) { return m.id; });
|
|
169
197
|
setBusyRow(member.id);
|
|
170
198
|
later(function () {
|
|
171
199
|
setBusyRow(null);
|
|
172
200
|
setConfirmingMember(null);
|
|
173
201
|
setMembers(function (list) { return list.filter(function (m) { return m.id !== member.id; }); });
|
|
202
|
+
focusAfterRemoving(removable, member.id);
|
|
174
203
|
toastIds.current.push(toast({ type: 'success', message: "".concat(member.name, " removed from Acme.") }));
|
|
175
204
|
}, 1200);
|
|
176
205
|
}
|
|
177
206
|
function handleRevokeInvite(invite) {
|
|
178
207
|
if (busyRow)
|
|
179
208
|
return;
|
|
209
|
+
var shown = invites.map(function (i) { return i.id; });
|
|
180
210
|
setBusyRow(invite.id);
|
|
181
211
|
later(function () {
|
|
182
212
|
setBusyRow(null);
|
|
183
213
|
setConfirmingInvite(null);
|
|
184
214
|
setInvites(function (list) { return list.filter(function (i) { return i.id !== invite.id; }); });
|
|
215
|
+
focusAfterRemoving(shown, invite.id);
|
|
185
216
|
toastIds.current.push(toast({ type: 'success', message: "Invite for ".concat(invite.email, " revoked.") }));
|
|
186
217
|
}, 1200);
|
|
187
218
|
}
|
|
@@ -252,7 +283,7 @@ export default function MembersListTable() {
|
|
|
252
283
|
<Stack gap="small">
|
|
253
284
|
<Cluster justify="between">
|
|
254
285
|
<Heading level={1} size="h5">Members</Heading>
|
|
255
|
-
{canManage && <Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember}/>}
|
|
286
|
+
{canManage && <Button ref={inviteButton} size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleInviteMember}/>}
|
|
256
287
|
</Cluster>
|
|
257
288
|
<Paragraph tone="secondary" size="body2" measure="none">{seatsUsed} of {seatLimit} seats used on the Free plan.</Paragraph>
|
|
258
289
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
@@ -293,9 +324,9 @@ export default function MembersListTable() {
|
|
|
293
324
|
<TableCell width="340px">
|
|
294
325
|
{canManage && !isYou && (confirmingMember === m.id ? (<Cluster gap="small">
|
|
295
326
|
<Paragraph size="body2" measure="none">Remove {m.name}?</Paragraph>
|
|
296
|
-
<Button size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel removing ".concat(m.name)} onClickButton={function () { return
|
|
327
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === m.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel removing ".concat(m.name)} onClickButton={function () { return cancelConfirmOn(m.id); }}/>
|
|
297
328
|
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" aria-label={"Remove ".concat(m.name)} loading={busyRow === m.id} onClickButton={function () { return handleRemove(m); }}/>
|
|
298
|
-
</Cluster>) : (<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={"Remove ".concat(m.name)} onClickButton={function () { return startConfirm('member', m.id); }}/>))}
|
|
329
|
+
</Cluster>) : (<Button ref={function (el) { rowButtons.current[m.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Remove" aria-label={"Remove ".concat(m.name)} onClickButton={function () { return startConfirm('member', m.id); }}/>))}
|
|
299
330
|
</TableCell>
|
|
300
331
|
</TableRow>);
|
|
301
332
|
})}
|
|
@@ -315,12 +346,12 @@ export default function MembersListTable() {
|
|
|
315
346
|
<TableCell width="340px">
|
|
316
347
|
{confirmingInvite === i.id ? (<Cluster gap="small">
|
|
317
348
|
<Paragraph size="body2" measure="none">Revoke this invite?</Paragraph>
|
|
318
|
-
<Button size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking the invite for ".concat(i.email)} onClickButton={function () { return
|
|
349
|
+
<Button ref={cancelConfirm} size="small" type="tertiary" state={busyRow === i.id ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel revoking the invite for ".concat(i.email)} onClickButton={function () { return cancelConfirmOn(i.id); }}/>
|
|
319
350
|
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke invite for ".concat(i.email)} loading={busyRow === i.id} onClickButton={function () { return handleRevokeInvite(i); }}/>
|
|
320
351
|
</Cluster>) : (<Stack gap="small">
|
|
321
352
|
<Cluster gap="small">
|
|
322
353
|
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label={copiedInvite === i.id ? 'Copied' : 'Copy Link'} aria-label={"".concat(copiedInvite === i.id ? 'Copied' : 'Copy Link', " for ").concat(i.email)} onClickButton={function () { return handleCopy(i); }}/>
|
|
323
|
-
<Button size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={"Revoke invite for ".concat(i.email)} onClickButton={function () { return startConfirm('invite', i.id); }}/>
|
|
354
|
+
<Button ref={function (el) { rowButtons.current[i.id] = el; }} size="small" type="tertiary" state={busyRow ? 'disabled' : 'enabled'} label="Revoke Invite" aria-label={"Revoke invite for ".concat(i.email)} onClickButton={function () { return startConfirm('invite', i.id); }}/>
|
|
324
355
|
</Cluster>
|
|
325
356
|
{copyBlocked === i.id && <Paragraph tone="secondary" size="caption" measure="none">Copying is blocked here. Select the link and copy it: {i.link}</Paragraph>}
|
|
326
357
|
</Stack>)}
|