@ankhorage/zora 14.0.0 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +176 -6
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts +5 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.d.ts.map +1 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js +91 -0
- package/dist/features/app-bar/adapters/inbound/AppBar.js.map +1 -0
- package/dist/{components/app-bar/meta.d.ts → features/app-bar/appBarMeta.d.ts} +1 -1
- package/dist/features/app-bar/appBarMeta.d.ts.map +1 -0
- package/dist/{components/app-bar/meta.js → features/app-bar/appBarMeta.js} +1 -1
- package/dist/features/app-bar/appBarMeta.js.map +1 -0
- package/dist/features/app-bar/public.d.ts +3 -0
- package/dist/features/app-bar/public.d.ts.map +1 -0
- package/dist/features/app-bar/public.js +2 -0
- package/dist/features/app-bar/public.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/settings-layout/SettingsLayout.d.ts +0 -2
- package/dist/layout/settings-layout/SettingsLayout.d.ts.map +1 -1
- package/dist/layout/settings-layout/SettingsLayout.js +1 -3
- package/dist/layout/settings-layout/SettingsLayout.js.map +1 -1
- package/dist/metadata/componentMeta.js +1 -1
- package/dist/metadata/componentMeta.js.map +1 -1
- package/dist/patterns/reader/ReaderSurface.js +1 -1
- package/dist/patterns/reader/ReaderSurface.js.map +1 -1
- package/dist/registry.js +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/{components/app-bar/types.d.ts → types/app-bar.d.ts} +2 -2
- package/dist/types/app-bar.d.ts.map +1 -0
- package/dist/types/app-bar.js +2 -0
- package/dist/types/app-bar.js.map +1 -0
- package/package.json +1 -1
- package/src/features/app-bar/adapters/inbound/AppBar.tsx +176 -0
- package/src/features/app-bar/public.ts +2 -0
- package/src/index.ts +2 -2
- package/src/interactionPolicy.test.ts +7 -3
- package/src/layout/settings-layout/SettingsLayout.tsx +1 -3
- package/src/metadata/componentMeta.ts +1 -1
- package/src/patterns/reader/ReaderSurface.tsx +1 -1
- package/src/registry.ts +1 -1
- package/src/theme/themeScopeStructure.test.ts +2 -2
- package/src/{components/app-bar/types.ts → types/app-bar.ts} +1 -1
- package/dist/components/app-bar/AppBar.d.ts +0 -7
- package/dist/components/app-bar/AppBar.d.ts.map +0 -1
- package/dist/components/app-bar/AppBar.js +0 -67
- package/dist/components/app-bar/AppBar.js.map +0 -1
- package/dist/components/app-bar/index.d.ts +0 -3
- package/dist/components/app-bar/index.d.ts.map +0 -1
- package/dist/components/app-bar/index.js +0 -3
- package/dist/components/app-bar/index.js.map +0 -1
- package/dist/components/app-bar/meta.d.ts.map +0 -1
- package/dist/components/app-bar/meta.js.map +0 -1
- package/dist/components/app-bar/types.d.ts.map +0 -1
- package/dist/components/app-bar/types.js +0 -2
- package/dist/components/app-bar/types.js.map +0 -1
- package/src/components/app-bar/AppBar.tsx +0 -140
- package/src/components/app-bar/index.ts +0 -2
- /package/src/{components/app-bar/meta.ts → features/app-bar/appBarMeta.ts} +0 -0
package/src/registry.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { InteractionPolicyProps } from '@ankhorage/surface';
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
|
|
4
|
-
import { AppBar } from './components/app-bar';
|
|
5
4
|
import { Breadcrumbs } from './components/breadcrumbs';
|
|
6
5
|
import { DropdownMenu, Menu } from './components/menu';
|
|
7
6
|
import { Modal } from './components/modal';
|
|
@@ -13,6 +12,7 @@ import { Tabs } from './components/tabs';
|
|
|
13
12
|
import { Toolbar, ToolbarAction } from './components/toolbar';
|
|
14
13
|
import { Accordion, AccordionItem } from './features/accordion/public';
|
|
15
14
|
import { ActivityIndicator } from './features/activity-indicator/public';
|
|
15
|
+
import { AppBar } from './features/app-bar/public';
|
|
16
16
|
import {
|
|
17
17
|
ForgotPasswordForm,
|
|
18
18
|
OAuthProviderButton,
|
|
@@ -56,7 +56,7 @@ const scopedComponentFiles = [
|
|
|
56
56
|
join(srcDir, 'features', 'list', 'adapters', 'inbound', 'FlatList.tsx'),
|
|
57
57
|
join(srcDir, 'features', 'list', 'adapters', 'inbound', 'SectionList.tsx'),
|
|
58
58
|
join(srcDir, 'features', 'bottom-sheet', 'adapters', 'inbound', 'BottomSheet.tsx'),
|
|
59
|
-
join(srcDir, '
|
|
59
|
+
join(srcDir, 'features', 'app-bar', 'adapters', 'inbound', 'AppBar.tsx'),
|
|
60
60
|
join(srcDir, 'features', 'accordion', 'adapters', 'inbound', 'Accordion.tsx'),
|
|
61
61
|
join(srcDir, 'features', 'accordion', 'adapters', 'inbound', 'AccordionItem.tsx'),
|
|
62
62
|
join(srcDir, 'features', 'badge', 'adapters', 'inbound', 'Badge.tsx'),
|
|
@@ -134,7 +134,7 @@ const scopedComponentFiles = [
|
|
|
134
134
|
] as const;
|
|
135
135
|
|
|
136
136
|
const scopedPropTypeFiles = [
|
|
137
|
-
join(srcDir, '
|
|
137
|
+
join(srcDir, 'types', 'app-bar.ts'),
|
|
138
138
|
join(srcDir, 'types', 'accordion.ts'),
|
|
139
139
|
join(srcDir, 'types', 'badge.ts'),
|
|
140
140
|
join(srcDir, 'types', 'button.ts'),
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { AppBarProps } from './types';
|
|
3
|
-
/***
|
|
4
|
-
* Renders a top app bar with title/subtitle and optional leading/trailing actions.
|
|
5
|
-
*/
|
|
6
|
-
export declare const AppBar: (props: AppBarProps) => React.ReactElement | null;
|
|
7
|
-
//# sourceMappingURL=AppBar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppBar.d.ts","sourceRoot":"","sources":["../../../src/components/app-bar/AppBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,EAAoC,WAAW,EAAE,MAAM,SAAS,CAAC;AA8H7E;;GAEG;AACH,eAAO,MAAM,MAAM,mDAAkC,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { AppBar as SurfaceAppBar } from '@ankhorage/surface';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { IconButton } from '../../features/button/public';
|
|
4
|
-
import { Box, Stack } from '../../features/layout/public';
|
|
5
|
-
import { Heading } from '../../features/typography/public';
|
|
6
|
-
import { Text } from '../../features/typography/public';
|
|
7
|
-
import { Inline } from '../../foundation';
|
|
8
|
-
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
9
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
10
|
-
const DEFAULT_CANCEL_ICON = { name: 'close-outline' };
|
|
11
|
-
const DEFAULT_OVERFLOW_ICON = { name: 'ellipsis-vertical' };
|
|
12
|
-
function resolveMode(mode) {
|
|
13
|
-
return mode ?? { type: 'default' };
|
|
14
|
-
}
|
|
15
|
-
function resolveSelectionLabel({ count, label }) {
|
|
16
|
-
if (count === undefined) {
|
|
17
|
-
return label;
|
|
18
|
-
}
|
|
19
|
-
return `${label} (${count})`;
|
|
20
|
-
}
|
|
21
|
-
function resolveOverflowLabel(overflow) {
|
|
22
|
-
return overflow.label ?? 'More options';
|
|
23
|
-
}
|
|
24
|
-
function resolveCancelLabel(mode) {
|
|
25
|
-
return mode.cancelLabel ?? 'Cancel selection';
|
|
26
|
-
}
|
|
27
|
-
function AppBarInner({ themeId: _themeId, mode: _mode, title, subtitle, leading, actions, overflow, appMode, children, safeAreaTop = true, divider = true, testID, interactionPolicy, }) {
|
|
28
|
-
const { theme } = useZoraTheme();
|
|
29
|
-
const resolvedMode = resolveMode(appMode);
|
|
30
|
-
const isSelectionMode = resolvedMode.type === 'selection';
|
|
31
|
-
const resolvedLeading = leading ??
|
|
32
|
-
(isSelectionMode ? (<IconButton icon={resolvedMode.cancelIcon ?? DEFAULT_CANCEL_ICON} interactionPolicy={interactionPolicy} label={resolveCancelLabel(resolvedMode)} variant="ghost" size="m" color="neutral" onPress={resolvedMode.onCancel}/>) : undefined);
|
|
33
|
-
const overflowButton = overflow?.onPress ? (<IconButton disabled={overflow.disabled} icon={overflow.icon ?? DEFAULT_OVERFLOW_ICON} interactionPolicy={interactionPolicy} label={resolveOverflowLabel(overflow)} variant="ghost" size="m" color="neutral" onPress={overflow.onPress}/>) : null;
|
|
34
|
-
const resolvedTrailing = actions || overflowButton ? (<Inline align="center" gap="s" wrap="nowrap">
|
|
35
|
-
{actions}
|
|
36
|
-
{overflowButton}
|
|
37
|
-
</Inline>) : undefined;
|
|
38
|
-
const resolvedCenter = (() => {
|
|
39
|
-
if (children !== undefined) {
|
|
40
|
-
return children;
|
|
41
|
-
}
|
|
42
|
-
if (isSelectionMode) {
|
|
43
|
-
return (<Text numberOfLines={1} emphasis="default" variant="label" weight="semiBold">
|
|
44
|
-
{resolveSelectionLabel(resolvedMode)}
|
|
45
|
-
</Text>);
|
|
46
|
-
}
|
|
47
|
-
if (title == null && subtitle == null) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return (<Stack gap="xs">
|
|
51
|
-
{title != null ? (<Heading ellipsizeMode="tail" level={3} numberOfLines={1} size="h5">
|
|
52
|
-
{title}
|
|
53
|
-
</Heading>) : null}
|
|
54
|
-
{subtitle != null ? (<Text ellipsizeMode="tail" numberOfLines={1} emphasis="muted" variant="bodySmall">
|
|
55
|
-
{subtitle}
|
|
56
|
-
</Text>) : null}
|
|
57
|
-
</Stack>);
|
|
58
|
-
})();
|
|
59
|
-
return (<SurfaceAppBar bg={isSelectionMode ? theme.semantics.action.primary.softBg : undefined} divider={divider} leading={resolvedLeading} safeAreaTop={safeAreaTop} testID={testID} trailing={resolvedTrailing}>
|
|
60
|
-
{resolvedCenter ? <Box style={{ minWidth: 0 }}>{resolvedCenter}</Box> : null}
|
|
61
|
-
</SurfaceAppBar>);
|
|
62
|
-
}
|
|
63
|
-
/***
|
|
64
|
-
* Renders a top app bar with title/subtitle and optional leading/trailing actions.
|
|
65
|
-
*/
|
|
66
|
-
export const AppBar = withZoraThemeScope(AppBarInner);
|
|
67
|
-
//# sourceMappingURL=AppBar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppBar.js","sourceRoot":"","sources":["../../../src/components/app-bar/AppBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAuB,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,eAAe,EAA2B,CAAC;AAC/E,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAA2B,CAAC;AAErF,SAAS,WAAW,CAAC,IAA4B;IAC/C,OAAO,IAAI,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACrC,CAAC;AAED,SAAS,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAqC;IAChF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,GAAG,KAAK,KAAK,KAAK,GAAG,CAAC;AAC/B,CAAC;AAED,SAAS,oBAAoB,CAAC,QAA8B;IAC1D,O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CAAC,CACX,CAAC,CAAC,CAAC,IAAI,CACR;QAAA,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,CAClB,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAC/E;YAAA,CAAC,QAAQ,CACX;UAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACV;MAAA,EAAE,KAAK,CAAC,CACT,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,CACL,CAAC,aAAa,CACZ,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CACxE,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,OAAO,CAAC,CAAC,eAAe,CAAC,CACzB,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAE3B;MAAA,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9E;IAAA,EAAE,aAAa,CAAC,CACjB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { AppBar as SurfaceAppBar, type ButtonIconSpec } from '@ankhorage/surface';\nimport React from 'react';\n\nimport { IconButton } from '../../features/button/public';\nimport { Box, Stack } from '../../features/layout/public';\nimport { Heading } from '../../features/typography/public';\nimport { Text } from '../../features/typography/public';\nimport { Inline } from '../../foundation';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport type { AppBarMode, AppBarOverflowAction, AppBarProps } from './types';\n\nconst DEFAULT_CANCEL_ICON = { name: 'close-outline' } satisfies ButtonIconSpec;\nconst DEFAULT_OVERFLOW_ICON = { name: 'ellipsis-vertical' } satisfies ButtonIconSpec;\n\nfunction resolveMode(mode: AppBarMode | undefined): AppBarMode {\n return mode ?? { type: 'default' };\n}\n\nfunction resolveSelectionLabel({ count, label }: { count?: number; label: string }): string {\n if (count === undefined) {\n return label;\n }\n\n return `${label} (${count})`;\n}\n\nfunction resolveOverflowLabel(overflow: AppBarOverflowAction): string {\n return overflow.label ?? 'More options';\n}\n\nfunction resolveCancelLabel(mode: Extract<AppBarMode, { type: 'selection' }>): string {\n return mode.cancelLabel ?? 'Cancel selection';\n}\n\nfunction AppBarInner({\n themeId: _themeId,\n mode: _mode,\n title,\n subtitle,\n leading,\n actions,\n overflow,\n appMode,\n children,\n safeAreaTop = true,\n divider = true,\n testID,\n interactionPolicy,\n}: AppBarProps) {\n const { theme } = useZoraTheme();\n const resolvedMode = resolveMode(appMode);\n const isSelectionMode = resolvedMode.type === 'selection';\n\n const resolvedLeading =\n leading ??\n (isSelectionMode ? (\n <IconButton\n icon={resolvedMode.cancelIcon ?? DEFAULT_CANCEL_ICON}\n interactionPolicy={interactionPolicy}\n label={resolveCancelLabel(resolvedMode)}\n variant=\"ghost\"\n size=\"m\"\n color=\"neutral\"\n onPress={resolvedMode.onCancel}\n />\n ) : undefined);\n\n const overflowButton = overflow?.onPress ? (\n <IconButton\n disabled={overflow.disabled}\n icon={overflow.icon ?? DEFAULT_OVERFLOW_ICON}\n interactionPolicy={interactionPolicy}\n label={resolveOverflowLabel(overflow)}\n variant=\"ghost\"\n size=\"m\"\n color=\"neutral\"\n onPress={overflow.onPress}\n />\n ) : null;\n\n const resolvedTrailing =\n actions || overflowButton ? (\n <Inline align=\"center\" gap=\"s\" wrap=\"nowrap\">\n {actions}\n {overflowButton}\n </Inline>\n ) : undefined;\n\n const resolvedCenter = (() => {\n if (children !== undefined) {\n return children;\n }\n\n if (isSelectionMode) {\n return (\n <Text numberOfLines={1} emphasis=\"default\" variant=\"label\" weight=\"semiBold\">\n {resolveSelectionLabel(resolvedMode)}\n </Text>\n );\n }\n\n if (title == null && subtitle == null) {\n return null;\n }\n\n return (\n <Stack gap=\"xs\">\n {title != null ? (\n <Heading ellipsizeMode=\"tail\" level={3} numberOfLines={1} size=\"h5\">\n {title}\n </Heading>\n ) : null}\n {subtitle != null ? (\n <Text ellipsizeMode=\"tail\" numberOfLines={1} emphasis=\"muted\" variant=\"bodySmall\">\n {subtitle}\n </Text>\n ) : null}\n </Stack>\n );\n })();\n\n return (\n <SurfaceAppBar\n bg={isSelectionMode ? theme.semantics.action.primary.softBg : undefined}\n divider={divider}\n leading={resolvedLeading}\n safeAreaTop={safeAreaTop}\n testID={testID}\n trailing={resolvedTrailing}\n >\n {resolvedCenter ? <Box style={{ minWidth: 0 }}>{resolvedCenter}</Box> : null}\n </SurfaceAppBar>\n );\n}\n\n/***\n * Renders a top app bar with title/subtitle and optional leading/trailing actions.\n */\nexport const AppBar = withZoraThemeScope(AppBarInner);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/app-bar/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/app-bar/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC","sourcesContent":["export * from './AppBar';\nexport * from './types';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/components/app-bar/meta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;CAOe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/components/app-bar/meta.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,WAAW;IACrB,kBAAkB,EAAE,KAAK;IACzB,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,yEAAyE;IAC/E,KAAK,EAAE,EAAE;CAC2B,CAAC","sourcesContent":["import type { ZoraComponentMeta } from '../../metadata';\n\nexport const appBarMeta = {\n name: 'AppBar',\n category: 'component',\n directManifestNode: false,\n allowedChildren: [],\n note: 'Application chrome component; not represented as a manifest node in v1.',\n props: {},\n} as const satisfies ZoraComponentMeta;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/app-bar/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/app-bar/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\nexport type AppBarMode =\n | {\n type: 'default';\n }\n | {\n type: 'selection';\n label: string;\n count?: number;\n onCancel: () => void;\n cancelLabel?: string;\n cancelIcon?: ButtonIconSpec;\n };\n\nexport interface AppBarOverflowAction {\n onPress: () => void;\n label?: string;\n icon?: ButtonIconSpec;\n disabled?: boolean;\n}\n\nexport interface AppBarProps extends ZoraBaseProps {\n title?: React.ReactNode;\n subtitle?: React.ReactNode;\n leading?: React.ReactNode;\n actions?: React.ReactNode;\n overflow?: AppBarOverflowAction;\n appMode?: AppBarMode;\n children?: React.ReactNode;\n safeAreaTop?: boolean;\n divider?: boolean;\n}\n"]}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { AppBar as SurfaceAppBar, type ButtonIconSpec } from '@ankhorage/surface';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { IconButton } from '../../features/button/public';
|
|
5
|
-
import { Box, Stack } from '../../features/layout/public';
|
|
6
|
-
import { Heading } from '../../features/typography/public';
|
|
7
|
-
import { Text } from '../../features/typography/public';
|
|
8
|
-
import { Inline } from '../../foundation';
|
|
9
|
-
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
10
|
-
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
11
|
-
import type { AppBarMode, AppBarOverflowAction, AppBarProps } from './types';
|
|
12
|
-
|
|
13
|
-
const DEFAULT_CANCEL_ICON = { name: 'close-outline' } satisfies ButtonIconSpec;
|
|
14
|
-
const DEFAULT_OVERFLOW_ICON = { name: 'ellipsis-vertical' } satisfies ButtonIconSpec;
|
|
15
|
-
|
|
16
|
-
function resolveMode(mode: AppBarMode | undefined): AppBarMode {
|
|
17
|
-
return mode ?? { type: 'default' };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function resolveSelectionLabel({ count, label }: { count?: number; label: string }): string {
|
|
21
|
-
if (count === undefined) {
|
|
22
|
-
return label;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return `${label} (${count})`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function resolveOverflowLabel(overflow: AppBarOverflowAction): string {
|
|
29
|
-
return overflow.label ?? 'More options';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function resolveCancelLabel(mode: Extract<AppBarMode, { type: 'selection' }>): string {
|
|
33
|
-
return mode.cancelLabel ?? 'Cancel selection';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function AppBarInner({
|
|
37
|
-
themeId: _themeId,
|
|
38
|
-
mode: _mode,
|
|
39
|
-
title,
|
|
40
|
-
subtitle,
|
|
41
|
-
leading,
|
|
42
|
-
actions,
|
|
43
|
-
overflow,
|
|
44
|
-
appMode,
|
|
45
|
-
children,
|
|
46
|
-
safeAreaTop = true,
|
|
47
|
-
divider = true,
|
|
48
|
-
testID,
|
|
49
|
-
interactionPolicy,
|
|
50
|
-
}: AppBarProps) {
|
|
51
|
-
const { theme } = useZoraTheme();
|
|
52
|
-
const resolvedMode = resolveMode(appMode);
|
|
53
|
-
const isSelectionMode = resolvedMode.type === 'selection';
|
|
54
|
-
|
|
55
|
-
const resolvedLeading =
|
|
56
|
-
leading ??
|
|
57
|
-
(isSelectionMode ? (
|
|
58
|
-
<IconButton
|
|
59
|
-
icon={resolvedMode.cancelIcon ?? DEFAULT_CANCEL_ICON}
|
|
60
|
-
interactionPolicy={interactionPolicy}
|
|
61
|
-
label={resolveCancelLabel(resolvedMode)}
|
|
62
|
-
variant="ghost"
|
|
63
|
-
size="m"
|
|
64
|
-
color="neutral"
|
|
65
|
-
onPress={resolvedMode.onCancel}
|
|
66
|
-
/>
|
|
67
|
-
) : undefined);
|
|
68
|
-
|
|
69
|
-
const overflowButton = overflow?.onPress ? (
|
|
70
|
-
<IconButton
|
|
71
|
-
disabled={overflow.disabled}
|
|
72
|
-
icon={overflow.icon ?? DEFAULT_OVERFLOW_ICON}
|
|
73
|
-
interactionPolicy={interactionPolicy}
|
|
74
|
-
label={resolveOverflowLabel(overflow)}
|
|
75
|
-
variant="ghost"
|
|
76
|
-
size="m"
|
|
77
|
-
color="neutral"
|
|
78
|
-
onPress={overflow.onPress}
|
|
79
|
-
/>
|
|
80
|
-
) : null;
|
|
81
|
-
|
|
82
|
-
const resolvedTrailing =
|
|
83
|
-
actions || overflowButton ? (
|
|
84
|
-
<Inline align="center" gap="s" wrap="nowrap">
|
|
85
|
-
{actions}
|
|
86
|
-
{overflowButton}
|
|
87
|
-
</Inline>
|
|
88
|
-
) : undefined;
|
|
89
|
-
|
|
90
|
-
const resolvedCenter = (() => {
|
|
91
|
-
if (children !== undefined) {
|
|
92
|
-
return children;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (isSelectionMode) {
|
|
96
|
-
return (
|
|
97
|
-
<Text numberOfLines={1} emphasis="default" variant="label" weight="semiBold">
|
|
98
|
-
{resolveSelectionLabel(resolvedMode)}
|
|
99
|
-
</Text>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (title == null && subtitle == null) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
<Stack gap="xs">
|
|
109
|
-
{title != null ? (
|
|
110
|
-
<Heading ellipsizeMode="tail" level={3} numberOfLines={1} size="h5">
|
|
111
|
-
{title}
|
|
112
|
-
</Heading>
|
|
113
|
-
) : null}
|
|
114
|
-
{subtitle != null ? (
|
|
115
|
-
<Text ellipsizeMode="tail" numberOfLines={1} emphasis="muted" variant="bodySmall">
|
|
116
|
-
{subtitle}
|
|
117
|
-
</Text>
|
|
118
|
-
) : null}
|
|
119
|
-
</Stack>
|
|
120
|
-
);
|
|
121
|
-
})();
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<SurfaceAppBar
|
|
125
|
-
bg={isSelectionMode ? theme.semantics.action.primary.softBg : undefined}
|
|
126
|
-
divider={divider}
|
|
127
|
-
leading={resolvedLeading}
|
|
128
|
-
safeAreaTop={safeAreaTop}
|
|
129
|
-
testID={testID}
|
|
130
|
-
trailing={resolvedTrailing}
|
|
131
|
-
>
|
|
132
|
-
{resolvedCenter ? <Box style={{ minWidth: 0 }}>{resolvedCenter}</Box> : null}
|
|
133
|
-
</SurfaceAppBar>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/***
|
|
138
|
-
* Renders a top app bar with title/subtitle and optional leading/trailing actions.
|
|
139
|
-
*/
|
|
140
|
-
export const AppBar = withZoraThemeScope(AppBarInner);
|
|
File without changes
|