oneslash-design-system 2.14.2 → 2.16.0
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/README.md +15 -0
- package/dist/DESIGN.md +138 -1
- package/dist/cases/accept-invite/signed-in.d.ts +1 -0
- package/dist/cases/accept-invite/signed-in.jsx +57 -0
- package/dist/cases/accept-invite/signed-out.d.ts +1 -0
- package/dist/cases/accept-invite/signed-out.jsx +33 -0
- package/dist/cases/accept-invite.md +161 -0
- package/dist/cases/agent-asks-before-risky-action.md +29 -0
- package/dist/cases/agent-cancels-when-unanswered.md +27 -0
- package/dist/cases/agent-refuses-clearly.md +31 -0
- package/dist/cases/agent-says-what-it-is.md +29 -0
- package/dist/cases/agent-shows-progress.md +30 -0
- package/dist/cases/agent-shows-sources.md +26 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
- package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
- package/dist/cases/auth-gate-loading.md +70 -0
- package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
- package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
- package/dist/cases/check-your-email/page.d.ts +1 -0
- package/dist/cases/check-your-email/page.jsx +49 -0
- package/dist/cases/check-your-email.md +184 -0
- package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
- package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
- package/dist/cases/confirm-destructive-action.md +211 -0
- package/dist/cases/confirm-dialogs.md +36 -0
- package/dist/cases/create-modal/quick.d.ts +1 -0
- package/dist/cases/create-modal/quick.jsx +80 -0
- package/dist/cases/create-modal/with-settings.d.ts +1 -0
- package/dist/cases/create-modal/with-settings.jsx +99 -0
- package/dist/cases/create-modal.md +244 -0
- package/dist/cases/device-login/popup.d.ts +1 -0
- package/dist/cases/device-login/popup.jsx +14 -0
- package/dist/cases/device-login/provider-first.d.ts +1 -0
- package/dist/cases/device-login/provider-first.jsx +98 -0
- package/dist/cases/device-login.md +171 -0
- package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
- package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
- package/dist/cases/email-confirmed/page.d.ts +1 -0
- package/dist/cases/email-confirmed/page.jsx +21 -0
- package/dist/cases/email-confirmed.md +151 -0
- package/dist/cases/empty-list/region.d.ts +1 -0
- package/dist/cases/empty-list/region.jsx +13 -0
- package/dist/cases/empty-list/section.d.ts +1 -0
- package/dist/cases/empty-list/section.jsx +17 -0
- package/dist/cases/empty-list.md +77 -0
- package/dist/cases/empty-lists.md +35 -0
- package/dist/cases/empty-not-set-up/action.d.ts +1 -0
- package/dist/cases/empty-not-set-up/action.jsx +16 -0
- package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
- package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
- package/dist/cases/empty-not-set-up.md +88 -0
- package/dist/cases/empty-search/clear-search.d.ts +1 -0
- package/dist/cases/empty-search/clear-search.jsx +29 -0
- package/dist/cases/empty-search.md +77 -0
- package/dist/cases/error-page/full-page.d.ts +1 -0
- package/dist/cases/error-page/full-page.jsx +19 -0
- package/dist/cases/error-page/in-shell.d.ts +1 -0
- package/dist/cases/error-page/in-shell.jsx +39 -0
- package/dist/cases/error-page.md +107 -0
- package/dist/cases/feedback-form/modal.d.ts +1 -0
- package/dist/cases/feedback-form/modal.jsx +89 -0
- package/dist/cases/feedback-form.md +139 -0
- package/dist/cases/forgot-password/in-place.d.ts +1 -0
- package/dist/cases/forgot-password/in-place.jsx +155 -0
- package/dist/cases/forgot-password/own-page.d.ts +1 -0
- package/dist/cases/forgot-password/own-page.jsx +99 -0
- package/dist/cases/forgot-password.md +328 -0
- package/dist/cases/form-errors.md +32 -0
- package/dist/cases/import-checklist/modal.d.ts +1 -0
- package/dist/cases/import-checklist/modal.jsx +125 -0
- package/dist/cases/import-checklist.md +188 -0
- package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
- package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
- package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
- package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
- package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
- package/dist/cases/inline-form-feedback/toast.jsx +66 -0
- package/dist/cases/inline-form-feedback.md +237 -0
- package/dist/cases/invite-member/by-email.d.ts +1 -0
- package/dist/cases/invite-member/by-email.jsx +98 -0
- package/dist/cases/invite-member/by-link.d.ts +1 -0
- package/dist/cases/invite-member/by-link.jsx +122 -0
- package/dist/cases/invite-member.md +321 -0
- package/dist/cases/load-failure/inline.d.ts +1 -0
- package/dist/cases/load-failure/inline.jsx +52 -0
- package/dist/cases/load-failure/region.d.ts +1 -0
- package/dist/cases/load-failure/region.jsx +34 -0
- package/dist/cases/load-failure.md +155 -0
- package/dist/cases/log-out-confirm/modal.d.ts +1 -0
- package/dist/cases/log-out-confirm/modal.jsx +57 -0
- package/dist/cases/log-out-confirm.md +106 -0
- package/dist/cases/login-page/centered.d.ts +1 -0
- package/dist/cases/login-page/centered.jsx +72 -0
- package/dist/cases/login-page/email-only.d.ts +1 -0
- package/dist/cases/login-page/email-only.jsx +59 -0
- package/dist/cases/login-page/provider-first.d.ts +1 -0
- package/dist/cases/login-page/provider-first.jsx +66 -0
- package/dist/cases/login-page/split.d.ts +1 -0
- package/dist/cases/login-page/split.jsx +79 -0
- package/dist/cases/login-page.md +373 -0
- package/dist/cases/not-found-page/full-page.d.ts +1 -0
- package/dist/cases/not-found-page/full-page.jsx +16 -0
- package/dist/cases/not-found-page/in-shell.d.ts +1 -0
- package/dist/cases/not-found-page/in-shell.jsx +36 -0
- package/dist/cases/not-found-page.md +98 -0
- package/dist/cases/oauth-consent/simple.d.ts +1 -0
- package/dist/cases/oauth-consent/simple.jsx +73 -0
- package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
- package/dist/cases/oauth-consent/with-scope.jsx +89 -0
- package/dist/cases/oauth-consent.md +233 -0
- package/dist/cases/rename/inline.d.ts +1 -0
- package/dist/cases/rename/inline.jsx +58 -0
- package/dist/cases/rename/modal.d.ts +1 -0
- package/dist/cases/rename/modal.jsx +70 -0
- package/dist/cases/rename.md +205 -0
- package/dist/cases/route-loading/full-screen.d.ts +1 -0
- package/dist/cases/route-loading/full-screen.jsx +8 -0
- package/dist/cases/route-loading/region.d.ts +1 -0
- package/dist/cases/route-loading/region.jsx +26 -0
- package/dist/cases/route-loading.md +84 -0
- package/dist/cases/set-new-password/form.d.ts +1 -0
- package/dist/cases/set-new-password/form.jsx +130 -0
- package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
- package/dist/cases/set-new-password/invalid-link.jsx +50 -0
- package/dist/cases/set-new-password.md +247 -0
- package/dist/cases/sign-up-page/centered.d.ts +1 -0
- package/dist/cases/sign-up-page/centered.jsx +124 -0
- package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
- package/dist/cases/sign-up-page/provider-first.jsx +124 -0
- package/dist/cases/sign-up-page/split.d.ts +1 -0
- package/dist/cases/sign-up-page/split.jsx +134 -0
- package/dist/cases/sign-up-page.md +478 -0
- package/dist/cases/success-feedback.md +35 -0
- package/dist/cases/type-to-confirm/inline.d.ts +1 -0
- package/dist/cases/type-to-confirm/inline.jsx +69 -0
- package/dist/cases/type-to-confirm/modal.d.ts +1 -0
- package/dist/cases/type-to-confirm/modal.jsx +73 -0
- package/dist/cases/type-to-confirm.md +222 -0
- package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
- package/dist/cases/unsaved-changes-guard.md +239 -0
- package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
- package/dist/cases/upgrade-prompt/inline.jsx +52 -0
- package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
- package/dist/cases/upgrade-prompt/modal.jsx +43 -0
- package/dist/cases/upgrade-prompt.md +174 -0
- package/dist/cases.json +2073 -0
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/brandIcon.d.ts +12 -0
- package/dist/components/brandIcon.jsx +24 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/form.d.ts +11 -0
- package/dist/components/form.jsx +22 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/image.d.ts +14 -0
- package/dist/components/image.jsx +6 -0
- package/dist/components/layout.d.ts +18 -1
- package/dist/components/layout.jsx +16 -0
- package/dist/components/line.d.ts +3 -1
- package/dist/components/line.jsx +8 -1
- package/dist/components/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- package/dist/components/radioGroup.d.ts +2 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- package/dist/components/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +11 -5
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/tooltip.jsx +3 -1
- package/dist/designTokens.d.ts +1 -0
- package/dist/designTokens.js +1 -0
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.js +6 -0
- package/dist/internal/modal.d.ts +2 -0
- package/dist/internal/modal.js +21 -0
- package/dist/internal/toaster.d.ts +19 -0
- package/dist/internal/toaster.js +50 -0
- package/dist/native-mapping.json +23 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- package/dist/stories/BrandIcon.stories.d.ts +9 -0
- package/dist/stories/BrandIcon.stories.jsx +19 -0
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +116 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/Form.stories.d.ts +6 -0
- package/dist/stories/Form.stories.jsx +26 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/Image.stories.d.ts +7 -0
- package/dist/stories/Image.stories.jsx +18 -0
- package/dist/stories/Line.stories.d.ts +1 -0
- package/dist/stories/Line.stories.jsx +12 -0
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- package/dist/stories/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +36 -0
- package/dist/stories/PageComponents.stories.d.ts +2 -0
- package/dist/stories/PageComponents.stories.jsx +15 -1
- package/dist/stories/RadioGroup.stories.d.ts +1 -0
- package/dist/stories/RadioGroup.stories.jsx +14 -0
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -0
- package/dist/stories/TabsContainer.stories.d.ts +1 -0
- package/dist/stories/TabsContainer.stories.jsx +12 -0
- package/dist/stories/TextField.stories.d.ts +2 -0
- package/dist/stories/TextField.stories.jsx +22 -0
- package/dist/stories/Toaster.stories.d.ts +6 -0
- package/dist/stories/Toaster.stories.jsx +29 -0
- package/dist/tailwind-preset-auto.js +2 -1
- package/dist/tailwind-preset.js +2 -1
- package/dist/theme-auto.css +1 -0
- package/dist/theme.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/tokens.json +7 -0
- package/package.json +4 -2
|
@@ -7,6 +7,8 @@ interface AlertProps {
|
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
showCloseButton?: boolean;
|
|
9
9
|
variant?: 'toast' | 'inline';
|
|
10
|
+
/** Not set: the alert dismisses itself after 5 seconds unless it has a close button. `false` keeps it open; `true` dismisses it even with a close button. */
|
|
11
|
+
autoDismiss?: boolean;
|
|
10
12
|
}
|
|
11
|
-
export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, }: AlertProps): React.JSX.Element | null;
|
|
13
|
+
export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
|
|
12
14
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import IconButton from './iconButton';
|
|
4
|
+
import { shouldAutoDismiss } from '../internal/alert';
|
|
4
5
|
var bgClassMap = {
|
|
5
6
|
error: 'bg-error-alertBg',
|
|
6
7
|
warning: 'bg-warning-alertBg',
|
|
@@ -17,7 +18,7 @@ var motionClasses = {
|
|
|
17
18
|
};
|
|
18
19
|
export default function Alert(_a) {
|
|
19
20
|
var _b;
|
|
20
|
-
var _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e;
|
|
21
|
+
var _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss;
|
|
21
22
|
var _f = useState(false), isVisible = _f[0], setIsVisible = _f[1];
|
|
22
23
|
var _g = useState(false), shouldRender = _g[0], setShouldRender = _g[1];
|
|
23
24
|
// Auto-dismiss pauses while the toast is hovered or focused
|
|
@@ -40,9 +41,10 @@ export default function Alert(_a) {
|
|
|
40
41
|
return function () { return clearTimeout(hideTimer_1); };
|
|
41
42
|
}
|
|
42
43
|
}, [open, showCloseButton, shouldRender]);
|
|
43
|
-
//
|
|
44
|
+
// Auto-dismiss unless autoDismiss says otherwise; by default only an alert with no close button
|
|
45
|
+
var autoDismissOn = shouldAutoDismiss({ autoDismiss: autoDismiss, showCloseButton: showCloseButton });
|
|
44
46
|
useEffect(function () {
|
|
45
|
-
if (!open || !shouldRender ||
|
|
47
|
+
if (!open || !shouldRender || !autoDismissOn || isPaused)
|
|
46
48
|
return;
|
|
47
49
|
var startedAt = Date.now();
|
|
48
50
|
var dismissTimer = setTimeout(function () { return handleClose(); }, remainingMs.current);
|
|
@@ -50,7 +52,7 @@ export default function Alert(_a) {
|
|
|
50
52
|
clearTimeout(dismissTimer);
|
|
51
53
|
remainingMs.current -= Date.now() - startedAt;
|
|
52
54
|
};
|
|
53
|
-
}, [open, shouldRender,
|
|
55
|
+
}, [open, shouldRender, autoDismissOn, isPaused]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
54
56
|
var handleClose = function () {
|
|
55
57
|
setIsVisible(false);
|
|
56
58
|
// Wait for animation to complete before unmounting
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type BrandName = 'google' | 'github' | 'apple';
|
|
3
|
+
interface BrandIconProps {
|
|
4
|
+
name: BrandName;
|
|
5
|
+
/** Pixel size. Ignored when `className` sets a size (`w-*`, `h-*`, `size-*`), as a Button does. */
|
|
6
|
+
size?: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Names the mark for assistive tech. Without it the icon is hidden from them. */
|
|
9
|
+
title?: string;
|
|
10
|
+
}
|
|
11
|
+
export default function BrandIcon({ name, size, className, title }: BrandIconProps): React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// A Tailwind class that sets a width or a height, with any variant or `!` in front
|
|
3
|
+
var SIZE_CLASS = /(^|[\s:!])(w|h|size)-/;
|
|
4
|
+
var GITHUB = 'M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12';
|
|
5
|
+
var APPLE = 'M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701';
|
|
6
|
+
var marks = {
|
|
7
|
+
github: <path fill="currentColor" d={GITHUB}/>,
|
|
8
|
+
apple: <path fill="currentColor" d={APPLE}/>,
|
|
9
|
+
google: (<>
|
|
10
|
+
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
|
|
11
|
+
<path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
|
|
12
|
+
<path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
|
|
13
|
+
<path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
|
|
14
|
+
</>),
|
|
15
|
+
};
|
|
16
|
+
// `strokeWidth` and any other prop a Button's icon slot passes is not a prop here, so it never reaches the DOM
|
|
17
|
+
export default function BrandIcon(_a) {
|
|
18
|
+
var name = _a.name, _b = _a.size, size = _b === void 0 ? 16 : _b, className = _a.className, title = _a.title;
|
|
19
|
+
var sizedByClass = !!className && SIZE_CLASS.test(className);
|
|
20
|
+
return (<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" {...(sizedByClass ? {} : { width: size, height: size })} className={className} {...(title ? { role: 'img', 'aria-label': title } : { 'aria-hidden': true })}>
|
|
21
|
+
{title && <title>{title}</title>}
|
|
22
|
+
{marks[name]}
|
|
23
|
+
</svg>);
|
|
24
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type IconSource } from './iconSlot';
|
|
2
3
|
interface EmptyBoxProps {
|
|
3
4
|
text: string;
|
|
4
5
|
secondText?: string;
|
|
5
6
|
size: "small" | "large";
|
|
7
|
+
/** Shown under the text, centered, for the one thing to do next. Wrap more than one Button yourself. */
|
|
8
|
+
action?: React.ReactNode;
|
|
9
|
+
/** Replaces the default icon: a Lucide name, an icon component or an element */
|
|
10
|
+
icon?: IconSource;
|
|
6
11
|
}
|
|
7
|
-
export default function EmptyBox({ text, secondText, size, }: EmptyBoxProps): React.JSX.Element;
|
|
12
|
+
export default function EmptyBox({ text, secondText, size, action, icon, }: EmptyBoxProps): React.JSX.Element;
|
|
8
13
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AlertCircle } from 'lucide-react';
|
|
4
|
+
import IconSlot from './iconSlot';
|
|
4
5
|
export default function EmptyBox(_a) {
|
|
5
|
-
var text = _a.text, secondText = _a.secondText, size = _a.size;
|
|
6
|
+
var text = _a.text, secondText = _a.secondText, size = _a.size, action = _a.action, icon = _a.icon;
|
|
6
7
|
// The icon can be faint; the text needs readable contrast
|
|
7
8
|
var iconColor = 'text-fg-disabled';
|
|
8
9
|
var textColor = 'text-fg-secondary';
|
|
9
10
|
var height = size === 'small' ? 'py-6' : 'h-full';
|
|
10
11
|
var iconSize = 'size-6';
|
|
11
12
|
return (<div className={"flex flex-col space-y-2 justify-center items-center w-full ".concat(height)}>
|
|
12
|
-
<AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>
|
|
13
|
+
{icon ? (<IconSlot icon={icon} className={"".concat(iconSize, " ").concat(iconColor)}/>) : (<AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>)}
|
|
13
14
|
<div className="flex flex-col text-center">
|
|
14
15
|
<p className={"text-body1 ".concat(textColor)}>
|
|
15
16
|
{text}
|
|
@@ -18,5 +19,6 @@ export default function EmptyBox(_a) {
|
|
|
18
19
|
{secondText}
|
|
19
20
|
</p>)}
|
|
20
21
|
</div>
|
|
22
|
+
{action}
|
|
21
23
|
</div>);
|
|
22
24
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Gap } from './layout';
|
|
3
|
+
interface FormProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Called when the form is submitted, from a submit Button or the Enter key. The page does not reload. */
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
gap?: Gap;
|
|
8
|
+
'aria-label'?: string;
|
|
9
|
+
}
|
|
10
|
+
export default function Form({ children, onSubmit, gap, 'aria-label': ariaLabel }: FormProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
var gaps = {
|
|
4
|
+
small: 'gap-small',
|
|
5
|
+
medium: 'gap-medium',
|
|
6
|
+
large: 'gap-large',
|
|
7
|
+
xlarge: 'gap-xlarge',
|
|
8
|
+
xxlarge: 'gap-xxlarge',
|
|
9
|
+
huge: 'gap-huge',
|
|
10
|
+
giant: 'gap-giant',
|
|
11
|
+
};
|
|
12
|
+
// A column of fields that submits as one. Put a Button with `htmlType="submit"` inside it.
|
|
13
|
+
// The browser does not validate; the app shows its own errors.
|
|
14
|
+
export default function Form(_a) {
|
|
15
|
+
var children = _a.children, onSubmit = _a.onSubmit, _b = _a.gap, gap = _b === void 0 ? 'large' : _b, ariaLabel = _a["aria-label"];
|
|
16
|
+
return (<form noValidate aria-label={ariaLabel} className={"flex flex-col ".concat(gaps[gap])} onSubmit={function (event) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
onSubmit();
|
|
19
|
+
}}>
|
|
20
|
+
{children}
|
|
21
|
+
</form>);
|
|
22
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface HeadingProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
/** The element:
|
|
5
|
-
level?: 2 | 3 | 4;
|
|
4
|
+
/** The element: h1 to h4. Pick the one that fits the page's outline, not the size. */
|
|
5
|
+
level?: 1 | 2 | 3 | 4;
|
|
6
6
|
/** How large it is set. */
|
|
7
7
|
size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
|
|
8
8
|
id?: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ImageProps {
|
|
3
|
+
src: string;
|
|
4
|
+
/** Required. Use "" for an image that only decorates. */
|
|
5
|
+
alt: string;
|
|
6
|
+
/** Pixel size of the file. Set both so the browser keeps the space before the image loads. */
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
/** How the image fills its box. Not set, the browser default applies. Inside a `Figure` with `crop`, the figure fills the frame and `fit` has no effect. */
|
|
10
|
+
fit?: 'cover' | 'contain';
|
|
11
|
+
loading?: 'lazy' | 'eager';
|
|
12
|
+
}
|
|
13
|
+
export default function Image({ src, alt, width, height, fit, loading }: ImageProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var fits = { cover: 'object-cover', contain: 'object-contain' };
|
|
3
|
+
export default function Image(_a) {
|
|
4
|
+
var src = _a.src, alt = _a.alt, width = _a.width, height = _a.height, fit = _a.fit, loading = _a.loading;
|
|
5
|
+
return <img src={src} alt={alt} width={width} height={height} loading={loading} className={fit ? fits[fit] : undefined}/>;
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type Gap = 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'huge' | 'giant';
|
|
2
|
+
export type Gap = 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'huge' | 'giant';
|
|
3
3
|
interface LayoutProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
gap?: Gap;
|
|
@@ -20,4 +20,21 @@ interface GridProps extends LayoutProps {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function Grid({ children, columns, compact, align, gap, className }: GridProps): React.JSX.Element;
|
|
22
22
|
export declare function PageSection({ children, gap, className }: LayoutProps): React.JSX.Element;
|
|
23
|
+
interface CenterProps {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
/** `form` is a narrow column, `page` the width of a page. */
|
|
26
|
+
width?: 'form' | 'page';
|
|
27
|
+
/** Take at least the window height and center the column vertically too. */
|
|
28
|
+
fill?: boolean;
|
|
29
|
+
gap?: Gap;
|
|
30
|
+
}
|
|
31
|
+
export declare function Center({ children, width, fill, gap }: CenterProps): React.JSX.Element;
|
|
32
|
+
interface SplitProps {
|
|
33
|
+
/** The first half, on a panel. It is not shown below the medium breakpoint. */
|
|
34
|
+
aside: React.ReactNode;
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
/** Take at least the window height. */
|
|
37
|
+
fill?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function Split({ aside, children, fill }: SplitProps): React.JSX.Element;
|
|
23
40
|
export {};
|
|
@@ -41,3 +41,19 @@ export function PageSection(_a) {
|
|
|
41
41
|
var children = _a.children, _b = _a.gap, gap = _b === void 0 ? 'huge' : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
42
42
|
return <section className={"flex flex-col ".concat(gaps[gap], " ").concat(className)}>{children}</section>;
|
|
43
43
|
}
|
|
44
|
+
// A column centered in the window. For a page that is one narrow thing, such as a form.
|
|
45
|
+
export function Center(_a) {
|
|
46
|
+
var children = _a.children, _b = _a.width, width = _b === void 0 ? 'form' : _b, _c = _a.fill, fill = _c === void 0 ? false : _c, _d = _a.gap, gap = _d === void 0 ? 'xlarge' : _d;
|
|
47
|
+
return (<div className={"mx-auto flex w-full flex-col px-xlarge ".concat(width === 'page' ? 'max-w-page' : 'max-w-form', " ").concat(fill ? 'min-h-screen justify-center' : '', " ").concat(gaps[gap])}>
|
|
48
|
+
{children}
|
|
49
|
+
</div>);
|
|
50
|
+
}
|
|
51
|
+
// A page of two equal halves from the medium breakpoint up. Below it, only the children.
|
|
52
|
+
// Put a `<Center fill>` in the second half to center a form in it.
|
|
53
|
+
export function Split(_a) {
|
|
54
|
+
var aside = _a.aside, children = _a.children, _b = _a.fill, fill = _b === void 0 ? false : _b;
|
|
55
|
+
return (<div className={"grid grid-cols-1 md:grid-cols-2 ".concat(fill ? 'min-h-screen' : '')}>
|
|
56
|
+
<div className="hidden md:flex items-center justify-center bg-background-panel p-xxlarge">{aside}</div>
|
|
57
|
+
<div>{children}</div>
|
|
58
|
+
</div>);
|
|
59
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface LineProps {
|
|
3
|
+
/** A short word between two lines, such as "or". Horizontal only; ignored when vertical. */
|
|
4
|
+
label?: string;
|
|
3
5
|
direction?: 'horizontal' | 'vertical';
|
|
4
6
|
className?: string;
|
|
5
7
|
}
|
|
6
|
-
export default function Line({ direction, className, }: LineProps): React.JSX.Element;
|
|
8
|
+
export default function Line({ label, direction, className, }: LineProps): React.JSX.Element;
|
|
7
9
|
export {};
|
package/dist/components/line.jsx
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export default function Line(_a) {
|
|
4
|
-
var _b = _a.direction, direction = _b === void 0 ? 'horizontal' : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
4
|
+
var label = _a.label, _b = _a.direction, direction = _b === void 0 ? 'horizontal' : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
5
5
|
var baseClasses = 'bg-misc-divider';
|
|
6
6
|
if (direction === 'vertical') {
|
|
7
7
|
return (<div className={"".concat(baseClasses, " w-px h-full ").concat(className)}/>);
|
|
8
8
|
}
|
|
9
|
+
if (label) {
|
|
10
|
+
return (<div className={"flex items-center gap-medium w-full ".concat(className)}>
|
|
11
|
+
<div className={"".concat(baseClasses, " h-px flex-1")}/>
|
|
12
|
+
<span className="text-caption text-fg-secondary">{label}</span>
|
|
13
|
+
<div className={"".concat(baseClasses, " h-px flex-1")}/>
|
|
14
|
+
</div>);
|
|
15
|
+
}
|
|
9
16
|
return (<div className={"".concat(baseClasses, " h-px w-full ").concat(className)}/>);
|
|
10
17
|
}
|
|
@@ -2,6 +2,10 @@ import React from 'react';
|
|
|
2
2
|
interface LoadingSmallProps {
|
|
3
3
|
size?: 'large' | 'medium' | 'small' | 'tiny';
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
interface LoadingScreenProps {
|
|
6
|
+
/** One line of text centered under the spinner. It is also the status element's accessible name, in place of "Loading". */
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
export default function LoadingScreen({ label }?: LoadingScreenProps): React.JSX.Element;
|
|
6
10
|
export declare function LoadingSmall({ size }: LoadingSmallProps): React.JSX.Element;
|
|
7
11
|
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export default function LoadingScreen() {
|
|
4
|
-
|
|
3
|
+
export default function LoadingScreen(_a) {
|
|
4
|
+
var _b = _a === void 0 ? {} : _a, label = _b.label;
|
|
5
|
+
return (<div role="status" aria-label={label !== null && label !== void 0 ? label : 'Loading'} className={"flex ".concat(label ? 'flex-col ' : '', "justify-center items-center ").concat(label ? 'gap-1 ' : '', "h-full w-full min-h-[200px]")}>
|
|
5
6
|
<div className="w-12 h-12 rounded-full border-4 border-current border-t-transparent text-fg-primary animate-spin"></div>
|
|
7
|
+
{label && <p className="text-body2 text-fg-secondary text-center">{label}</p>}
|
|
6
8
|
</div>);
|
|
7
9
|
}
|
|
8
10
|
;
|
|
@@ -7,6 +7,7 @@ interface ModalProps {
|
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
actions?: React.ReactNode;
|
|
9
9
|
size?: 'small' | 'medium' | 'large';
|
|
10
|
+
initialFocus?: 'first' | 'body';
|
|
10
11
|
}
|
|
11
|
-
export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, }: ModalProps): React.JSX.Element | null;
|
|
12
|
+
export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, initialFocus, }: ModalProps): React.JSX.Element | null;
|
|
12
13
|
export {};
|
|
@@ -2,26 +2,38 @@
|
|
|
2
2
|
import React, { useEffect, useId, useRef } from 'react';
|
|
3
3
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
4
4
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
5
|
+
import { initialFocusCandidates } from '../internal/modal';
|
|
5
6
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
7
|
+
// For the first focus and the Tab trap: the same, minus a hidden input, which matches but cannot take focus
|
|
8
|
+
var PICKABLE = FOCUSABLE.replace('input:not([disabled])', 'input:not([disabled]):not([type="hidden"])');
|
|
6
9
|
export default function Modal(_a) {
|
|
7
|
-
var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
10
|
+
var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.initialFocus, initialFocus = _c === void 0 ? 'first' : _c;
|
|
8
11
|
var panelRef = useRef(null);
|
|
12
|
+
var bodyRef = useRef(null);
|
|
9
13
|
var titleId = useId();
|
|
10
|
-
var
|
|
14
|
+
var _d = useOverlayTransition(isOpen), mounted = _d.mounted, visible = _d.visible;
|
|
11
15
|
// Keep onClose in a ref so a new function each render doesn't re-run the focus effect
|
|
12
16
|
var onCloseRef = useRef(onClose);
|
|
13
17
|
onCloseRef.current = onClose;
|
|
14
18
|
// Move focus into the panel, trap Tab inside it, close on Escape,
|
|
15
19
|
// lock page scroll, and give focus back to the trigger on close
|
|
16
20
|
useEffect(function () {
|
|
17
|
-
var _a;
|
|
21
|
+
var _a, _b, _c;
|
|
18
22
|
// Wait for the panel to mount before moving focus into it
|
|
19
23
|
if (!isOpen || !mounted)
|
|
20
24
|
return;
|
|
21
25
|
var previouslyFocused = document.activeElement;
|
|
22
26
|
var panel = panelRef.current;
|
|
23
|
-
var
|
|
24
|
-
|
|
27
|
+
var candidates = initialFocusCandidates(Array.from((_a = panel === null || panel === void 0 ? void 0 : panel.querySelectorAll(PICKABLE)) !== null && _a !== void 0 ? _a : []), Array.from((_c = (_b = bodyRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(PICKABLE)) !== null && _c !== void 0 ? _c : []), initialFocus);
|
|
28
|
+
// An element that is hidden or display:none ignores focus(); try the next one
|
|
29
|
+
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
30
|
+
var candidate = candidates_1[_i];
|
|
31
|
+
candidate.focus();
|
|
32
|
+
if (panel === null || panel === void 0 ? void 0 : panel.contains(document.activeElement))
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (panel && !panel.contains(document.activeElement))
|
|
36
|
+
panel.focus();
|
|
25
37
|
var previousOverflow = document.body.style.overflow;
|
|
26
38
|
document.body.style.overflow = 'hidden';
|
|
27
39
|
var handleKeyDown = function (e) {
|
|
@@ -31,7 +43,7 @@ export default function Modal(_a) {
|
|
|
31
43
|
}
|
|
32
44
|
if (e.key !== 'Tab' || !panel)
|
|
33
45
|
return;
|
|
34
|
-
var focusable = Array.from(panel.querySelectorAll(
|
|
46
|
+
var focusable = Array.from(panel.querySelectorAll(PICKABLE));
|
|
35
47
|
if (focusable.length === 0) {
|
|
36
48
|
e.preventDefault();
|
|
37
49
|
return;
|
|
@@ -61,7 +73,7 @@ export default function Modal(_a) {
|
|
|
61
73
|
medium: { width: 'w-[600px]', maxWidth: '600px' },
|
|
62
74
|
large: { width: 'w-[1024px]', maxWidth: '1024px' },
|
|
63
75
|
};
|
|
64
|
-
var
|
|
76
|
+
var _e = sizeConfig[size], modalWidth = _e.width, maxWidth = _e.maxWidth;
|
|
65
77
|
// close modal by clicking elsewhere
|
|
66
78
|
var handleOverlayClick = function (e) {
|
|
67
79
|
if (e.target === e.currentTarget) {
|
|
@@ -92,7 +104,7 @@ export default function Modal(_a) {
|
|
|
92
104
|
</div>)}
|
|
93
105
|
</div>)}
|
|
94
106
|
|
|
95
|
-
<div className="text-body1 space-y-4 text-fg-primary p-6" style={{
|
|
107
|
+
<div ref={bodyRef} className="text-body1 space-y-4 text-fg-primary p-6" style={{
|
|
96
108
|
overflowY: 'auto',
|
|
97
109
|
flexGrow: 1,
|
|
98
110
|
minHeight: 0,
|
|
@@ -9,6 +9,7 @@ interface RadioGroupProps {
|
|
|
9
9
|
selectedValue: string;
|
|
10
10
|
onChange: (value: string) => void;
|
|
11
11
|
direction?: 'horizontal' | 'vertical';
|
|
12
|
+
'aria-label'?: string;
|
|
12
13
|
}
|
|
13
|
-
export default function RadioGroup({ options, selectedValue, onChange, direction, }: RadioGroupProps): React.JSX.Element;
|
|
14
|
+
export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, }: RadioGroupProps): React.JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import React, { useId } from 'react';
|
|
3
3
|
import { popTransition, stateTransition } from './sharedStyles';
|
|
4
4
|
export default function RadioGroup(_a) {
|
|
5
|
-
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b;
|
|
5
|
+
var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, ariaLabel = _a["aria-label"];
|
|
6
6
|
// One shared name gives native arrow-key movement between the options
|
|
7
7
|
var groupName = useId();
|
|
8
|
-
return (<div role="radiogroup" className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
8
|
+
return (<div role="radiogroup" aria-label={ariaLabel} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
|
|
9
9
|
{options.map(function (option) {
|
|
10
10
|
var isSelected = selectedValue === option.value;
|
|
11
11
|
return (<label key={option.value} className="group relative flex items-start cursor-pointer">
|
|
@@ -14,6 +14,7 @@ interface SelectProps {
|
|
|
14
14
|
width?: number | string;
|
|
15
15
|
multiple?: boolean;
|
|
16
16
|
className?: string;
|
|
17
|
+
'aria-label'?: string;
|
|
17
18
|
}
|
|
18
|
-
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, }: SelectProps): React.JSX.Element;
|
|
19
|
+
export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, 'aria-label': ariaLabel, }: SelectProps): React.JSX.Element;
|
|
19
20
|
export { Select };
|
|
@@ -42,7 +42,7 @@ var popperOptions = {
|
|
|
42
42
|
};
|
|
43
43
|
export default function Select(_a) {
|
|
44
44
|
var _b, _c;
|
|
45
|
-
var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g;
|
|
45
|
+
var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g, ariaLabel = _a["aria-label"];
|
|
46
46
|
var _h = useState(false), isOpen = _h[0], setIsOpen = _h[1];
|
|
47
47
|
// Option highlighted by the keyboard; focus itself stays on the trigger
|
|
48
48
|
var _j = useState(-1), activeIndex = _j[0], setActiveIndex = _j[1];
|
|
@@ -153,6 +153,8 @@ export default function Select(_a) {
|
|
|
153
153
|
break;
|
|
154
154
|
case 'Escape':
|
|
155
155
|
e.preventDefault();
|
|
156
|
+
// Close only the list: keep this Escape from reaching a Modal's window listener
|
|
157
|
+
e.stopPropagation();
|
|
156
158
|
closeMenu();
|
|
157
159
|
break;
|
|
158
160
|
case 'Tab':
|
|
@@ -208,7 +210,7 @@ export default function Select(_a) {
|
|
|
208
210
|
};
|
|
209
211
|
return (<div className={"relative ".concat(className)} style={{ width: width || '100%' }}>
|
|
210
212
|
{/* Select Button */}
|
|
211
|
-
<div ref={setTrigger} role="combobox" aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
213
|
+
<div ref={setTrigger} role="combobox" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
|
|
212
214
|
{/* Inner Content Container; 7px vertical padding makes the control 40px like Button and TextField */}
|
|
213
215
|
<div className={"flex items-center justify-between px-2 py-[7px] ".concat(getTextColor())}>
|
|
214
216
|
{/* Content Container */}
|
package/dist/components/tab.jsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import IconSlot from './iconSlot';
|
|
4
|
-
import { TabsContainerContext } from './tabsContainer';
|
|
4
|
+
import { TabsContainerContext, TabsFillContext } from './tabsContainer';
|
|
5
5
|
import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
6
6
|
export default function Tab(_a) {
|
|
7
7
|
var label = _a.label, secondLabel = _a.secondLabel, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, router = _a.router, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
|
|
8
8
|
var inContainer = useContext(TabsContainerContext);
|
|
9
|
+
var fill = useContext(TabsFillContext);
|
|
9
10
|
var handleClick = function () {
|
|
10
11
|
onClickTab();
|
|
11
12
|
if (href && router) {
|
|
@@ -28,7 +29,7 @@ export default function Tab(_a) {
|
|
|
28
29
|
e.preventDefault();
|
|
29
30
|
handleClick();
|
|
30
31
|
}
|
|
31
|
-
}} className={"\n relative flex items-center space-x-1 rounded-control cursor-pointer justify-start ".concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(sizeClasses.tab, "\n ").concat(isSelected
|
|
32
|
+
}} className={"\n relative flex items-center space-x-1 rounded-control cursor-pointer ".concat(fill ? 'flex-1 justify-center' : 'justify-start', " ").concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(sizeClasses.tab, "\n ").concat(isSelected
|
|
32
33
|
? selectedClasses
|
|
33
34
|
: 'text-fg-primary hover:bg-background-accent200', "\n ")} onClick={handleClick}>
|
|
34
35
|
<IconSlot icon={decoIcon} className={sizeClasses.icon}/>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface TabsContainerProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
+
/** The container is as wide as its parent and every tab takes an equal share, label centered. */
|
|
5
|
+
fill?: boolean;
|
|
4
6
|
}
|
|
5
7
|
export declare const TabsContainerContext: React.Context<boolean>;
|
|
6
|
-
export
|
|
8
|
+
export declare const TabsFillContext: React.Context<boolean>;
|
|
9
|
+
export default function TabsContainer({ children, fill, }: TabsContainerProps): React.JSX.Element;
|
|
7
10
|
export {};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, { createContext, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { createContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
// useLayoutEffect warns on a server render, where it cannot run; useEffect is the same there and silent
|
|
4
|
+
var useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
3
5
|
// Lets a Tab know a container draws its selected background (the sliding pill)
|
|
4
6
|
export var TabsContainerContext = createContext(false);
|
|
7
|
+
// Lets a Tab know every tab in the container takes an equal share of the width
|
|
8
|
+
export var TabsFillContext = createContext(false);
|
|
5
9
|
export default function TabsContainer(_a) {
|
|
6
|
-
var children = _a.children;
|
|
10
|
+
var children = _a.children, _b = _a.fill, fill = _b === void 0 ? false : _b;
|
|
7
11
|
var tabCount = React.Children.count(children);
|
|
8
12
|
var containerRef = useRef(null);
|
|
9
13
|
var selectedRef = useRef(null);
|
|
10
|
-
var
|
|
11
|
-
|
|
14
|
+
var _c = useState(null), indicator = _c[0], setIndicator = _c[1];
|
|
15
|
+
useIsomorphicLayoutEffect(function () {
|
|
12
16
|
var _a;
|
|
13
17
|
var container = containerRef.current;
|
|
14
18
|
if (!container)
|
|
@@ -59,6 +63,7 @@ export default function TabsContainer(_a) {
|
|
|
59
63
|
};
|
|
60
64
|
}, [children]);
|
|
61
65
|
return (<TabsContainerContext.Provider value={true}>
|
|
66
|
+
<TabsFillContext.Provider value={fill}>
|
|
62
67
|
<div ref={containerRef} role="tablist" onKeyDown={function (e) {
|
|
63
68
|
var _a, _b;
|
|
64
69
|
// Arrow keys move focus to the next tab and select it
|
|
@@ -77,7 +82,7 @@ export default function TabsContainer(_a) {
|
|
|
77
82
|
e.preventDefault();
|
|
78
83
|
tabs[next].focus();
|
|
79
84
|
tabs[next].click();
|
|
80
|
-
}} className={"\n relative flex gap-0.5 p-1 rounded-container overflow-x-auto\n ".concat(tabCount > 0 ? 'bg-background-accent100' : 'bg-transparent', "\n ")} style={{
|
|
85
|
+
}} className={"\n relative flex gap-0.5 p-1 rounded-container overflow-x-auto".concat(fill ? ' w-full' : '', "\n ").concat(tabCount > 0 ? 'bg-background-accent100' : 'bg-transparent', "\n ")} style={{
|
|
81
86
|
scrollbarWidth: 'none',
|
|
82
87
|
msOverflowStyle: 'none',
|
|
83
88
|
}}>
|
|
@@ -90,5 +95,6 @@ export default function TabsContainer(_a) {
|
|
|
90
95
|
}}/>)}
|
|
91
96
|
{children}
|
|
92
97
|
</div>
|
|
98
|
+
</TabsFillContext.Provider>
|
|
93
99
|
</TabsContainerContext.Provider>);
|
|
94
100
|
}
|
|
@@ -13,9 +13,13 @@ interface TextFieldProps {
|
|
|
13
13
|
multiline?: boolean;
|
|
14
14
|
maxRows?: number;
|
|
15
15
|
disabled?: boolean;
|
|
16
|
+
/** Passed to the `<input>` or `<textarea>`: the text can be focused and selected but not changed. Keeps the normal colors, unlike `disabled`. `required` has no effect on a read-only field. */
|
|
17
|
+
readOnly?: boolean;
|
|
16
18
|
error?: boolean;
|
|
17
19
|
/** Message shown under the field when `error` is true */
|
|
18
20
|
errorText?: string;
|
|
21
|
+
/** A caption under the field. Tied to the field with `aria-describedby`. While `error` is true the error text replaces it, so the error text should restate the rule. */
|
|
22
|
+
helperText?: string;
|
|
19
23
|
required?: boolean;
|
|
20
24
|
size?: 'large' | 'medium' | 'small' | 'tiny';
|
|
21
25
|
placeholder?: string;
|
|
@@ -30,5 +34,5 @@ interface TextFieldProps {
|
|
|
30
34
|
/** Passed to the `<input>` or `<textarea>`. Left to the browser's default when not set. */
|
|
31
35
|
spellCheck?: boolean;
|
|
32
36
|
}
|
|
33
|
-
export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, error, errorText, required, size, placeholder, name, autoComplete, tabIndex, maxLength, minLength, spellCheck, }: TextFieldProps): React.JSX.Element;
|
|
37
|
+
export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, readOnly, error, errorText, helperText, required, size, placeholder, name, autoComplete, tabIndex, maxLength, minLength, spellCheck, }: TextFieldProps): React.JSX.Element;
|
|
34
38
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { stateTransition } from './sharedStyles';
|
|
4
4
|
export default function TextField(_a) {
|
|
5
|
-
var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.
|
|
5
|
+
var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.errorText, errorText = _j === void 0 ? 'This field is required' : _j, helperText = _a.helperText, _k = _a.required, required = _k === void 0 ? false : _k, _l = _a.size, size = _l === void 0 ? 'medium' : _l, placeholder = _a.placeholder, name = _a.name, _m = _a.autoComplete, autoComplete = _m === void 0 ? 'off' : _m, tabIndex = _a.tabIndex, maxLength = _a.maxLength, minLength = _a.minLength, spellCheck = _a.spellCheck;
|
|
6
6
|
var handleKeyDown = function (e) {
|
|
7
7
|
// Ctrl+Enter or Cmd+Enter to submit
|
|
8
8
|
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter' && onSubmit) {
|
|
@@ -35,6 +35,7 @@ export default function TextField(_a) {
|
|
|
35
35
|
return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-fg-primary";
|
|
36
36
|
};
|
|
37
37
|
var errorId = "".concat(id, "-error");
|
|
38
|
+
var helperId = "".concat(id, "-helper");
|
|
38
39
|
// Get inputMode for mobile keyboard optimization
|
|
39
40
|
var getInputMode = function () {
|
|
40
41
|
switch (type) {
|
|
@@ -55,17 +56,20 @@ export default function TextField(_a) {
|
|
|
55
56
|
var containerClasses = "\n ".concat(colorClasses, "\n ").concat(baseClasses, "\n ").concat(sizeClasses, "\n ").concat(getBorderColor(), "\n ");
|
|
56
57
|
var errorProps = {
|
|
57
58
|
'aria-invalid': error || undefined,
|
|
58
|
-
'aria-describedby': error ? errorId : undefined,
|
|
59
|
+
'aria-describedby': error ? errorId : helperText ? helperId : undefined,
|
|
59
60
|
};
|
|
60
61
|
return (<div className="flex flex-col w-full">
|
|
61
62
|
{label && (<label htmlFor={id} className="mb-1 text-body2 text-fg-secondary">
|
|
62
63
|
{label}{required && <span className="text-error-text ml-0.5">*</span>}
|
|
63
64
|
</label>)}
|
|
64
65
|
<div className="relative">
|
|
65
|
-
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
|
|
66
|
+
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
|
|
66
67
|
</div>
|
|
67
68
|
{error && (<p id={errorId} className="mt-1 text-error-text text-body2">
|
|
68
69
|
{errorText}
|
|
69
70
|
</p>)}
|
|
71
|
+
{!error && helperText && (<p id={helperId} className="mt-1 text-fg-secondary text-body2">
|
|
72
|
+
{helperText}
|
|
73
|
+
</p>)}
|
|
70
74
|
</div>);
|
|
71
75
|
}
|