@korzun/design 0.0.6 → 0.1.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/AGENTS.md +5 -1
- package/dist/component/tag/index.d.ts +1 -1
- package/dist/component/tag/index.d.ts.map +1 -1
- package/dist/component/tag/index.js.map +1 -1
- package/dist/component/tag/style.d.ts +1 -1
- package/dist/component/tag/style.d.ts.map +1 -1
- package/dist/control/index.d.ts +1 -1
- package/dist/control/index.d.ts.map +1 -1
- package/dist/control/index.js +1 -1
- package/dist/control/index.js.map +1 -1
- package/dist/control/popover/index.d.ts +24 -8
- package/dist/control/popover/index.d.ts.map +1 -1
- package/dist/control/popover/index.js +60 -15
- package/dist/control/popover/index.js.map +1 -1
- package/dist/control/popover/position.d.ts +47 -0
- package/dist/control/popover/position.d.ts.map +1 -0
- package/dist/control/popover/position.js +29 -0
- package/dist/control/popover/position.js.map +1 -0
- package/dist/theme/theme.d.ts +24 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +36 -0
- package/dist/theme/theme.js.map +1 -1
- package/docs/component/metadata-list.md +1 -1
- package/docs/component/tag.md +26 -6
- package/docs/control/popover.md +41 -10
- package/docs/theme.md +4 -2
- package/docs/tokens.md +3 -3
- package/package.json +1 -1
- package/src/component/tag/index.tsx +1 -1
- package/src/control/index.ts +6 -1
- package/src/control/popover/index.tsx +77 -19
- package/src/control/popover/position.ts +66 -0
- package/src/theme/theme.ts +45 -0
package/AGENTS.md
CHANGED
|
@@ -44,7 +44,11 @@ Every component exports its props type as `<Name>Props` (`ButtonProps`,
|
|
|
44
44
|
sibling `style.ts`. Colours, spacing, font sizes, radii, shadows, and z-index
|
|
45
45
|
all come from `theme.*`; use `applyTransparency(token, alpha)` for tints. No
|
|
46
46
|
literal hex, px, or rem values, no inline `style={{…}}` with literals, and no
|
|
47
|
-
other CSS-in-JS or Tailwind. See [theme](docs/theme.md).
|
|
47
|
+
other CSS-in-JS or Tailwind. See [theme](docs/theme.md). **Tags that report
|
|
48
|
+
state use a status tone**; label tones (`subject`, `author`, …) name
|
|
49
|
+
things. `status` is a legacy label tone despite its name; for a state use
|
|
50
|
+
`success`/`warning`/`danger`/`info`, or `neutral` when it carries no
|
|
51
|
+
meaning.
|
|
48
52
|
2. **Corners follow depth.** On the page background use `lg`. Inside a card or
|
|
49
53
|
modal use `md`. Inside one of those use `sm`. A flush child takes its
|
|
50
54
|
parent's radius. Popovers, menus, and toasts use `md`, and their items `sm`.
|
|
@@ -7,7 +7,7 @@ export interface TagProps {
|
|
|
7
7
|
onClick?: () => void;
|
|
8
8
|
/** `sm` renders a compact chip that fits within a normal text line height. Default `'md'`. */
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
|
-
/** Colour, from the theme's `color.chip` tokens (
|
|
10
|
+
/** Colour, from the theme's `color.chip` tokens. Status tones (`success`, `warning`, `danger`, `info`, `neutral`) report state; label tones (the rest) name a kind of thing. `status` is a legacy label tone despite its name; for a state use `success`/`warning`/`danger`/`info`, or `neutral` when it carries no meaning. Default `subject`. */
|
|
11
11
|
tone?: TagTone;
|
|
12
12
|
}
|
|
13
13
|
/** A small coloured chip for a category, status, or value. Optionally clickable. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/tag/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,YAAY,CAAC;AAEpD,YAAY,EAAE,OAAO,EAAE,CAAC;AAExB,MAAM,WAAW,QAAQ;IACvB,iBAAiB;IACjB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/tag/index.tsx"],"names":[],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O,KAAK,SAAS;YACnB,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACJ,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;oBACvC,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YACH,CAAC,CAAC,SAAS,YAGd,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\n\nimport { type TagTone, useStyle } from './style.js';\n\nexport type { TagTone };\n\nexport interface TagProps {\n /** The label. */\n children: React.ReactNode;\n /** Makes it a button (focusable, Enter/Space, pointer cursor). Receives no event. */\n onClick?: () => void;\n /** `sm` renders a compact chip that fits within a normal text line height. Default `'md'`. */\n size?: 'sm' | 'md';\n /** Colour, from the theme's `color.chip` tokens (
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/tag/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAgB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAepD,oFAAoF;AACpF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,SAAS,EAAY,EAAE,EAAE;IACpF,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,EACrB,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,EAAE,EACzB,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,CACzC,EACD,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAClD,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAC/C,SAAS,EACP,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACJ,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;oBACvC,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YACH,CAAC,CAAC,SAAS,YAGd,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\n\nimport { type TagTone, useStyle } from './style.js';\n\nexport type { TagTone };\n\nexport interface TagProps {\n /** The label. */\n children: React.ReactNode;\n /** Makes it a button (focusable, Enter/Space, pointer cursor). Receives no event. */\n onClick?: () => void;\n /** `sm` renders a compact chip that fits within a normal text line height. Default `'md'`. */\n size?: 'sm' | 'md';\n /** Colour, from the theme's `color.chip` tokens. Status tones (`success`, `warning`, `danger`, `info`, `neutral`) report state; label tones (the rest) name a kind of thing. `status` is a legacy label tone despite its name; for a state use `success`/`warning`/`danger`/`info`, or `neutral` when it carries no meaning. Default `subject`. */\n tone?: TagTone;\n}\n\n/** A small coloured chip for a category, status, or value. Optionally clickable. */\nexport const Tag = ({ children, onClick, size = 'md', tone = 'subject' }: TagProps) => {\n const style = useStyle();\n return (\n <span\n className={cx(\n style.root,\n style[`tone-${tone}`],\n size === 'sm' && style.sm,\n onClick !== undefined && style.clickable\n )}\n onClick={onClick}\n role={onClick !== undefined ? 'button' : undefined}\n tabIndex={onClick !== undefined ? 0 : undefined}\n onKeyDown={\n onClick !== undefined\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onClick();\n }\n }\n : undefined\n }\n >\n {children}\n </span>\n );\n};\n"]}
|
|
@@ -2,5 +2,5 @@ import { type Theme } from '../../theme/index.js';
|
|
|
2
2
|
export type TagTone = keyof Theme['color']['chip'];
|
|
3
3
|
export declare const useStyle: (data?: {
|
|
4
4
|
theme?: Theme | undefined;
|
|
5
|
-
} | undefined) => import("jss").Classes<"clickable" | "root" | "sm" | "tone-author" | "tone-book" | "tone-entryType" | "tone-neutral" | "tone-rating" | "tone-series" | "tone-status" | "tone-subject" | "tone-user">;
|
|
5
|
+
} | undefined) => import("jss").Classes<"clickable" | "root" | "sm" | "tone-author" | "tone-book" | "tone-danger" | "tone-entryType" | "tone-info" | "tone-neutral" | "tone-rating" | "tone-series" | "tone-status" | "tone-subject" | "tone-success" | "tone-user" | "tone-warning">;
|
|
6
6
|
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/component/tag/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAwBnD,eAAO,MAAM,QAAQ;;
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/component/tag/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAwBnD,eAAO,MAAM,QAAQ;;qRAoBlB,CAAC"}
|
package/dist/control/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { NumberInput, type NumberInputProps } from './number-input/index.js';
|
|
|
8
8
|
export { PageActionsBar, type PageActionsBarProps } from './page-actions-bar/index.js';
|
|
9
9
|
export { PageActionsMenu, type PageActionIntentProps, type PageActionItem, type PageActionsMenuProps, } from './page-actions-menu/index.js';
|
|
10
10
|
export { PageFooterActions, type FooterAction, type PageFooterActionsProps, } from './page-footer-actions/index.js';
|
|
11
|
-
export { Popover, type PopoverProps } from './popover/index.js';
|
|
11
|
+
export { Popover, type PopoverAlign, type PopoverProps, type PopoverSide, } from './popover/index.js';
|
|
12
12
|
export { Select, type SelectOption, type SelectProps } from './select/index.js';
|
|
13
13
|
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption, } from './segmented-control/index.js';
|
|
14
14
|
export { Switch, type SwitchProps, type SwitchRadiusValue } from './switch/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK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AAe,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/control/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { NumberInput } from './number-input/index.js';
|
|
|
8
8
|
export { PageActionsBar } from './page-actions-bar/index.js';
|
|
9
9
|
export { PageActionsMenu, } from './page-actions-menu/index.js';
|
|
10
10
|
export { PageFooterActions, } from './page-footer-actions/index.js';
|
|
11
|
-
export { Popover } from './popover/index.js';
|
|
11
|
+
export { Popover, } from './popover/index.js';
|
|
12
12
|
export { Select } from './select/index.js';
|
|
13
13
|
export { SegmentedControl, } from './segmented-control/index.js';
|
|
14
14
|
export { Switch } from './switch/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,MAAM,GAIP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAwC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAA0B,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,SAAS,GAIV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAA4B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,eAAe,GAIhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,MAAM,GAIP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAwC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAA0B,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,SAAS,GAIV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAA4B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,eAAe,GAIhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,GAIR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAuC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,gBAAgB,GAGjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAA4C,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAsB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,SAAS,EAA6C,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { BackButton, type BackButtonProps } from './back-button/index.js';\nexport {\n Button,\n type ButtonProps,\n type ButtonRadiusValue,\n type ButtonTypeValue,\n} from './button/index.js';\nexport { ChipsInput, type ChipColor, type ChipsInputProps } from './chips-input/index.js';\nexport { ConfirmModal, type ConfirmModalProps } from './confirm-modal/index.js';\nexport { DateTimeInput, type DateTimeInputProps } from './date-time-input/index.js';\nexport {\n FieldList,\n type ColumnDescriptor,\n type FieldListProps,\n type FieldRow,\n} from './field-list/index.js';\nexport { NumberInput, type NumberInputProps } from './number-input/index.js';\nexport { PageActionsBar, type PageActionsBarProps } from './page-actions-bar/index.js';\nexport {\n PageActionsMenu,\n type PageActionIntentProps,\n type PageActionItem,\n type PageActionsMenuProps,\n} from './page-actions-menu/index.js';\nexport {\n PageFooterActions,\n type FooterAction,\n type PageFooterActionsProps,\n} from './page-footer-actions/index.js';\nexport {\n Popover,\n type PopoverAlign,\n type PopoverProps,\n type PopoverSide,\n} from './popover/index.js';\nexport { Select, type SelectOption, type SelectProps } from './select/index.js';\nexport {\n SegmentedControl,\n type SegmentedControlProps,\n type SegmentedOption,\n} from './segmented-control/index.js';\nexport { Switch, type SwitchProps, type SwitchRadiusValue } from './switch/index.js';\nexport { TextArea, type TextAreaProps } from './text-area/index.js';\nexport { TextInput, type TextInputAction, type TextInputProps } from './text-input/index.js';\nexport { useModalDialog } from './use-modal-dialog/index.js';\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
import { type PopoverAlign, type PopoverSide } from './position.js';
|
|
3
|
+
export type { PopoverAlign, PopoverSide } from './position.js';
|
|
2
4
|
export type PopoverProps = {
|
|
3
|
-
/** Element the popover aligns to (
|
|
5
|
+
/** Element the popover aligns to (placed below or above it, per `side`). */
|
|
4
6
|
anchorRef: RefObject<HTMLElement | null>;
|
|
5
7
|
/** Whether the popover is rendered. */
|
|
6
8
|
open: boolean;
|
|
@@ -8,23 +10,37 @@ export type PopoverProps = {
|
|
|
8
10
|
children: ReactNode;
|
|
9
11
|
/** Applied to the fixed wrapper; win specificity with `'&&'`, never `!important`. */
|
|
10
12
|
className?: string;
|
|
11
|
-
/** Vertical gap between the anchor and the popover, in pixels. */
|
|
13
|
+
/** Vertical gap between the anchor and the popover, in pixels; also the viewport edge margin when `matchWidth` is false. */
|
|
12
14
|
gap?: number;
|
|
13
15
|
/** Match the popover width to the anchor width (default true). */
|
|
14
16
|
matchWidth?: boolean;
|
|
17
|
+
/** Preferred side; flips to the other side when this one has no room. */
|
|
18
|
+
side?: PopoverSide;
|
|
19
|
+
/** Horizontal alignment to the anchor's left edge, centre, or right edge. */
|
|
20
|
+
align?: PopoverAlign;
|
|
15
21
|
/**
|
|
16
|
-
* Called on a pointer-down outside both the anchor and the popover content
|
|
17
|
-
* Omit to opt out
|
|
22
|
+
* Called on a pointer-down outside both the anchor and the popover content,
|
|
23
|
+
* and on an Escape keydown no control has already handled. Omit to opt out.
|
|
18
24
|
*/
|
|
19
25
|
onClose?: () => void;
|
|
20
26
|
};
|
|
21
27
|
/**
|
|
22
28
|
* Renders `children` in a portal on `document.body`, positioned with `fixed`
|
|
23
|
-
* coordinates
|
|
24
|
-
*
|
|
29
|
+
* coordinates against `anchorRef`. This lets dropdowns escape ancestors that
|
|
30
|
+
* clip overflow (e.g. cards with rounded corners) without those ancestors
|
|
25
31
|
* having to opt out of clipping.
|
|
26
32
|
*
|
|
27
|
-
*
|
|
33
|
+
* Opens on `side` (default below) and flips when that side has no room; aligns
|
|
34
|
+
* per `align` and clamps horizontally to the viewport (only without
|
|
35
|
+
* `matchWidth`). The wrapper carries `data-side` with the side actually used.
|
|
36
|
+
* On the top side it is anchored by CSS `bottom`, so it stays attached as its
|
|
37
|
+
* content changes height. The first render is transparent (`opacity: 0`, still
|
|
38
|
+
* focusable) until measured, then it re-measures on scroll (capture phase),
|
|
39
|
+
* window resize, and content resize (`ResizeObserver`, where available).
|
|
40
|
+
*
|
|
41
|
+
* With `onClose`, Escape closes it unless the keydown was already
|
|
42
|
+
* `defaultPrevented`; it calls `preventDefault` so an enclosing `<dialog>`
|
|
43
|
+
* does not also cancel. No focus management.
|
|
28
44
|
*/
|
|
29
|
-
export declare const Popover: ({ anchorRef, open, children, className, gap, matchWidth, onClose, }: PopoverProps) => import("react").ReactPortal | null;
|
|
45
|
+
export declare const Popover: ({ anchorRef, open, children, className, gap, matchWidth, side, align, onClose, }: PopoverProps) => import("react").ReactPortal | null;
|
|
30
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,SAAS,EAMV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,SAAS,EAMV,MAAM,OAAO,CAAC;AAGf,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG;IACzB,4EAA4E;IAC5E,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4HAA4H;IAC5H,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yEAAyE;IACzE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,OAAO,qFAUjB,YAAY,uCAyFd,CAAC"}
|
|
@@ -2,26 +2,50 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
+
import { computePosition, } from './position.js';
|
|
5
6
|
import { useStyle } from './style.js';
|
|
6
7
|
/**
|
|
7
8
|
* Renders `children` in a portal on `document.body`, positioned with `fixed`
|
|
8
|
-
* coordinates
|
|
9
|
-
*
|
|
9
|
+
* coordinates against `anchorRef`. This lets dropdowns escape ancestors that
|
|
10
|
+
* clip overflow (e.g. cards with rounded corners) without those ancestors
|
|
10
11
|
* having to opt out of clipping.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
+
* Opens on `side` (default below) and flips when that side has no room; aligns
|
|
14
|
+
* per `align` and clamps horizontally to the viewport (only without
|
|
15
|
+
* `matchWidth`). The wrapper carries `data-side` with the side actually used.
|
|
16
|
+
* On the top side it is anchored by CSS `bottom`, so it stays attached as its
|
|
17
|
+
* content changes height. The first render is transparent (`opacity: 0`, still
|
|
18
|
+
* focusable) until measured, then it re-measures on scroll (capture phase),
|
|
19
|
+
* window resize, and content resize (`ResizeObserver`, where available).
|
|
20
|
+
*
|
|
21
|
+
* With `onClose`, Escape closes it unless the keydown was already
|
|
22
|
+
* `defaultPrevented`; it calls `preventDefault` so an enclosing `<dialog>`
|
|
23
|
+
* does not also cancel. No focus management.
|
|
13
24
|
*/
|
|
14
|
-
export const Popover = ({ anchorRef, open, children, className, gap = 4, matchWidth = true, onClose, }) => {
|
|
25
|
+
export const Popover = ({ anchorRef, open, children, className, gap = 4, matchWidth = true, side = 'bottom', align = 'start', onClose, }) => {
|
|
15
26
|
const style = useStyle();
|
|
16
27
|
const contentRef = useRef(null);
|
|
17
|
-
const [
|
|
28
|
+
const [placement, setPlacement] = useState(null);
|
|
18
29
|
const updatePosition = useCallback(() => {
|
|
19
30
|
const anchor = anchorRef.current;
|
|
20
|
-
|
|
31
|
+
const content = contentRef.current;
|
|
32
|
+
if (!anchor || !content)
|
|
21
33
|
return;
|
|
22
34
|
const rect = anchor.getBoundingClientRect();
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
// Measure at the width it will render with, so wrapped height is right.
|
|
36
|
+
if (matchWidth)
|
|
37
|
+
content.style.width = `${rect.width}px`;
|
|
38
|
+
const size = content.getBoundingClientRect();
|
|
39
|
+
setPlacement(computePosition({
|
|
40
|
+
anchor: rect,
|
|
41
|
+
content: { width: size.width, height: size.height },
|
|
42
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
43
|
+
side,
|
|
44
|
+
align,
|
|
45
|
+
gap,
|
|
46
|
+
matchWidth,
|
|
47
|
+
}));
|
|
48
|
+
}, [anchorRef, gap, matchWidth, side, align]);
|
|
25
49
|
useLayoutEffect(() => {
|
|
26
50
|
if (!open)
|
|
27
51
|
return;
|
|
@@ -30,9 +54,14 @@ export const Popover = ({ anchorRef, open, children, className, gap = 4, matchWi
|
|
|
30
54
|
// Capture-phase scroll so nested scroll containers reposition too.
|
|
31
55
|
window.addEventListener('scroll', handle, true);
|
|
32
56
|
window.addEventListener('resize', handle);
|
|
57
|
+
const observer = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(handle) : undefined;
|
|
58
|
+
if (observer && contentRef.current)
|
|
59
|
+
observer.observe(contentRef.current);
|
|
33
60
|
return () => {
|
|
34
61
|
window.removeEventListener('scroll', handle, true);
|
|
35
62
|
window.removeEventListener('resize', handle);
|
|
63
|
+
observer?.disconnect();
|
|
64
|
+
setPlacement(null);
|
|
36
65
|
};
|
|
37
66
|
}, [open, updatePosition]);
|
|
38
67
|
useEffect(() => {
|
|
@@ -46,15 +75,31 @@ export const Popover = ({ anchorRef, open, children, className, gap = 4, matchWi
|
|
|
46
75
|
return;
|
|
47
76
|
onClose();
|
|
48
77
|
};
|
|
78
|
+
const handleKeyDown = (event) => {
|
|
79
|
+
if (event.key !== 'Escape' || event.defaultPrevented)
|
|
80
|
+
return;
|
|
81
|
+
// preventDefault on keydown is what stops a native <dialog> from cancelling.
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
onClose();
|
|
84
|
+
};
|
|
49
85
|
document.addEventListener('mousedown', handleMouseDown);
|
|
50
|
-
|
|
86
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
87
|
+
return () => {
|
|
88
|
+
document.removeEventListener('mousedown', handleMouseDown);
|
|
89
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
90
|
+
};
|
|
51
91
|
}, [open, onClose, anchorRef]);
|
|
52
|
-
if (!open
|
|
92
|
+
if (!open)
|
|
53
93
|
return null;
|
|
54
|
-
return createPortal(_jsx("div", { ref: contentRef, className: cx(style.popover, className), style:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
return createPortal(_jsx("div", { ref: contentRef, className: cx(style.popover, className), "data-side": placement?.side, style: placement
|
|
95
|
+
? {
|
|
96
|
+
top: placement.top,
|
|
97
|
+
bottom: placement.bottom,
|
|
98
|
+
left: placement.left,
|
|
99
|
+
width: placement.width,
|
|
100
|
+
}
|
|
101
|
+
: // Never painted: the layout effect measures and re-renders first.
|
|
102
|
+
// Opacity, not visibility, so an autoFocus child can take focus.
|
|
103
|
+
{ top: 0, left: 0, opacity: 0 }, children: children }), document.body);
|
|
59
104
|
};
|
|
60
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAGL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names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CAAC,IAAI;gBACpB,KAAK,EAAE,SAAS,CAAC,KAAK;aACvB;YACH,CAAC,CAAC,kEAAkE;gBAClE,iEAAiE;gBACjE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,YAGpC,QAAQ,GACL,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport {\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport {\n computePosition,\n type Placement,\n type PopoverAlign,\n type PopoverSide,\n} from './position.js';\nimport { useStyle } from './style.js';\n\nexport type { PopoverAlign, PopoverSide } from './position.js';\n\nexport type PopoverProps = {\n /** Element the popover aligns to (placed below or above it, per `side`). */\n anchorRef: RefObject<HTMLElement | null>;\n /** Whether the popover is rendered. */\n open: boolean;\n /** Your surface: give it its own background, border, and radius. */\n children: ReactNode;\n /** Applied to the fixed wrapper; win specificity with `'&&'`, never `!important`. */\n className?: string;\n /** Vertical gap between the anchor and the popover, in pixels; also the viewport edge margin when `matchWidth` is false. */\n gap?: number;\n /** Match the popover width to the anchor width (default true). */\n matchWidth?: boolean;\n /** Preferred side; flips to the other side when this one has no room. */\n side?: PopoverSide;\n /** Horizontal alignment to the anchor's left edge, centre, or right edge. */\n align?: PopoverAlign;\n /**\n * Called on a pointer-down outside both the anchor and the popover content,\n * and on an Escape keydown no control has already handled. Omit to opt out.\n */\n onClose?: () => void;\n};\n\n/**\n * Renders `children` in a portal on `document.body`, positioned with `fixed`\n * coordinates against `anchorRef`. This lets dropdowns escape ancestors that\n * clip overflow (e.g. cards with rounded corners) without those ancestors\n * having to opt out of clipping.\n *\n * Opens on `side` (default below) and flips when that side has no room; aligns\n * per `align` and clamps horizontally to the viewport (only without\n * `matchWidth`). The wrapper carries `data-side` with the side actually used.\n * On the top side it is anchored by CSS `bottom`, so it stays attached as its\n * content changes height. The first render is transparent (`opacity: 0`, still\n * focusable) until measured, then it re-measures on scroll (capture phase),\n * window resize, and content resize (`ResizeObserver`, where available).\n *\n * With `onClose`, Escape closes it unless the keydown was already\n * `defaultPrevented`; it calls `preventDefault` so an enclosing `<dialog>`\n * does not also cancel. No focus management.\n */\nexport const Popover = ({\n anchorRef,\n open,\n children,\n className,\n gap = 4,\n matchWidth = true,\n side = 'bottom',\n align = 'start',\n onClose,\n}: PopoverProps) => {\n const style = useStyle();\n const contentRef = useRef<HTMLDivElement>(null);\n const [placement, setPlacement] = useState<Placement | null>(null);\n\n const updatePosition = useCallback(() => {\n const anchor = anchorRef.current;\n const content = contentRef.current;\n if (!anchor || !content) return;\n const rect = anchor.getBoundingClientRect();\n // Measure at the width it will render with, so wrapped height is right.\n if (matchWidth) content.style.width = `${rect.width}px`;\n const size = content.getBoundingClientRect();\n setPlacement(\n computePosition({\n anchor: rect,\n content: { width: size.width, height: size.height },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n side,\n align,\n gap,\n matchWidth,\n })\n );\n }, [anchorRef, gap, matchWidth, side, align]);\n\n useLayoutEffect(() => {\n if (!open) return;\n updatePosition();\n const handle = () => updatePosition();\n // Capture-phase scroll so nested scroll containers reposition too.\n window.addEventListener('scroll', handle, true);\n window.addEventListener('resize', handle);\n const observer = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(handle) : undefined;\n if (observer && contentRef.current) observer.observe(contentRef.current);\n return () => {\n window.removeEventListener('scroll', handle, true);\n window.removeEventListener('resize', handle);\n observer?.disconnect();\n setPlacement(null);\n };\n }, [open, updatePosition]);\n\n useEffect(() => {\n if (!open || !onClose) return;\n const handleMouseDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (anchorRef.current?.contains(target)) return;\n if (contentRef.current?.contains(target)) return;\n onClose();\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.defaultPrevented) return;\n // preventDefault on keydown is what stops a native <dialog> from cancelling.\n event.preventDefault();\n onClose();\n };\n document.addEventListener('mousedown', handleMouseDown);\n document.addEventListener('keydown', handleKeyDown);\n return () => {\n document.removeEventListener('mousedown', handleMouseDown);\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [open, onClose, anchorRef]);\n\n if (!open) return null;\n\n return createPortal(\n <div\n ref={contentRef}\n className={cx(style.popover, className)}\n data-side={placement?.side}\n style={\n placement\n ? {\n top: placement.top,\n bottom: placement.bottom,\n left: placement.left,\n width: placement.width,\n }\n : // Never painted: the layout effect measures and re-renders first.\n // Opacity, not visibility, so an autoFocus child can take focus.\n { top: 0, left: 0, opacity: 0 }\n }\n >\n {children}\n </div>,\n document.body\n );\n};\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Which side of the anchor the popover prefers. */
|
|
2
|
+
export type PopoverSide = 'bottom' | 'top';
|
|
3
|
+
/** Horizontal alignment of the popover against the anchor. */
|
|
4
|
+
export type PopoverAlign = 'start' | 'center' | 'end';
|
|
5
|
+
/** Viewport-relative rectangle, as from getBoundingClientRect. */
|
|
6
|
+
export type Rect = {
|
|
7
|
+
top: number;
|
|
8
|
+
bottom: number;
|
|
9
|
+
left: number;
|
|
10
|
+
right: number;
|
|
11
|
+
width: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Resolved popover position; `side` is the side actually used after flipping.
|
|
15
|
+
* Exactly one of `top` / `bottom` is set: the bottom side is anchored by its
|
|
16
|
+
* top edge (CSS `top`), the top side by its bottom edge (CSS `bottom`, measured
|
|
17
|
+
* from the viewport's bottom), so content that grows or shrinks while open
|
|
18
|
+
* stays attached to the anchor.
|
|
19
|
+
*/
|
|
20
|
+
export type Placement = {
|
|
21
|
+
top: number | undefined;
|
|
22
|
+
bottom: number | undefined;
|
|
23
|
+
left: number;
|
|
24
|
+
width: number | undefined;
|
|
25
|
+
side: PopoverSide;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Pure placement: picks the side (flipping when the preferred side does not
|
|
29
|
+
* fit and the other has more room), aligns horizontally, and clamps to the
|
|
30
|
+
* viewport horizontally unless `matchWidth` (then it lines up with the anchor).
|
|
31
|
+
*/
|
|
32
|
+
export declare function computePosition({ anchor, content, viewport, side, align, gap, matchWidth, }: {
|
|
33
|
+
anchor: Rect;
|
|
34
|
+
content: {
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
};
|
|
38
|
+
viewport: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
side: PopoverSide;
|
|
43
|
+
align: PopoverAlign;
|
|
44
|
+
gap: number;
|
|
45
|
+
matchWidth: boolean;
|
|
46
|
+
}): Placement;
|
|
47
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/control/popover/position.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAC;AAC3C,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AACtD,kEAAkE;AAClE,MAAM,MAAM,IAAI,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/F;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,GAAG,EACH,UAAU,GACX,EAAE;IACD,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,SAAS,CAuBZ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure placement: picks the side (flipping when the preferred side does not
|
|
3
|
+
* fit and the other has more room), aligns horizontally, and clamps to the
|
|
4
|
+
* viewport horizontally unless `matchWidth` (then it lines up with the anchor).
|
|
5
|
+
*/
|
|
6
|
+
export function computePosition({ anchor, content, viewport, side, align, gap, matchWidth, }) {
|
|
7
|
+
const w = matchWidth ? anchor.width : content.width;
|
|
8
|
+
const h = content.height;
|
|
9
|
+
const roomBelow = viewport.height - anchor.bottom - gap;
|
|
10
|
+
const roomAbove = anchor.top - gap;
|
|
11
|
+
const room = (s) => (s === 'bottom' ? roomBelow : roomAbove);
|
|
12
|
+
const other = side === 'bottom' ? 'top' : 'bottom';
|
|
13
|
+
const used = room(side) >= h || room(other) <= room(side) ? side : other;
|
|
14
|
+
const top = used === 'bottom' ? anchor.bottom + gap : undefined;
|
|
15
|
+
const bottom = used === 'top' ? viewport.height - anchor.top + gap : undefined;
|
|
16
|
+
let left;
|
|
17
|
+
if (align === 'start')
|
|
18
|
+
left = anchor.left;
|
|
19
|
+
else if (align === 'center')
|
|
20
|
+
left = anchor.left + anchor.width / 2 - w / 2;
|
|
21
|
+
else
|
|
22
|
+
left = anchor.right - w;
|
|
23
|
+
if (!matchWidth) {
|
|
24
|
+
left =
|
|
25
|
+
w > viewport.width - 2 * gap ? gap : Math.max(gap, Math.min(left, viewport.width - w - gap));
|
|
26
|
+
}
|
|
27
|
+
return { top, bottom, left, width: matchWidth ? anchor.width : undefined, side: used };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.js","sourceRoot":"","sources":["../../../src/control/popover/position.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,GAAG,EACH,UAAU,GASX;IACC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACpD,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAEzB,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;IACxD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACnC,MAAM,IAAI,GAAG,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAgB,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,MAAM,GAAG,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/E,IAAI,IAAY,CAAC;IACjB,IAAI,KAAK,KAAK,OAAO;QAAE,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;SACrC,IAAI,KAAK,KAAK,QAAQ;QAAE,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;;QACtE,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAE7B,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI;YACF,CAAC,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACzF,CAAC","sourcesContent":["/** Which side of the anchor the popover prefers. */\nexport type PopoverSide = 'bottom' | 'top';\n/** Horizontal alignment of the popover against the anchor. */\nexport type PopoverAlign = 'start' | 'center' | 'end';\n/** Viewport-relative rectangle, as from getBoundingClientRect. */\nexport type Rect = { top: number; bottom: number; left: number; right: number; width: number };\n/**\n * Resolved popover position; `side` is the side actually used after flipping.\n * Exactly one of `top` / `bottom` is set: the bottom side is anchored by its\n * top edge (CSS `top`), the top side by its bottom edge (CSS `bottom`, measured\n * from the viewport's bottom), so content that grows or shrinks while open\n * stays attached to the anchor.\n */\nexport type Placement = {\n top: number | undefined;\n bottom: number | undefined;\n left: number;\n width: number | undefined;\n side: PopoverSide;\n};\n\n/**\n * Pure placement: picks the side (flipping when the preferred side does not\n * fit and the other has more room), aligns horizontally, and clamps to the\n * viewport horizontally unless `matchWidth` (then it lines up with the anchor).\n */\nexport function computePosition({\n anchor,\n content,\n viewport,\n side,\n align,\n gap,\n matchWidth,\n}: {\n anchor: Rect;\n content: { width: number; height: number };\n viewport: { width: number; height: number };\n side: PopoverSide;\n align: PopoverAlign;\n gap: number;\n matchWidth: boolean;\n}): Placement {\n const w = matchWidth ? anchor.width : content.width;\n const h = content.height;\n\n const roomBelow = viewport.height - anchor.bottom - gap;\n const roomAbove = anchor.top - gap;\n const room = (s: PopoverSide) => (s === 'bottom' ? roomBelow : roomAbove);\n const other: PopoverSide = side === 'bottom' ? 'top' : 'bottom';\n const used = room(side) >= h || room(other) <= room(side) ? side : other;\n const top = used === 'bottom' ? anchor.bottom + gap : undefined;\n const bottom = used === 'top' ? viewport.height - anchor.top + gap : undefined;\n\n let left: number;\n if (align === 'start') left = anchor.left;\n else if (align === 'center') left = anchor.left + anchor.width / 2 - w / 2;\n else left = anchor.right - w;\n\n if (!matchWidth) {\n left =\n w > viewport.width - 2 * gap ? gap : Math.max(gap, Math.min(left, viewport.width - w - gap));\n }\n\n return { top, bottom, left, width: matchWidth ? anchor.width : undefined, side: used };\n}\n"]}
|
package/dist/theme/theme.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ export interface Theme {
|
|
|
85
85
|
section: string;
|
|
86
86
|
};
|
|
87
87
|
success: string;
|
|
88
|
+
/** Solid warning colour for icons and accents. */
|
|
89
|
+
warning: string;
|
|
90
|
+
/** Solid info colour for icons and accents. */
|
|
91
|
+
info: string;
|
|
88
92
|
brand: {
|
|
89
93
|
default: string;
|
|
90
94
|
hover: string;
|
|
@@ -155,6 +159,26 @@ export interface Theme {
|
|
|
155
159
|
bg: string;
|
|
156
160
|
border: string;
|
|
157
161
|
};
|
|
162
|
+
success: {
|
|
163
|
+
text: string;
|
|
164
|
+
bg: string;
|
|
165
|
+
border: string;
|
|
166
|
+
};
|
|
167
|
+
warning: {
|
|
168
|
+
text: string;
|
|
169
|
+
bg: string;
|
|
170
|
+
border: string;
|
|
171
|
+
};
|
|
172
|
+
danger: {
|
|
173
|
+
text: string;
|
|
174
|
+
bg: string;
|
|
175
|
+
border: string;
|
|
176
|
+
};
|
|
177
|
+
info: {
|
|
178
|
+
text: string;
|
|
179
|
+
bg: string;
|
|
180
|
+
border: string;
|
|
181
|
+
};
|
|
158
182
|
};
|
|
159
183
|
};
|
|
160
184
|
space: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAGzC,QAAA,MAAM,IAAI;aACR,EAAE,EAAE,SAAS;aACb,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,MAAM;CACH,CAAC;AAEX,QAAA,MAAM,IAAI;aACR,EAAE,EAAE,SAAS;aACb,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;aACd,GAAG,EAAE,SAAS;CACN,CAAC;AAEX,QAAA,MAAM,GAAG;aACP,EAAE,EAAE,SAAS;aACb,GAAG,EAAE,SAAS;aACd,G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E,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAIF,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,4FAA4F;QAC5F,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YACL,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;QACF,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;CACH;AA+fD,eAAO,MAAM,UAAU,EAAE,KAA2B,CAAC;AACrD,eAAO,MAAM,SAAS,EAAE,KAA0B,CAAC;AACnD,eAAO,MAAM,YAAY,EAAE,KAAkB,CAAC"}
|
package/dist/theme/theme.js
CHANGED
|
@@ -83,6 +83,8 @@ function buildTheme(mode) {
|
|
|
83
83
|
section: '#E6E6E9',
|
|
84
84
|
},
|
|
85
85
|
success: '#16a34a',
|
|
86
|
+
warning: '#ca8a04',
|
|
87
|
+
info: blue[500],
|
|
86
88
|
brand: {
|
|
87
89
|
default: blue[500],
|
|
88
90
|
hover: blue[400],
|
|
@@ -123,6 +125,22 @@ function buildTheme(mode) {
|
|
|
123
125
|
bg: applyTransparency(gray[600], 0.08),
|
|
124
126
|
border: applyTransparency(gray[600], 0.22),
|
|
125
127
|
},
|
|
128
|
+
success: {
|
|
129
|
+
text: '#15803d',
|
|
130
|
+
bg: applyTransparency('#16a34a', 0.08),
|
|
131
|
+
border: applyTransparency('#16a34a', 0.22),
|
|
132
|
+
},
|
|
133
|
+
warning: { text: '#854d0e', bg: 'rgba(234,179,8,0.16)', border: 'rgba(202,138,4,0.40)' },
|
|
134
|
+
danger: {
|
|
135
|
+
text: red[700],
|
|
136
|
+
bg: applyTransparency(red[500], 0.08),
|
|
137
|
+
border: applyTransparency(red[500], 0.22),
|
|
138
|
+
},
|
|
139
|
+
info: {
|
|
140
|
+
text: blue[700],
|
|
141
|
+
bg: applyTransparency(blue[500], 0.08),
|
|
142
|
+
border: applyTransparency(blue[500], 0.24),
|
|
143
|
+
},
|
|
126
144
|
},
|
|
127
145
|
};
|
|
128
146
|
const darkMuted = '#9CA1AB';
|
|
@@ -174,6 +192,8 @@ function buildTheme(mode) {
|
|
|
174
192
|
section: '#2B2C30',
|
|
175
193
|
},
|
|
176
194
|
success: '#22C55E',
|
|
195
|
+
warning: '#EAB308',
|
|
196
|
+
info: blue[400],
|
|
177
197
|
brand: {
|
|
178
198
|
default: blue[400],
|
|
179
199
|
hover: blue[300],
|
|
@@ -215,6 +235,22 @@ function buildTheme(mode) {
|
|
|
215
235
|
bg: applyTransparency(darkMuted, 0.16),
|
|
216
236
|
border: applyTransparency(darkMuted, 0.3),
|
|
217
237
|
},
|
|
238
|
+
success: {
|
|
239
|
+
text: '#86EFAC',
|
|
240
|
+
bg: applyTransparency('#22C55E', 0.16),
|
|
241
|
+
border: applyTransparency('#22C55E', 0.3),
|
|
242
|
+
},
|
|
243
|
+
warning: { text: '#FDE047', bg: 'rgba(234,179,8,0.20)', border: 'rgba(234,179,8,0.42)' },
|
|
244
|
+
danger: {
|
|
245
|
+
text: red[400],
|
|
246
|
+
bg: applyTransparency(red[500], 0.16),
|
|
247
|
+
border: applyTransparency(red[500], 0.3),
|
|
248
|
+
},
|
|
249
|
+
info: {
|
|
250
|
+
text: blue[300],
|
|
251
|
+
bg: applyTransparency(blue[400], 0.18),
|
|
252
|
+
border: applyTransparency(blue[400], 0.36),
|
|
253
|
+
},
|
|
218
254
|
},
|
|
219
255
|
};
|
|
220
256
|
const color = mode === 'dark' ? darkColor : lightColor;
|