@bitrise/bitkit-v2 0.3.535 → 0.3.536
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.
|
@@ -23,6 +23,7 @@ type BitkitSelectMenuActionCommonProps = {
|
|
|
23
23
|
export type BitkitSelectMenuActionAsButtonProps = BitkitSelectMenuActionCommonProps & {
|
|
24
24
|
href?: undefined;
|
|
25
25
|
isExternal?: undefined;
|
|
26
|
+
/** Runs before the menu closes. Clicking an action always closes the menu. */
|
|
26
27
|
onClick: () => void;
|
|
27
28
|
};
|
|
28
29
|
export type BitkitSelectMenuActionAsAnchorProps = BitkitSelectMenuActionCommonProps & {
|
|
@@ -21,6 +21,10 @@ var actionStepKeys = {
|
|
|
21
21
|
var BitkitSelectMenuAction = (props) => {
|
|
22
22
|
const { colorVariant, href, icon: Icon, label, onClick, state, tooltip } = props;
|
|
23
23
|
const { api, iconSize, styles } = useSelectMenuShellContext();
|
|
24
|
+
const handleClick = () => {
|
|
25
|
+
onClick?.();
|
|
26
|
+
api.setOpen(false);
|
|
27
|
+
};
|
|
24
28
|
const rowProps = {
|
|
25
29
|
"data-color-variant": colorVariant,
|
|
26
30
|
"data-select-menu-action": "",
|
|
@@ -69,7 +73,7 @@ var BitkitSelectMenuAction = (props) => {
|
|
|
69
73
|
target: effectiveTarget,
|
|
70
74
|
rel: effectiveRel,
|
|
71
75
|
css: styles.action,
|
|
72
|
-
onClick,
|
|
76
|
+
onClick: handleClick,
|
|
73
77
|
...rowProps,
|
|
74
78
|
children: content
|
|
75
79
|
}));
|
|
@@ -77,7 +81,7 @@ var BitkitSelectMenuAction = (props) => {
|
|
|
77
81
|
return asRow(/* @__PURE__ */ jsx(chakra.button, {
|
|
78
82
|
type: "button",
|
|
79
83
|
css: styles.action,
|
|
80
|
-
onClick,
|
|
84
|
+
onClick: handleClick,
|
|
81
85
|
...rowProps,
|
|
82
86
|
children: content
|
|
83
87
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitSelectMenuAction.js","names":["_Fragment"],"sources":["../../../lib/components/BitkitSelectMenu/BitkitSelectMenuAction.tsx"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport { createContext } from '@chakra-ui/react';\nimport { type ListCollection } from '@chakra-ui/react/collection';\nimport { chakra, type SystemStyleObject } from '@chakra-ui/react/styled-system';\nimport { type KeyboardEvent as ReactKeyboardEvent, type ReactElement } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\ntype BitkitSelectMenuActionCommonProps = {\n /** `ai` colors the icon for an AI action. A disabled action keeps the disabled icon color. */\n colorVariant?: 'ai';\n icon: BitkitIconComponent;\n label: string;\n /**\n * A disabled action stays focusable and keeps taking pointer events (`aria-disabled`, not the\n * native attribute), so the `tooltip` saying why it is unavailable is still reachable. Natively\n * disabled it would be neither hoverable nor tabbable, hiding the explanation in the one state\n * that needs it.\n *\n * This is the only disabled affordance in the menus: an option a user cannot pick is left out\n * of the collection instead, never dimmed.\n */\n state?: 'disabled';\n /** Hover and focus tooltip on the row. On a disabled action, say why it is unavailable. */\n tooltip?: string;\n};\n\nexport type BitkitSelectMenuActionAsButtonProps = BitkitSelectMenuActionCommonProps & {\n href?: undefined;\n isExternal?: undefined;\n onClick: () => void;\n};\n\nexport type BitkitSelectMenuActionAsAnchorProps = BitkitSelectMenuActionCommonProps & {\n href: string;\n isExternal?: boolean;\n onClick?: () => void;\n rel?: string;\n target?: string;\n};\n\nexport type BitkitSelectMenuActionProps = BitkitSelectMenuActionAsButtonProps | BitkitSelectMenuActionAsAnchorProps;\n\nexport type BitkitSelectMenuActionChild = ReactElement<BitkitSelectMenuActionProps> | false | null;\n\nexport type BitkitSelectMenuActionChildren = BitkitSelectMenuActionChild | BitkitSelectMenuActionChild[];\n\nexport type SelectMenuApi = {\n clearHighlightValue: () => void;\n collection: Pick<ListCollection<{ value: string }>, 'firstValue' | 'lastValue'>;\n setHighlightValue: (value: string) => void;\n setOpen: (open: boolean) => void;\n};\n\ntype SelectMenuShellContext = {\n api: SelectMenuApi;\n iconSize: '16' | '24';\n styles: Record<string, SystemStyleObject>;\n};\n\nconst [SelectMenuShellContextProvider, useSelectMenuShellContext] = createContext<SelectMenuShellContext>({\n name: 'SelectMenuShellContext',\n hookName: 'useSelectMenuShellContext',\n providerName:\n '<BitkitSelectMenu />, <BitkitMultiselectMenu />, <BitkitSelect />, <BitkitMultiselect />, or <BitkitCombobox />',\n});\n\nexport { SelectMenuShellContextProvider };\n\nconst listEdgeKeys: Record<string, 'firstValue' | 'lastValue' | undefined> = {\n ArrowDown: 'firstValue',\n ArrowUp: 'lastValue',\n End: 'lastValue',\n Home: 'firstValue',\n};\n\nconst actionStepKeys: Record<string, 1 | -1 | undefined> = {\n ArrowDown: 1,\n ArrowUp: -1,\n};\n\nconst BitkitSelectMenuAction = (props: BitkitSelectMenuActionProps) => {\n const { colorVariant, href, icon: Icon, label, onClick, state, tooltip } = props;\n const { api, iconSize, styles } = useSelectMenuShellContext();\n\n const rowProps = {\n 'data-color-variant': colorVariant,\n 'data-select-menu-action': '',\n onFocus: api.clearHighlightValue,\n onKeyDown: (event: ReactKeyboardEvent) => {\n if (event.key === 'Tab' || event.key === 'Escape') return;\n event.stopPropagation();\n\n // Up and Down step between the actions first, and leave them for the list only past the first\n // or the last one.\n const step = actionStepKeys[event.key];\n if (step) {\n const actions = Array.from(\n event.currentTarget\n .closest('[data-select-menu-actions]')\n ?.querySelectorAll<HTMLElement>('[data-select-menu-action]') ?? [],\n );\n const next = actions[actions.indexOf(event.currentTarget as HTMLElement) + step];\n if (next) {\n event.preventDefault();\n next.focus();\n return;\n }\n }\n\n const edge = listEdgeKeys[event.key];\n const value = edge && api.collection[edge];\n if (!value) return;\n\n event.preventDefault();\n const content = event.currentTarget.closest<HTMLElement>('[data-part=\"content\"]');\n (content?.querySelector<HTMLElement>('input') ?? content)?.focus();\n api.setHighlightValue(value);\n },\n };\n\n const content = (\n <>\n <Icon size={iconSize} />\n {label}\n </>\n );\n\n const asRow = (row: ReactElement) => (tooltip ? <BitkitTooltip text={tooltip}>{row}</BitkitTooltip> : row);\n\n if (state === 'disabled') {\n return asRow(\n // A button even for an `href` action: dropping the attribute is the only thing that stops a\n // middle click or \"open link in new tab\" from navigating anyway, and an anchor without one\n // leaves the tab order, taking the tooltip with it.\n <chakra.button\n type=\"button\"\n aria-disabled=\"true\"\n css={styles.action}\n // `_disabled` matches `[aria-disabled=true]` by itself, but `_hover`/`_active` only\n // exclude `:disabled` and `[data-disabled]`, so without this the row still lights up.\n data-disabled=\"\"\n {...rowProps}\n >\n {content}\n </chakra.button>,\n );\n }\n\n if (href !== undefined) {\n const { isExternal, rel, target } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n\n return asRow(\n <chakra.a\n href={href}\n target={effectiveTarget}\n rel={effectiveRel}\n css={styles.action}\n onClick={
|
|
1
|
+
{"version":3,"file":"BitkitSelectMenuAction.js","names":["_Fragment"],"sources":["../../../lib/components/BitkitSelectMenu/BitkitSelectMenuAction.tsx"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport { createContext } from '@chakra-ui/react';\nimport { type ListCollection } from '@chakra-ui/react/collection';\nimport { chakra, type SystemStyleObject } from '@chakra-ui/react/styled-system';\nimport { type KeyboardEvent as ReactKeyboardEvent, type ReactElement } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\ntype BitkitSelectMenuActionCommonProps = {\n /** `ai` colors the icon for an AI action. A disabled action keeps the disabled icon color. */\n colorVariant?: 'ai';\n icon: BitkitIconComponent;\n label: string;\n /**\n * A disabled action stays focusable and keeps taking pointer events (`aria-disabled`, not the\n * native attribute), so the `tooltip` saying why it is unavailable is still reachable. Natively\n * disabled it would be neither hoverable nor tabbable, hiding the explanation in the one state\n * that needs it.\n *\n * This is the only disabled affordance in the menus: an option a user cannot pick is left out\n * of the collection instead, never dimmed.\n */\n state?: 'disabled';\n /** Hover and focus tooltip on the row. On a disabled action, say why it is unavailable. */\n tooltip?: string;\n};\n\nexport type BitkitSelectMenuActionAsButtonProps = BitkitSelectMenuActionCommonProps & {\n href?: undefined;\n isExternal?: undefined;\n /** Runs before the menu closes. Clicking an action always closes the menu. */\n onClick: () => void;\n};\n\nexport type BitkitSelectMenuActionAsAnchorProps = BitkitSelectMenuActionCommonProps & {\n href: string;\n isExternal?: boolean;\n onClick?: () => void;\n rel?: string;\n target?: string;\n};\n\nexport type BitkitSelectMenuActionProps = BitkitSelectMenuActionAsButtonProps | BitkitSelectMenuActionAsAnchorProps;\n\nexport type BitkitSelectMenuActionChild = ReactElement<BitkitSelectMenuActionProps> | false | null;\n\nexport type BitkitSelectMenuActionChildren = BitkitSelectMenuActionChild | BitkitSelectMenuActionChild[];\n\nexport type SelectMenuApi = {\n clearHighlightValue: () => void;\n collection: Pick<ListCollection<{ value: string }>, 'firstValue' | 'lastValue'>;\n setHighlightValue: (value: string) => void;\n setOpen: (open: boolean) => void;\n};\n\ntype SelectMenuShellContext = {\n api: SelectMenuApi;\n iconSize: '16' | '24';\n styles: Record<string, SystemStyleObject>;\n};\n\nconst [SelectMenuShellContextProvider, useSelectMenuShellContext] = createContext<SelectMenuShellContext>({\n name: 'SelectMenuShellContext',\n hookName: 'useSelectMenuShellContext',\n providerName:\n '<BitkitSelectMenu />, <BitkitMultiselectMenu />, <BitkitSelect />, <BitkitMultiselect />, or <BitkitCombobox />',\n});\n\nexport { SelectMenuShellContextProvider };\n\nconst listEdgeKeys: Record<string, 'firstValue' | 'lastValue' | undefined> = {\n ArrowDown: 'firstValue',\n ArrowUp: 'lastValue',\n End: 'lastValue',\n Home: 'firstValue',\n};\n\nconst actionStepKeys: Record<string, 1 | -1 | undefined> = {\n ArrowDown: 1,\n ArrowUp: -1,\n};\n\nconst BitkitSelectMenuAction = (props: BitkitSelectMenuActionProps) => {\n const { colorVariant, href, icon: Icon, label, onClick, state, tooltip } = props;\n const { api, iconSize, styles } = useSelectMenuShellContext();\n\n const handleClick = () => {\n onClick?.();\n api.setOpen(false);\n };\n\n const rowProps = {\n 'data-color-variant': colorVariant,\n 'data-select-menu-action': '',\n onFocus: api.clearHighlightValue,\n onKeyDown: (event: ReactKeyboardEvent) => {\n if (event.key === 'Tab' || event.key === 'Escape') return;\n event.stopPropagation();\n\n // Up and Down step between the actions first, and leave them for the list only past the first\n // or the last one.\n const step = actionStepKeys[event.key];\n if (step) {\n const actions = Array.from(\n event.currentTarget\n .closest('[data-select-menu-actions]')\n ?.querySelectorAll<HTMLElement>('[data-select-menu-action]') ?? [],\n );\n const next = actions[actions.indexOf(event.currentTarget as HTMLElement) + step];\n if (next) {\n event.preventDefault();\n next.focus();\n return;\n }\n }\n\n const edge = listEdgeKeys[event.key];\n const value = edge && api.collection[edge];\n if (!value) return;\n\n event.preventDefault();\n const content = event.currentTarget.closest<HTMLElement>('[data-part=\"content\"]');\n (content?.querySelector<HTMLElement>('input') ?? content)?.focus();\n api.setHighlightValue(value);\n },\n };\n\n const content = (\n <>\n <Icon size={iconSize} />\n {label}\n </>\n );\n\n const asRow = (row: ReactElement) => (tooltip ? <BitkitTooltip text={tooltip}>{row}</BitkitTooltip> : row);\n\n if (state === 'disabled') {\n return asRow(\n // A button even for an `href` action: dropping the attribute is the only thing that stops a\n // middle click or \"open link in new tab\" from navigating anyway, and an anchor without one\n // leaves the tab order, taking the tooltip with it.\n <chakra.button\n type=\"button\"\n aria-disabled=\"true\"\n css={styles.action}\n // `_disabled` matches `[aria-disabled=true]` by itself, but `_hover`/`_active` only\n // exclude `:disabled` and `[data-disabled]`, so without this the row still lights up.\n data-disabled=\"\"\n {...rowProps}\n >\n {content}\n </chakra.button>,\n );\n }\n\n if (href !== undefined) {\n const { isExternal, rel, target } = props;\n const effectiveTarget = isExternal ? '_blank' : target;\n const effectiveRel = isExternal ? (rel ? `${rel} noreferrer noopener` : 'noreferrer noopener') : rel;\n\n return asRow(\n <chakra.a\n href={href}\n target={effectiveTarget}\n rel={effectiveRel}\n css={styles.action}\n onClick={handleClick}\n {...rowProps}\n >\n {content}\n </chakra.a>,\n );\n }\n\n return asRow(\n <chakra.button type=\"button\" css={styles.action} onClick={handleClick} {...rowProps}>\n {content}\n </chakra.button>,\n );\n};\n\nBitkitSelectMenuAction.displayName = 'BitkitSelectMenu.Action';\n\nexport default BitkitSelectMenuAction;\n"],"mappings":";;;;;AA8DA,IAAM,CAAC,gCAAgC,6BAA6B,cAAsC;CACxG,MAAM;CACN,UAAU;CACV,cACE;AACJ,CAAC;AAID,IAAM,eAAuE;CAC3E,WAAW;CACX,SAAS;CACT,KAAK;CACL,MAAM;AACR;AAEA,IAAM,iBAAqD;CACzD,WAAW;CACX,SAAS;AACX;AAEA,IAAM,0BAA0B,UAAuC;CACrE,MAAM,EAAE,cAAc,MAAM,MAAM,MAAM,OAAO,SAAS,OAAO,YAAY;CAC3E,MAAM,EAAE,KAAK,UAAU,WAAW,0BAA0B;CAE5D,MAAM,oBAAoB;EACxB,UAAU;EACV,IAAI,QAAQ,KAAK;CACnB;CAEA,MAAM,WAAW;EACf,sBAAsB;EACtB,2BAA2B;EAC3B,SAAS,IAAI;EACb,YAAY,UAA8B;GACxC,IAAI,MAAM,QAAQ,SAAS,MAAM,QAAQ,UAAU;GACnD,MAAM,gBAAgB;GAItB,MAAM,OAAO,eAAe,MAAM;GAClC,IAAI,MAAM;IACR,MAAM,UAAU,MAAM,KACpB,MAAM,cACH,QAAQ,4BAA4B,CAAC,EACpC,iBAA8B,2BAA2B,KAAK,CAAC,CACrE;IACA,MAAM,OAAO,QAAQ,QAAQ,QAAQ,MAAM,aAA4B,IAAI;IAC3E,IAAI,MAAM;KACR,MAAM,eAAe;KACrB,KAAK,MAAM;KACX;IACF;GACF;GAEA,MAAM,OAAO,aAAa,MAAM;GAChC,MAAM,QAAQ,QAAQ,IA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