@cratis/scene.blueprint.default 4.31.0 → 4.32.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/ComponentName.ts +12 -0
- package/defaultBlueprint.ts +2 -1
- package/defaultBlueprintComponentMetadata.ts +2 -0
- package/defaultBlueprintComponents.ts +5 -0
- package/dist/cjs/ComponentName.js +4 -0
- package/dist/cjs/ComponentName.js.map +1 -1
- package/dist/cjs/defaultBlueprint.js +9 -5
- package/dist/cjs/defaultBlueprint.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponentMetadata.js +8 -0
- package/dist/cjs/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponents.js +13 -1
- package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
- package/dist/cjs/foundation/ActionButton.js +33 -0
- package/dist/cjs/foundation/ActionButton.js.map +1 -0
- package/dist/cjs/foundation/ComponentState.js +42 -0
- package/dist/cjs/foundation/ComponentState.js.map +1 -0
- package/dist/cjs/foundation/EmptyState.js +31 -0
- package/dist/cjs/foundation/EmptyState.js.map +1 -0
- package/dist/cjs/foundation/FoundationIcon.js +58 -0
- package/dist/cjs/foundation/FoundationIcon.js.map +1 -0
- package/dist/cjs/foundation/FoundationStates.js +62 -0
- package/dist/cjs/foundation/FoundationStates.js.map +1 -0
- package/dist/cjs/foundation/PermissionRule.js +22 -0
- package/dist/cjs/foundation/PermissionRule.js.map +1 -0
- package/dist/cjs/foundation/StatCard.js +61 -0
- package/dist/cjs/foundation/StatCard.js.map +1 -0
- package/dist/cjs/foundation/StateFrame.js +200 -0
- package/dist/cjs/foundation/StateFrame.js.map +1 -0
- package/dist/cjs/foundation/StatusChip.js +64 -0
- package/dist/cjs/foundation/StatusChip.js.map +1 -0
- package/dist/cjs/foundation/TrendChip.js +93 -0
- package/dist/cjs/foundation/TrendChip.js.map +1 -0
- package/dist/cjs/foundation/formatting.js +85 -0
- package/dist/cjs/foundation/formatting.js.map +1 -0
- package/dist/cjs/foundation/foundationComponentMetadata.js +41 -0
- package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -0
- package/dist/cjs/foundation/foundationDescriptors.js +232 -0
- package/dist/cjs/foundation/foundationDescriptors.js.map +1 -0
- package/dist/cjs/foundation/foundationSamples.js +71 -0
- package/dist/cjs/foundation/foundationSamples.js.map +1 -0
- package/dist/cjs/foundation/foundationStrings.js +105 -0
- package/dist/cjs/foundation/foundationStrings.js.map +1 -0
- package/dist/cjs/index.js +52 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/themes/dark.js +9 -1
- package/dist/cjs/themes/dark.js.map +1 -1
- package/dist/cjs/themes/light.js +10 -2
- package/dist/cjs/themes/light.js.map +1 -1
- package/dist/esm/ComponentName.d.ts +5 -1
- package/dist/esm/ComponentName.d.ts.map +1 -1
- package/dist/esm/ComponentName.js +4 -0
- package/dist/esm/ComponentName.js.map +1 -1
- package/dist/esm/defaultBlueprint.d.ts.map +1 -1
- package/dist/esm/defaultBlueprint.js +9 -5
- package/dist/esm/defaultBlueprint.js.map +1 -1
- package/dist/esm/defaultBlueprintComponentMetadata.d.ts.map +1 -1
- package/dist/esm/defaultBlueprintComponentMetadata.js +8 -0
- package/dist/esm/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
- package/dist/esm/defaultBlueprintComponents.js +13 -1
- package/dist/esm/defaultBlueprintComponents.js.map +1 -1
- package/dist/esm/foundation/ActionButton.d.ts +13 -0
- package/dist/esm/foundation/ActionButton.d.ts.map +1 -0
- package/dist/esm/foundation/ActionButton.js +31 -0
- package/dist/esm/foundation/ActionButton.js.map +1 -0
- package/dist/esm/foundation/ComponentState.d.ts +12 -0
- package/dist/esm/foundation/ComponentState.d.ts.map +1 -0
- package/dist/esm/foundation/ComponentState.js +38 -0
- package/dist/esm/foundation/ComponentState.js.map +1 -0
- package/dist/esm/foundation/EmptyState.d.ts +3 -0
- package/dist/esm/foundation/EmptyState.d.ts.map +1 -0
- package/dist/esm/foundation/EmptyState.js +29 -0
- package/dist/esm/foundation/EmptyState.js.map +1 -0
- package/dist/esm/foundation/Foundation.stories.d.ts +21 -0
- package/dist/esm/foundation/Foundation.stories.d.ts.map +1 -0
- package/dist/esm/foundation/Foundation.stories.js +18 -0
- package/dist/esm/foundation/Foundation.stories.js.map +1 -0
- package/dist/esm/foundation/FoundationIcon.d.ts +7 -0
- package/dist/esm/foundation/FoundationIcon.d.ts.map +1 -0
- package/dist/esm/foundation/FoundationIcon.js +55 -0
- package/dist/esm/foundation/FoundationIcon.js.map +1 -0
- package/dist/esm/foundation/FoundationStates.d.ts +8 -0
- package/dist/esm/foundation/FoundationStates.d.ts.map +1 -0
- package/dist/esm/foundation/FoundationStates.js +60 -0
- package/dist/esm/foundation/FoundationStates.js.map +1 -0
- package/dist/esm/foundation/PermissionRule.d.ts +8 -0
- package/dist/esm/foundation/PermissionRule.d.ts.map +1 -0
- package/dist/esm/foundation/PermissionRule.js +19 -0
- package/dist/esm/foundation/PermissionRule.js.map +1 -0
- package/dist/esm/foundation/StatCard.d.ts +3 -0
- package/dist/esm/foundation/StatCard.d.ts.map +1 -0
- package/dist/esm/foundation/StatCard.js +59 -0
- package/dist/esm/foundation/StatCard.js.map +1 -0
- package/dist/esm/foundation/StateFrame.d.ts +15 -0
- package/dist/esm/foundation/StateFrame.d.ts.map +1 -0
- package/dist/esm/foundation/StateFrame.js +197 -0
- package/dist/esm/foundation/StateFrame.js.map +1 -0
- package/dist/esm/foundation/StatusChip.d.ts +13 -0
- package/dist/esm/foundation/StatusChip.d.ts.map +1 -0
- package/dist/esm/foundation/StatusChip.js +59 -0
- package/dist/esm/foundation/StatusChip.js.map +1 -0
- package/dist/esm/foundation/TrendChip.d.ts +18 -0
- package/dist/esm/foundation/TrendChip.d.ts.map +1 -0
- package/dist/esm/foundation/TrendChip.js +88 -0
- package/dist/esm/foundation/TrendChip.js.map +1 -0
- package/dist/esm/foundation/formatting.d.ts +13 -0
- package/dist/esm/foundation/formatting.d.ts.map +1 -0
- package/dist/esm/foundation/formatting.js +78 -0
- package/dist/esm/foundation/formatting.js.map +1 -0
- package/dist/esm/foundation/foundationComponentMetadata.d.ts +3 -0
- package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -0
- package/dist/esm/foundation/foundationComponentMetadata.js +39 -0
- package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -0
- package/dist/esm/foundation/foundationDescriptors.d.ts +6 -0
- package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -0
- package/dist/esm/foundation/foundationDescriptors.js +227 -0
- package/dist/esm/foundation/foundationDescriptors.js.map +1 -0
- package/dist/esm/foundation/foundationSamples.d.ts +10 -0
- package/dist/esm/foundation/foundationSamples.d.ts.map +1 -0
- package/dist/esm/foundation/foundationSamples.js +68 -0
- package/dist/esm/foundation/foundationSamples.js.map +1 -0
- package/dist/esm/foundation/foundationStrings.d.ts +78 -0
- package/dist/esm/foundation/foundationStrings.d.ts.map +1 -0
- package/dist/esm/foundation/foundationStrings.js +101 -0
- package/dist/esm/foundation/foundationStrings.js.map +1 -0
- package/dist/esm/foundation/index.d.ts +16 -0
- package/dist/esm/foundation/index.d.ts.map +1 -0
- package/dist/esm/foundation/index.js +16 -0
- package/dist/esm/foundation/index.js.map +1 -0
- package/dist/esm/gallery/widgets.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/themes/dark.d.ts.map +1 -1
- package/dist/esm/themes/dark.js +9 -1
- package/dist/esm/themes/dark.js.map +1 -1
- package/dist/esm/themes/light.d.ts.map +1 -1
- package/dist/esm/themes/light.js +10 -2
- package/dist/esm/themes/light.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/foundation/ActionButton.tsx +39 -0
- package/foundation/ComponentState.ts +53 -0
- package/foundation/EmptyState.tsx +22 -0
- package/foundation/Foundation.stories.tsx +30 -0
- package/foundation/FoundationIcon.tsx +49 -0
- package/foundation/FoundationStates.tsx +46 -0
- package/foundation/PermissionRule.ts +26 -0
- package/foundation/StatCard.tsx +44 -0
- package/foundation/StateFrame.tsx +126 -0
- package/foundation/StatusChip.tsx +51 -0
- package/foundation/TrendChip.tsx +78 -0
- package/foundation/formatting.ts +69 -0
- package/foundation/foundationComponentMetadata.ts +17 -0
- package/foundation/foundationDescriptors.ts +119 -0
- package/foundation/foundationSamples.ts +44 -0
- package/foundation/foundationStrings.ts +112 -0
- package/foundation/index.ts +18 -0
- package/index.ts +1 -0
- package/package.json +9 -8
- package/shell/layout.css +241 -0
- package/themes/dark.ts +8 -0
- package/themes/light.ts +9 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
const paths = {
|
|
6
|
+
check: 'M5 13l4 4L19 7',
|
|
7
|
+
close: 'M6 6l12 12M18 6L6 18',
|
|
8
|
+
'arrow-up': 'M12 19V5M5 12l7-7 7 7',
|
|
9
|
+
'arrow-down': 'M12 5v14M5 12l7 7 7-7',
|
|
10
|
+
minus: 'M5 12h14',
|
|
11
|
+
alert: 'M12 8v5M12 16.5v.5M10.3 3.9L2.5 17.5A2 2 0 004.2 20.5h15.6a2 2 0 001.7-3L13.7 3.9a2 2 0 00-3.4 0z',
|
|
12
|
+
info: 'M12 11v6M12 7.5v.5M12 21a9 9 0 100-18 9 9 0 000 18z',
|
|
13
|
+
lock: 'M7 11V8a5 5 0 0110 0v3M6 11h12a1 1 0 011 1v8a1 1 0 01-1 1H6a1 1 0 01-1-1v-8a1 1 0 011-1z',
|
|
14
|
+
clock: 'M12 7v5l3 2M12 21a9 9 0 100-18 9 9 0 000 18z',
|
|
15
|
+
inbox: 'M3 13l3-8h12l3 8M3 13v6a1 1 0 001 1h16a1 1 0 001-1v-6M3 13h5l1 3h6l1-3h5',
|
|
16
|
+
refresh: 'M20 11a8 8 0 10-2.3 6.3M20 4v7h-7',
|
|
17
|
+
plus: 'M12 5v14M5 12h14',
|
|
18
|
+
'chevron-right': 'M9 5l7 7-7 7',
|
|
19
|
+
'chevron-down': 'M5 9l7 7 7-7',
|
|
20
|
+
upload: 'M12 16V4M7 9l5-5 5 5M4 17v2a1 1 0 001 1h14a1 1 0 001-1v-2',
|
|
21
|
+
file: 'M14 3H7a1 1 0 00-1 1v16a1 1 0 001 1h10a1 1 0 001-1V7l-4-4zM14 3v4h4',
|
|
22
|
+
user: 'M12 12a4 4 0 100-8 4 4 0 000 8zM4 21a8 8 0 0116 0',
|
|
23
|
+
columns: 'M4 5h16v14H4zM9.5 5v14M14.5 5v14',
|
|
24
|
+
filter: 'M4 5h16l-6 8v6l-4-2v-4L4 5z',
|
|
25
|
+
star: 'M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9L12 3z',
|
|
26
|
+
circle: 'M12 20a8 8 0 100-16 8 8 0 000 16z'
|
|
27
|
+
};
|
|
28
|
+
/** Whether a name is one of the icons drawn here. */ function isFoundationIcon(name) {
|
|
29
|
+
return name in paths;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One icon. It is decorative unless given a label: the meaning an icon carries is always repeated in text, so no status is
|
|
33
|
+
* conveyed by color or shape alone (WCAG 1.4.1).
|
|
34
|
+
*/ function FoundationIcon({ name, label }) {
|
|
35
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
36
|
+
className: "foundation-icon",
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
width: "1em",
|
|
39
|
+
height: "1em",
|
|
40
|
+
fill: "none",
|
|
41
|
+
stroke: "currentColor",
|
|
42
|
+
strokeWidth: "2",
|
|
43
|
+
strokeLinecap: "round",
|
|
44
|
+
strokeLinejoin: "round",
|
|
45
|
+
"aria-hidden": label ? undefined : true,
|
|
46
|
+
role: label ? 'img' : undefined,
|
|
47
|
+
"aria-label": label,
|
|
48
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
49
|
+
d: paths[name]
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { FoundationIcon, isFoundationIcon };
|
|
55
|
+
//# sourceMappingURL=FoundationIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundationIcon.js","sources":["../../../foundation/FoundationIcon.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** The icons the foundation components draw themselves, so none of them depends on an icon font being loaded. */\nexport type FoundationIconName =\n | 'check' | 'close' | 'arrow-up' | 'arrow-down' | 'minus' | 'alert' | 'info' | 'lock' | 'clock' | 'inbox' | 'refresh'\n | 'plus' | 'chevron-right' | 'chevron-down' | 'upload' | 'file' | 'user' | 'columns' | 'filter' | 'star' | 'circle';\n\nconst paths: Record<FoundationIconName, string> = {\n check: 'M5 13l4 4L19 7',\n close: 'M6 6l12 12M18 6L6 18',\n 'arrow-up': 'M12 19V5M5 12l7-7 7 7',\n 'arrow-down': 'M12 5v14M5 12l7 7 7-7',\n minus: 'M5 12h14',\n alert: 'M12 8v5M12 16.5v.5M10.3 3.9L2.5 17.5A2 2 0 004.2 20.5h15.6a2 2 0 001.7-3L13.7 3.9a2 2 0 00-3.4 0z',\n info: 'M12 11v6M12 7.5v.5M12 21a9 9 0 100-18 9 9 0 000 18z',\n lock: 'M7 11V8a5 5 0 0110 0v3M6 11h12a1 1 0 011 1v8a1 1 0 01-1 1H6a1 1 0 01-1-1v-8a1 1 0 011-1z',\n clock: 'M12 7v5l3 2M12 21a9 9 0 100-18 9 9 0 000 18z',\n inbox: 'M3 13l3-8h12l3 8M3 13v6a1 1 0 001 1h16a1 1 0 001-1v-6M3 13h5l1 3h6l1-3h5',\n refresh: 'M20 11a8 8 0 10-2.3 6.3M20 4v7h-7',\n plus: 'M12 5v14M5 12h14',\n 'chevron-right': 'M9 5l7 7-7 7',\n 'chevron-down': 'M5 9l7 7 7-7',\n upload: 'M12 16V4M7 9l5-5 5 5M4 17v2a1 1 0 001 1h14a1 1 0 001-1v-2',\n file: 'M14 3H7a1 1 0 00-1 1v16a1 1 0 001 1h10a1 1 0 001-1V7l-4-4zM14 3v4h4',\n user: 'M12 12a4 4 0 100-8 4 4 0 000 8zM4 21a8 8 0 0116 0',\n columns: 'M4 5h16v14H4zM9.5 5v14M14.5 5v14',\n filter: 'M4 5h16l-6 8v6l-4-2v-4L4 5z',\n star: 'M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9L12 3z',\n circle: 'M12 20a8 8 0 100-16 8 8 0 000 16z',\n};\n\n/** Whether a name is one of the icons drawn here. */\nexport function isFoundationIcon(name: string): name is FoundationIconName {\n return name in paths;\n}\n\n/**\n * One icon. It is decorative unless given a label: the meaning an icon carries is always repeated in text, so no status is\n * conveyed by color or shape alone (WCAG 1.4.1).\n */\nexport function FoundationIcon({ name, label }: { name: FoundationIconName; label?: string }) {\n return (\n <svg className='foundation-icon' viewBox='0 0 24 24' width='1em' height='1em' fill='none' stroke='currentColor' strokeWidth='2'\n strokeLinecap='round' strokeLinejoin='round' aria-hidden={label ? undefined : true} role={label ? 'img' : undefined} aria-label={label}>\n <path d={paths[name]} />\n </svg>\n );\n}\n"],"names":["paths","check","close","minus","alert","info","lock","clock","inbox","refresh","plus","upload","file","user","columns","filter","star","circle","isFoundationIcon","name","FoundationIcon","label","_jsx","svg","className","viewBox","width","height","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","aria-hidden","undefined","role","aria-label","path","d"],"mappings":";;AAAA;AACA;AAOA,MAAMA,KAAAA,GAA4C;IAC9CC,KAAAA,EAAO,gBAAA;IACPC,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;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface FoundationStatesProps {
|
|
2
|
+
component: string;
|
|
3
|
+
theme: 'light' | 'dark';
|
|
4
|
+
properties?: Record<string, unknown>;
|
|
5
|
+
rightToLeft?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function FoundationStates({ component, theme, properties, rightToLeft }: FoundationStatesProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FoundationStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundationStates.d.ts","sourceRoot":"","sources":["../../../foundation/FoundationStates.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,qBAAqB;IAElC,SAAS,EAAE,MAAM,CAAC;IAGlB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IAGxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGrC,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,qBAAqB,+BAiBpG"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { componentRegistryKey, SceneThemeProvider } from '@cratis/scene.react';
|
|
3
|
+
import { defaultBlueprintComponents } from '../defaultBlueprintComponents.js';
|
|
4
|
+
import { defaultBlueprintName } from '../packageName.js';
|
|
5
|
+
import { lightTheme } from '../themes/light.js';
|
|
6
|
+
import { darkTheme } from '../themes/dark.js';
|
|
7
|
+
import 'react';
|
|
8
|
+
import { componentStates, ComponentState } from './ComponentState.js';
|
|
9
|
+
import { foundationSamples, foundationElement } from './foundationSamples.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Every standard state of one foundation component side by side in one theme: the preview of spec Part B 6 ("all standard states
|
|
13
|
+
* implemented and previewable"), used by the stories and by the gallery.
|
|
14
|
+
*/ function FoundationStates({ component, theme, properties, rightToLeft }) {
|
|
15
|
+
const Component = defaultBlueprintComponents[componentRegistryKey(defaultBlueprintName, component)];
|
|
16
|
+
const sample = foundationSamples[component];
|
|
17
|
+
const states = sample?.stateful ? componentStates : [
|
|
18
|
+
ComponentState.Ready
|
|
19
|
+
];
|
|
20
|
+
return /*#__PURE__*/ jsx(SceneThemeProvider, {
|
|
21
|
+
theme: theme === 'dark' ? darkTheme : lightTheme,
|
|
22
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
23
|
+
dir: rightToLeft ? 'rtl' : 'ltr',
|
|
24
|
+
className: "foundation-states",
|
|
25
|
+
style: {
|
|
26
|
+
display: 'grid',
|
|
27
|
+
gap: '1rem',
|
|
28
|
+
padding: '1rem',
|
|
29
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(18rem, 1fr))',
|
|
30
|
+
background: 'var(--scene-surface-background)',
|
|
31
|
+
color: 'var(--scene-text-color)'
|
|
32
|
+
},
|
|
33
|
+
children: states.map((state)=>/*#__PURE__*/ jsxs("figure", {
|
|
34
|
+
style: {
|
|
35
|
+
margin: 0
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx("figcaption", {
|
|
39
|
+
style: {
|
|
40
|
+
fontSize: '0.75rem',
|
|
41
|
+
textTransform: 'uppercase',
|
|
42
|
+
marginBlockEnd: '0.5rem'
|
|
43
|
+
},
|
|
44
|
+
children: state
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ jsx(Component, {
|
|
47
|
+
element: foundationElement(component, {
|
|
48
|
+
...sample?.properties,
|
|
49
|
+
...properties
|
|
50
|
+
}, state === ComponentState.Ready ? undefined : state),
|
|
51
|
+
slots: {}
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}, state))
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { FoundationStates };
|
|
60
|
+
//# sourceMappingURL=FoundationStates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundationStates.js","sources":["../../../foundation/FoundationStates.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { componentRegistryKey, SceneThemeProvider } from '@cratis/scene.react';\nimport { defaultBlueprintComponents } from '../defaultBlueprintComponents';\nimport { defaultBlueprintName } from '../packageName';\nimport { darkTheme, lightTheme } from '../themes';\nimport { ComponentState, componentStates } from './ComponentState';\nimport { foundationElement, foundationSamples } from './foundationSamples';\n\nexport interface FoundationStatesProps {\n /** The bare name of the foundation component. */\n component: string;\n\n /** The theme the states are drawn in. */\n theme: 'light' | 'dark';\n\n /** Properties to lay over the sample, to show a variant. */\n properties?: Record<string, unknown>;\n\n /** Whether the page reads right to left. */\n rightToLeft?: boolean;\n}\n\n/**\n * Every standard state of one foundation component side by side in one theme: the preview of spec Part B 6 (\"all standard states\n * implemented and previewable\"), used by the stories and by the gallery.\n */\nexport function FoundationStates({ component, theme, properties, rightToLeft }: FoundationStatesProps) {\n const Component = defaultBlueprintComponents[componentRegistryKey(defaultBlueprintName, component)];\n const sample = foundationSamples[component];\n const states = sample?.stateful ? componentStates : [ComponentState.Ready];\n\n return (\n <SceneThemeProvider theme={theme === 'dark' ? darkTheme : lightTheme}>\n <div dir={rightToLeft ? 'rtl' : 'ltr'} className='foundation-states' style={{ display: 'grid', gap: '1rem', padding: '1rem', gridTemplateColumns: 'repeat(auto-fill, minmax(18rem, 1fr))', background: 'var(--scene-surface-background)', color: 'var(--scene-text-color)' }}>\n {states.map(state => (\n <figure key={state} style={{ margin: 0 }}>\n <figcaption style={{ fontSize: '0.75rem', textTransform: 'uppercase', marginBlockEnd: '0.5rem' }}>{state}</figcaption>\n <Component element={foundationElement(component, { ...sample?.properties, ...properties }, state === ComponentState.Ready ? undefined : state)} slots={{}} />\n </figure>\n ))}\n </div>\n </SceneThemeProvider>\n );\n}\n"],"names":["FoundationStates","component","theme","properties","rightToLeft","Component","defaultBlueprintComponents","componentRegistryKey","defaultBlueprintName","sample","foundationSamples","states","stateful","componentStates","ComponentState","Ready","_jsx","SceneThemeProvider","darkTheme","lightTheme","div","dir","className","style","display","gap","padding","gridTemplateColumns","background","color","map","state","_jsxs","figure","margin","figcaption","fontSize","textTransform","marginBlockEnd","element","foundationElement","undefined","slots"],"mappings":";;;;;;;;;;AAwBA;;;IAIO,SAASA,gBAAAA,CAAiB,EAAEC,SAAS,EAAEC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAyB,EAAA;AACjG,IAAA,MAAMC,SAAAA,GAAYC,0BAA0B,CAACC,oBAAAA,CAAqBC,sBAAsBP,SAAAA,CAAAA,CAAW;IACnG,MAAMQ,MAAAA,GAASC,iBAAiB,CAACT,SAAAA,CAAU;IAC3C,MAAMU,MAAAA,GAASF,MAAAA,EAAQG,QAAAA,GAAWC,eAAAA,GAAkB;AAACC,QAAAA,cAAAA,CAAeC;AAAM,KAAA;AAE1E,IAAA,qBACIC,GAAA,CAACC,kBAAAA,EAAAA;QAAmBf,KAAAA,EAAOA,KAAAA,KAAU,SAASgB,SAAAA,GAAYC,UAAAA;AACtD,QAAA,QAAA,gBAAAH,GAAA,CAACI,KAAAA,EAAAA;AAAIC,YAAAA,GAAAA,EAAKjB,cAAc,KAAA,GAAQ,KAAA;YAAOkB,SAAAA,EAAU,mBAAA;YAAoBC,KAAAA,EAAO;gBAAEC,OAAAA,EAAS,MAAA;gBAAQC,GAAAA,EAAK,MAAA;gBAAQC,OAAAA,EAAS,MAAA;gBAAQC,mBAAAA,EAAqB,uCAAA;gBAAyCC,UAAAA,EAAY,iCAAA;gBAAmCC,KAAAA,EAAO;AAA0B,aAAA;AACtQlB,YAAAA,QAAAA,EAAAA,MAAAA,CAAOmB,GAAG,CAACC,CAAAA,KAAAA,iBACRC,IAAA,CAACC,QAAAA,EAAAA;oBAAmBV,KAAAA,EAAO;wBAAEW,MAAAA,EAAQ;AAAE,qBAAA;;sCACnClB,GAAA,CAACmB,YAAAA,EAAAA;4BAAWZ,KAAAA,EAAO;gCAAEa,QAAAA,EAAU,SAAA;gCAAWC,aAAAA,EAAe,WAAA;gCAAaC,cAAAA,EAAgB;AAAS,6BAAA;AAAIP,4BAAAA,QAAAA,EAAAA;;sCACnGf,GAAA,CAACX,SAAAA,EAAAA;AAAUkC,4BAAAA,OAAAA,EAASC,kBAAkBvC,SAAAA,EAAW;AAAE,gCAAA,GAAGQ,QAAQN,UAAU;AAAE,gCAAA,GAAGA;AAAW,6BAAA,EAAG4B,KAAAA,KAAUjB,cAAAA,CAAeC,KAAK,GAAG0B,SAAAA,GAAYV,KAAAA,CAAAA;AAAQW,4BAAAA,KAAAA,EAAO;;;AAF9IX,iBAAAA,EAAAA,KAAAA,CAAAA;;;AAQjC;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExternalComponent } from '@cratis/scene.model';
|
|
2
|
+
export declare enum PermissionRule {
|
|
3
|
+
Enabled = "enabled",
|
|
4
|
+
Disabled = "disabled",
|
|
5
|
+
Hidden = "hidden"
|
|
6
|
+
}
|
|
7
|
+
export declare function readPermissionRule(element: ExternalComponent, property?: string): PermissionRule;
|
|
8
|
+
//# sourceMappingURL=PermissionRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionRule.d.ts","sourceRoot":"","sources":["../../../foundation/PermissionRule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD,oBAAY,cAAc;IAEtB,OAAO,YAAY;IAGnB,QAAQ,aAAa;IAGrB,MAAM,WAAW;CACpB;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,SAAe,GAAG,cAAc,CAGtG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/**
|
|
4
|
+
* What an action control does when the user lacks the permission it needs (spec Part B 1.5): it is shown and works, shown and
|
|
5
|
+
* refuses, or not shown. A template never assumes a role, so every action declares one of these and the host's permission
|
|
6
|
+
* evaluation sets it.
|
|
7
|
+
*/ var PermissionRule = /*#__PURE__*/ function(PermissionRule) {
|
|
8
|
+
/** The control works. */ PermissionRule["Enabled"] = "enabled";
|
|
9
|
+
/** The control is shown but cannot be used, and says why. */ PermissionRule["Disabled"] = "disabled";
|
|
10
|
+
/** The control is not rendered. */ PermissionRule["Hidden"] = "hidden";
|
|
11
|
+
return PermissionRule;
|
|
12
|
+
}({});
|
|
13
|
+
/** Reads a permission rule from a property, defaulting to Enabled for anything that is not a rule. */ function readPermissionRule(element, property = 'permission') {
|
|
14
|
+
const value = element.properties[property];
|
|
15
|
+
return value === "disabled" || value === "hidden" ? value : "enabled";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { PermissionRule, readPermissionRule };
|
|
19
|
+
//# sourceMappingURL=PermissionRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionRule.js","sources":["../../../foundation/PermissionRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ExternalComponent } from '@cratis/scene.model';\n\n/**\n * What an action control does when the user lacks the permission it needs (spec Part B 1.5): it is shown and works, shown and\n * refuses, or not shown. A template never assumes a role, so every action declares one of these and the host's permission\n * evaluation sets it.\n */\nexport enum PermissionRule {\n /** The control works. */\n Enabled = 'enabled',\n\n /** The control is shown but cannot be used, and says why. */\n Disabled = 'disabled',\n\n /** The control is not rendered. */\n Hidden = 'hidden',\n}\n\n/** Reads a permission rule from a property, defaulting to Enabled for anything that is not a rule. */\nexport function readPermissionRule(element: ExternalComponent, property = 'permission'): PermissionRule {\n const value = element.properties[property];\n return value === PermissionRule.Disabled || value === PermissionRule.Hidden ? value : PermissionRule.Enabled;\n}\n"],"names":["PermissionRule","readPermissionRule","element","property","value","properties"],"mappings":"AAAA;AACA;AAIA;;;;IAKO,IAAKA,cAAAA,iBAAAA,SAAAA,cAAAA,EAAAA;8BACe,cAAA,CAAA,SAAA,CAAA,GAAA,SAAA;kEAGoC,cAAA,CAAA,UAAA,CAAA,GAAA,UAAA;wCAG1B,cAAA,CAAA,QAAA,CAAA,GAAA,QAAA;AAPzBA,IAAAA,OAAAA,cAAAA;AASX,CAAA,CAAA,EAAA;AAED,uGACO,SAASC,mBAAmBC,OAA0B,EAAEC,WAAW,YAAY,EAAA;AAClF,IAAA,MAAMC,KAAAA,GAAQF,OAAAA,CAAQG,UAAU,CAACF,QAAAA,CAAS;AAC1C,IAAA,OAAOC,wBAAqCA,KAAAA,KAAAA,QAAAA,GAAkCA,KAAAA,GAAAA,SAAAA;AAClF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatCard.d.ts","sourceRoot":"","sources":["../../../foundation/StatCard.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAgB/D,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,wBAAwB,+BAwB3E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { readComponentState, ComponentState } from './ComponentState.js';
|
|
3
|
+
import { FoundationFrame } from './StateFrame.js';
|
|
4
|
+
import { TrendChipView } from './TrendChip.js';
|
|
5
|
+
import { readLocale, formatNumber, readNumberFormat } from './formatting.js';
|
|
6
|
+
import { readFoundationStrings } from './foundationStrings.js';
|
|
7
|
+
import { readString, readOptionalString } from '../shell/elementProperties.js';
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
10
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
11
|
+
/**
|
|
12
|
+
* The `statCard` component: one key figure with its label, its trend and what the trend is compared to - the unit of a dashboard's
|
|
13
|
+
* `kpis` slot.
|
|
14
|
+
*
|
|
15
|
+
* The value is a bound number, never embedded in the component (a figure is data, not design); it is formatted for the locale as
|
|
16
|
+
* a number, currency, percent or compact. With no value the card is empty, and it shows all five standard states
|
|
17
|
+
* independently of its neighbours, so a dashboard whose one query failed still shows the other cards.
|
|
18
|
+
*/ function StatCard({ element, interactions }) {
|
|
19
|
+
const value = element.properties.value;
|
|
20
|
+
const hasValue = typeof value === 'number';
|
|
21
|
+
const state = readComponentState(element, hasValue);
|
|
22
|
+
const locale = readLocale(element);
|
|
23
|
+
const label = readString(element, 'label');
|
|
24
|
+
const change = element.properties.change;
|
|
25
|
+
const currency = readOptionalString(element, 'currency');
|
|
26
|
+
return /*#__PURE__*/ jsx(FoundationFrame, {
|
|
27
|
+
element: element,
|
|
28
|
+
interactions: interactions,
|
|
29
|
+
name: "stat-card",
|
|
30
|
+
state: state,
|
|
31
|
+
skeleton: [
|
|
32
|
+
40,
|
|
33
|
+
70,
|
|
34
|
+
30
|
|
35
|
+
],
|
|
36
|
+
children: state !== ComponentState.Loading && /*#__PURE__*/ jsxs(Fragment, {
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx("h3", {
|
|
39
|
+
className: "foundation-stat-label",
|
|
40
|
+
children: label
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ jsx("p", {
|
|
43
|
+
className: "foundation-stat-value",
|
|
44
|
+
children: hasValue ? formatNumber(value, locale, readNumberFormat(element), currency, typeof element.properties.fractionDigits === 'number' ? element.properties.fractionDigits : undefined) : ''
|
|
45
|
+
}),
|
|
46
|
+
typeof change === 'number' && /*#__PURE__*/ jsx(TrendChipView, {
|
|
47
|
+
change: change,
|
|
48
|
+
locale: locale,
|
|
49
|
+
goodDirection: element.properties.goodDirection === 'down' ? 'down' : 'up',
|
|
50
|
+
comparison: readOptionalString(element, 'comparison'),
|
|
51
|
+
strings: readFoundationStrings(element)
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { StatCard };
|
|
59
|
+
//# sourceMappingURL=StatCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatCard.js","sources":["../../../foundation/StatCard.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ComponentState, readComponentState } from './ComponentState';\nimport { FoundationFrame } from './StateFrame';\nimport { TrendChipView } from './TrendChip';\nimport { formatNumber, readLocale, readNumberFormat } from './formatting';\nimport { readFoundationStrings } from './foundationStrings';\nimport { readOptionalString, readString } from '../shell/elementProperties';\n\n/**\n * The `statCard` component: one key figure with its label, its trend and what the trend is compared to - the unit of a dashboard's\n * `kpis` slot.\n *\n * The value is a bound number, never embedded in the component (a figure is data, not design); it is formatted for the locale as\n * a number, currency, percent or compact. With no value the card is empty, and it shows all five standard states\n * independently of its neighbours, so a dashboard whose one query failed still shows the other cards.\n */\nexport function StatCard({ element, interactions }: RegisteredComponentProps) {\n const value = element.properties.value;\n const hasValue = typeof value === 'number';\n const state = readComponentState(element, hasValue);\n const locale = readLocale(element);\n const label = readString(element, 'label');\n const change = element.properties.change;\n const currency = readOptionalString(element, 'currency');\n\n return (\n <FoundationFrame element={element} interactions={interactions}\n name='stat-card' state={state} skeleton={[40, 70, 30]}>\n {state !== ComponentState.Loading && (\n <>\n <h3 className='foundation-stat-label'>{label}</h3>\n <p className='foundation-stat-value'>{hasValue ? formatNumber(value, locale, readNumberFormat(element), currency, typeof element.properties.fractionDigits === 'number' ? element.properties.fractionDigits : undefined) : ''}</p>\n {typeof change === 'number' && (\n <TrendChipView change={change} locale={locale} goodDirection={element.properties.goodDirection === 'down' ? 'down' : 'up'}\n comparison={readOptionalString(element, 'comparison')} strings={readFoundationStrings(element)} />\n )}\n </>\n )}\n </FoundationFrame>\n );\n}\n"],"names":["StatCard","element","interactions","value","properties","hasValue","state","readComponentState","locale","readLocale","label","readString","change","currency","readOptionalString","_jsx","FoundationFrame","name","skeleton","ComponentState","Loading","_jsxs","_Fragment","h3","className","p","formatNumber","readNumberFormat","fractionDigits","undefined","TrendChipView","goodDirection","comparison","strings","readFoundationStrings"],"mappings":";;;;;;;;AAAA;AACA;AAUA;;;;;;;AAOC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAAEC,YAAY,EAA4B,EAAA;AACxE,IAAA,MAAMC,KAAAA,GAAQF,OAAAA,CAAQG,UAAU,CAACD,KAAK;IACtC,MAAME,QAAAA,GAAW,OAAOF,KAAAA,KAAU,QAAA;IAClC,MAAMG,KAAAA,GAAQC,mBAAmBN,OAAAA,EAASI,QAAAA,CAAAA;AAC1C,IAAA,MAAMG,SAASC,UAAAA,CAAWR,OAAAA,CAAAA;IAC1B,MAAMS,KAAAA,GAAQC,WAAWV,OAAAA,EAAS,OAAA,CAAA;AAClC,IAAA,MAAMW,MAAAA,GAASX,OAAAA,CAAQG,UAAU,CAACQ,MAAM;IACxC,MAAMC,QAAAA,GAAWC,mBAAmBb,OAAAA,EAAS,UAAA,CAAA;AAE7C,IAAA,qBACIc,GAAA,CAACC,eAAAA,EAAAA;QAAgBf,OAAAA,EAASA,OAAAA;QAASC,YAAAA,EAAcA,YAAAA;QAC7Ce,IAAAA,EAAK,WAAA;QAAYX,KAAAA,EAAOA,KAAAA;QAAOY,QAAAA,EAAU;AAAC,YAAA,EAAA;AAAI,YAAA,EAAA;AAAI,YAAA;AAAG,SAAA;kBACpDZ,KAAAA,KAAUa,cAAAA,CAAeC,OAAO,kBAC7BC,IAAA,CAAAC,QAAA,EAAA;;8BACIP,GAAA,CAACQ,IAAAA,EAAAA;oBAAGC,SAAAA,EAAU,uBAAA;AAAyBd,oBAAAA,QAAAA,EAAAA;;8BACvCK,GAAA,CAACU,GAAAA,EAAAA;oBAAED,SAAAA,EAAU,uBAAA;AAAyBnB,oBAAAA,QAAAA,EAAAA,QAAAA,GAAWqB,aAAavB,KAAAA,EAAOK,MAAAA,EAAQmB,iBAAiB1B,OAAAA,CAAAA,EAAUY,QAAAA,EAAU,OAAOZ,OAAAA,CAAQG,UAAU,CAACwB,cAAc,KAAK,QAAA,GAAW3B,OAAAA,CAAQG,UAAU,CAACwB,cAAc,GAAGC,SAAAA,CAAAA,GAAa;;gBAC1N,OAAOjB,MAAAA,KAAW,0BACfG,GAAA,CAACe,aAAAA,EAAAA;oBAAclB,MAAAA,EAAQA,MAAAA;oBAAQJ,MAAAA,EAAQA,MAAAA;AAAQuB,oBAAAA,aAAAA,EAAe9B,QAAQG,UAAU,CAAC2B,aAAa,KAAK,SAAS,MAAA,GAAS,IAAA;AACjHC,oBAAAA,UAAAA,EAAYlB,mBAAmBb,OAAAA,EAAS,YAAA,CAAA;AAAegC,oBAAAA,OAAAA,EAASC,qBAAAA,CAAsBjC,OAAAA;;;;;AAMlH;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RegisteredComponentProps } from '@cratis/scene.react';
|
|
3
|
+
import { ComponentState } from './ComponentState';
|
|
4
|
+
import { FoundationStrings } from './foundationStrings';
|
|
5
|
+
export interface FoundationFrameProps extends Pick<RegisteredComponentProps, 'element' | 'interactions'> {
|
|
6
|
+
name: string;
|
|
7
|
+
state: ComponentState;
|
|
8
|
+
skeleton?: number[];
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare function FoundationFrame({ element, interactions, name, state, skeleton, children }: FoundationFrameProps): import("react").JSX.Element;
|
|
12
|
+
export declare function EmptyStateView({ element, interactions, strings }: Pick<FoundationFrameProps, 'element' | 'interactions'> & {
|
|
13
|
+
strings: FoundationStrings;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=StateFrame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateFrame.d.ts","sourceRoot":"","sources":["../../../foundation/StateFrame.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAqC,MAAM,qBAAqB,CAAC;AAI3F,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,GAAG,cAAc,CAAC;IAEpG,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,cAAc,CAAC;IAGtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAgBD,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,QAAwB,EAAE,QAAQ,EAAE,EAAE,oBAAoB,+BAW/H;AAyDD,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,cAAc,CAAC,GAAG;IAAE,OAAO,EAAE,iBAAiB,CAAA;CAAE,+BAczJ"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { readOptionalString, readStrings } from '../shell/elementProperties.js';
|
|
3
|
+
import { ActionButton } from './ActionButton.js';
|
|
4
|
+
import { ComponentState } from './ComponentState.js';
|
|
5
|
+
import { FoundationIcon } from './FoundationIcon.js';
|
|
6
|
+
import { readFoundationStrings, formatText } from './foundationStrings.js';
|
|
7
|
+
import { readPermissionRule } from './PermissionRule.js';
|
|
8
|
+
import { readLocale } from './formatting.js';
|
|
9
|
+
|
|
10
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
11
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
12
|
+
/** The accessible name of a region, from the element's `label` property. */ function regionLabel(element) {
|
|
13
|
+
return readOptionalString(element, 'label') ?? readOptionalString(element, 'title');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The root every foundation component renders, and the five standard states of spec Part B 1.4 in one place:
|
|
17
|
+
* a skeleton while loading (never a spinner alone), an explanation with the primary action when empty, a message with a
|
|
18
|
+
* retry on error, what is missing - and nothing of the data - when the user is not allowed, and the loaded part with a
|
|
19
|
+
* note naming what failed when only some regions did.
|
|
20
|
+
*
|
|
21
|
+
* The region carries an ARIA landmark role when it has a label, a `dir` is left to the document so right-to-left is
|
|
22
|
+
* inherited, and every piece of text comes from the strings table.
|
|
23
|
+
*/ function FoundationFrame({ element, interactions, name, state, skeleton = [
|
|
24
|
+
60,
|
|
25
|
+
100,
|
|
26
|
+
80
|
|
27
|
+
], children }) {
|
|
28
|
+
const strings = readFoundationStrings(element);
|
|
29
|
+
const label = regionLabel(element);
|
|
30
|
+
const density = element.properties.density === 'compact' ? 'compact' : 'comfortable';
|
|
31
|
+
return /*#__PURE__*/ jsx("section", {
|
|
32
|
+
className: `foundation foundation-${name}`,
|
|
33
|
+
"data-scene-id": element.id,
|
|
34
|
+
"data-state": state,
|
|
35
|
+
"data-density": density,
|
|
36
|
+
lang: readLocale(element),
|
|
37
|
+
role: label ? 'region' : undefined,
|
|
38
|
+
"aria-label": label,
|
|
39
|
+
"aria-busy": state === ComponentState.Loading || undefined,
|
|
40
|
+
children: renderState(element, interactions, strings, state, skeleton, children)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function renderState(element, interactions, strings, state, skeleton, children) {
|
|
44
|
+
switch(state){
|
|
45
|
+
case ComponentState.Loading:
|
|
46
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
47
|
+
className: "foundation-skeleton",
|
|
48
|
+
role: "status",
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ jsx("span", {
|
|
51
|
+
className: "foundation-visually-hidden",
|
|
52
|
+
children: strings.loading
|
|
53
|
+
}),
|
|
54
|
+
skeleton.map((width, index)=>/*#__PURE__*/ jsx("span", {
|
|
55
|
+
className: "foundation-skeleton-block",
|
|
56
|
+
style: {
|
|
57
|
+
width: `${width}%`
|
|
58
|
+
},
|
|
59
|
+
"aria-hidden": "true"
|
|
60
|
+
}, index))
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
case ComponentState.Empty:
|
|
64
|
+
return /*#__PURE__*/ jsx(EmptyStateView, {
|
|
65
|
+
element: element,
|
|
66
|
+
interactions: interactions,
|
|
67
|
+
strings: strings
|
|
68
|
+
});
|
|
69
|
+
case ComponentState.Error:
|
|
70
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
71
|
+
className: "foundation-message",
|
|
72
|
+
"data-tone": "danger",
|
|
73
|
+
role: "alert",
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx(FoundationIcon, {
|
|
76
|
+
name: "alert"
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ jsxs("div", {
|
|
79
|
+
className: "foundation-message-text",
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ jsx("strong", {
|
|
82
|
+
children: strings.errorHeadline
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ jsx("span", {
|
|
85
|
+
children: typeof element.properties.error === 'string' && element.properties.error.length > 0 ? element.properties.error : strings.errorHint
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ jsx(ActionButton, {
|
|
90
|
+
emphasis: "secondary",
|
|
91
|
+
disabledReason: strings.disabledNoPermission,
|
|
92
|
+
onClick: interactions?.onClick,
|
|
93
|
+
children: strings.retry
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
case ComponentState.NoPermission:
|
|
98
|
+
{
|
|
99
|
+
const subject = readOptionalString(element, 'permissionSubject') ?? strings.noPermissionSubject;
|
|
100
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
101
|
+
className: "foundation-message",
|
|
102
|
+
"data-tone": "neutral",
|
|
103
|
+
role: "status",
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ jsx(FoundationIcon, {
|
|
106
|
+
name: "lock"
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ jsxs("div", {
|
|
109
|
+
className: "foundation-message-text",
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ jsx("strong", {
|
|
112
|
+
children: strings.noPermissionHeadline
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ jsx("span", {
|
|
115
|
+
children: formatText(strings.noPermissionHint, {
|
|
116
|
+
subject
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
case ComponentState.Partial:
|
|
125
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
126
|
+
children: [
|
|
127
|
+
/*#__PURE__*/ jsxs("div", {
|
|
128
|
+
className: "foundation-message",
|
|
129
|
+
"data-tone": "warning",
|
|
130
|
+
role: "status",
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ jsx(FoundationIcon, {
|
|
133
|
+
name: "alert"
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ jsxs("div", {
|
|
136
|
+
className: "foundation-message-text",
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ jsx("strong", {
|
|
139
|
+
children: strings.partialHeadline
|
|
140
|
+
}),
|
|
141
|
+
readStrings(element, 'failedRegions').length > 0 && /*#__PURE__*/ jsx("span", {
|
|
142
|
+
children: formatText(strings.partialHint, {
|
|
143
|
+
regions: readStrings(element, 'failedRegions').join(', ')
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ jsx(ActionButton, {
|
|
149
|
+
emphasis: "secondary",
|
|
150
|
+
disabledReason: strings.disabledNoPermission,
|
|
151
|
+
onClick: interactions?.onClick,
|
|
152
|
+
children: strings.retry
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}),
|
|
156
|
+
children
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
default:
|
|
160
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
161
|
+
children: children
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** What an empty region says: an icon, a headline, a hint and the primary action, with the action's permission rule applied. */ function EmptyStateView({ element, interactions, strings }) {
|
|
166
|
+
const icon = readOptionalString(element, 'emptyIcon') ?? readOptionalString(element, 'icon');
|
|
167
|
+
const actionLabel = readOptionalString(element, 'emptyActionLabel') ?? readOptionalString(element, 'actionLabel');
|
|
168
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
169
|
+
className: "foundation-empty",
|
|
170
|
+
role: "status",
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ jsx("span", {
|
|
173
|
+
className: "foundation-empty-icon",
|
|
174
|
+
children: /*#__PURE__*/ jsx(FoundationIcon, {
|
|
175
|
+
name: icon ?? 'inbox'
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ jsx("strong", {
|
|
179
|
+
className: "foundation-empty-headline",
|
|
180
|
+
children: readOptionalString(element, 'emptyHeadline') ?? readOptionalString(element, 'headline') ?? strings.emptyHeadline
|
|
181
|
+
}),
|
|
182
|
+
/*#__PURE__*/ jsx("span", {
|
|
183
|
+
className: "foundation-empty-hint",
|
|
184
|
+
children: readOptionalString(element, 'emptyHint') ?? readOptionalString(element, 'hint') ?? strings.emptyHint
|
|
185
|
+
}),
|
|
186
|
+
actionLabel && /*#__PURE__*/ jsx(ActionButton, {
|
|
187
|
+
rule: readPermissionRule(element, 'actionPermission'),
|
|
188
|
+
disabledReason: strings.disabledNoPermission,
|
|
189
|
+
onClick: interactions?.onClick,
|
|
190
|
+
children: actionLabel
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { EmptyStateView, FoundationFrame };
|
|
197
|
+
//# sourceMappingURL=StateFrame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateFrame.js","sources":["../../../foundation/StateFrame.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode } from 'react';\nimport { ExternalComponent } from '@cratis/scene.model';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { readOptionalString, readStrings } from '../shell/elementProperties';\nimport { ActionButton } from './ActionButton';\nimport { ComponentState } from './ComponentState';\nimport { FoundationIcon, FoundationIconName } from './FoundationIcon';\nimport { FoundationStrings, formatText, readFoundationStrings } from './foundationStrings';\nimport { readPermissionRule } from './PermissionRule';\nimport { readLocale } from './formatting';\n\nexport interface FoundationFrameProps extends Pick<RegisteredComponentProps, 'element' | 'interactions'> {\n /** The component's own class, added after `foundation`. */\n name: string;\n\n /** The state the component is in; compute it with `readComponentState`. */\n state: ComponentState;\n\n /** The shape of the skeleton, as the width of each block in percent; the skeleton keeps the footprint of the content. */\n skeleton?: number[];\n\n /** What the component draws when it is ready or partial. */\n children?: ReactNode;\n}\n\n/** The accessible name of a region, from the element's `label` property. */\nfunction regionLabel(element: ExternalComponent): string | undefined {\n return readOptionalString(element, 'label') ?? readOptionalString(element, 'title');\n}\n\n/**\n * The root every foundation component renders, and the five standard states of spec Part B 1.4 in one place:\n * a skeleton while loading (never a spinner alone), an explanation with the primary action when empty, a message with a\n * retry on error, what is missing - and nothing of the data - when the user is not allowed, and the loaded part with a\n * note naming what failed when only some regions did.\n *\n * The region carries an ARIA landmark role when it has a label, a `dir` is left to the document so right-to-left is\n * inherited, and every piece of text comes from the strings table.\n */\nexport function FoundationFrame({ element, interactions, name, state, skeleton = [60, 100, 80], children }: FoundationFrameProps) {\n const strings = readFoundationStrings(element);\n const label = regionLabel(element);\n const density = element.properties.density === 'compact' ? 'compact' : 'comfortable';\n\n return (\n <section className={`foundation foundation-${name}`} data-scene-id={element.id} data-state={state} data-density={density}\n lang={readLocale(element)} role={label ? 'region' : undefined} aria-label={label} aria-busy={state === ComponentState.Loading || undefined}>\n {renderState(element, interactions, strings, state, skeleton, children)}\n </section>\n );\n}\n\nfunction renderState(element: ExternalComponent, interactions: RegisteredComponentProps['interactions'], strings: FoundationStrings, state: ComponentState, skeleton: number[], children: ReactNode) {\n switch (state) {\n case ComponentState.Loading:\n return (\n <div className='foundation-skeleton' role='status'>\n <span className='foundation-visually-hidden'>{strings.loading}</span>\n {skeleton.map((width, index) => <span key={index} className='foundation-skeleton-block' style={{ width: `${width}%` }} aria-hidden='true' />)}\n </div>\n );\n case ComponentState.Empty:\n return <EmptyStateView element={element} interactions={interactions} strings={strings} />;\n case ComponentState.Error:\n return (\n <div className='foundation-message' data-tone='danger' role='alert'>\n <FoundationIcon name='alert' />\n <div className='foundation-message-text'>\n <strong>{strings.errorHeadline}</strong>\n <span>{typeof element.properties.error === 'string' && element.properties.error.length > 0 ? element.properties.error : strings.errorHint}</span>\n </div>\n <ActionButton emphasis='secondary' disabledReason={strings.disabledNoPermission} onClick={interactions?.onClick}>{strings.retry}</ActionButton>\n </div>\n );\n case ComponentState.NoPermission: {\n const subject = readOptionalString(element, 'permissionSubject') ?? strings.noPermissionSubject;\n return (\n <div className='foundation-message' data-tone='neutral' role='status'>\n <FoundationIcon name='lock' />\n <div className='foundation-message-text'>\n <strong>{strings.noPermissionHeadline}</strong>\n <span>{formatText(strings.noPermissionHint, { subject })}</span>\n </div>\n </div>\n );\n }\n\n case ComponentState.Partial:\n return (\n <>\n <div className='foundation-message' data-tone='warning' role='status'>\n <FoundationIcon name='alert' />\n <div className='foundation-message-text'>\n <strong>{strings.partialHeadline}</strong>\n {readStrings(element, 'failedRegions').length > 0 && <span>{formatText(strings.partialHint, { regions: readStrings(element, 'failedRegions').join(', ') })}</span>}\n </div>\n <ActionButton emphasis='secondary' disabledReason={strings.disabledNoPermission} onClick={interactions?.onClick}>{strings.retry}</ActionButton>\n </div>\n {children}\n </>\n );\n default:\n return <>{children}</>;\n }\n}\n\n/** What an empty region says: an icon, a headline, a hint and the primary action, with the action's permission rule applied. */\nexport function EmptyStateView({ element, interactions, strings }: Pick<FoundationFrameProps, 'element' | 'interactions'> & { strings: FoundationStrings }) {\n const icon = (readOptionalString(element, 'emptyIcon') ?? readOptionalString(element, 'icon')) as FoundationIconName | undefined;\n const actionLabel = readOptionalString(element, 'emptyActionLabel') ?? readOptionalString(element, 'actionLabel');\n\n return (\n <div className='foundation-empty' role='status'>\n <span className='foundation-empty-icon'><FoundationIcon name={icon ?? 'inbox'} /></span>\n <strong className='foundation-empty-headline'>{readOptionalString(element, 'emptyHeadline') ?? readOptionalString(element, 'headline') ?? strings.emptyHeadline}</strong>\n <span className='foundation-empty-hint'>{readOptionalString(element, 'emptyHint') ?? readOptionalString(element, 'hint') ?? strings.emptyHint}</span>\n {actionLabel && (\n <ActionButton rule={readPermissionRule(element, 'actionPermission')} disabledReason={strings.disabledNoPermission} onClick={interactions?.onClick}>{actionLabel}</ActionButton>\n )}\n </div>\n );\n}\n\n"],"names":["regionLabel","element","readOptionalString","FoundationFrame","interactions","name","state","skeleton","children","strings","readFoundationStrings","label","density","properties","_jsx","section","className","data-scene-id","id","data-state","data-density","lang","readLocale","role","undefined","aria-label","aria-busy","ComponentState","Loading","renderState","_jsxs","div","span","loading","map","width","index","style","aria-hidden","Empty","EmptyStateView","Error","data-tone","FoundationIcon","strong","errorHeadline","error","length","errorHint","ActionButton","emphasis","disabledReason","disabledNoPermission","onClick","retry","NoPermission","subject","noPermissionSubject","noPermissionHeadline","formatText","noPermissionHint","Partial","_Fragment","partialHeadline","readStrings","partialHint","regions","join","icon","actionLabel","emptyHeadline","emptyHint","rule","readPermissionRule"],"mappings":";;;;;;;;;AAAA;AACA;AA2BA,6EACA,SAASA,WAAAA,CAAYC,OAA0B,EAAA;AAC3C,IAAA,OAAOC,kBAAAA,CAAmBD,OAAAA,EAAS,OAAA,CAAA,IAAYC,kBAAAA,CAAmBD,OAAAA,EAAS,OAAA,CAAA;AAC/E;AAEA;;;;;;;;AAQC,IACM,SAASE,eAAAA,CAAgB,EAAEF,OAAO,EAAEG,YAAY,EAAEC,IAAI,EAAEC,KAAK,EAAEC,QAAAA,GAAW;AAAC,IAAA,EAAA;AAAI,IAAA,GAAA;AAAK,IAAA;AAAG,CAAA,EAAEC,QAAQ,EAAwB,EAAA;AAC5H,IAAA,MAAMC,UAAUC,qBAAAA,CAAsBT,OAAAA,CAAAA;AACtC,IAAA,MAAMU,QAAQX,WAAAA,CAAYC,OAAAA,CAAAA;AAC1B,IAAA,MAAMW,UAAUX,OAAAA,CAAQY,UAAU,CAACD,OAAO,KAAK,YAAY,SAAA,GAAY,aAAA;AAEvE,IAAA,qBACIE,GAAA,CAACC,SAAAA,EAAAA;QAAQC,SAAAA,EAAW,CAAC,sBAAsB,EAAEX,IAAAA,CAAAA,CAAM;AAAEY,QAAAA,eAAAA,EAAehB,QAAQiB,EAAE;QAAEC,YAAAA,EAAYb,KAAAA;QAAOc,cAAAA,EAAcR,OAAAA;AAC7GS,QAAAA,IAAAA,EAAMC,UAAAA,CAAWrB,OAAAA,CAAAA;AAAUsB,QAAAA,IAAAA,EAAMZ,QAAQ,QAAA,GAAWa,SAAAA;QAAWC,YAAAA,EAAYd,KAAAA;QAAOe,WAAAA,EAAWpB,KAAAA,KAAUqB,cAAAA,CAAeC,OAAO,IAAIJ,SAAAA;AAChIK,QAAAA,QAAAA,EAAAA,WAAAA,CAAY5B,OAAAA,EAASG,YAAAA,EAAcK,OAAAA,EAASH,KAAAA,EAAOC,QAAAA,E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A,qBACI6B,IAAA,CAACC,KAAAA,EAAAA;QAAIf,SAAAA,EAAU,kBAAA;QAAmBO,IAAAA,EAAK,QAAA;;0BACnCT,GAAA,CAACkB,MAAAA,EAAAA;gBAAKhB,SAAAA,EAAU,uBAAA;AAAwB,gBAAA,QAAA,gBAAAF,GAAA,CAAC6B,cAAAA,EAAAA;AAAetC,oBAAAA,IAAAA,EAAM+D,IAAAA,IAAQ;;;0BACtEtD,GAAA,CAAC8B,QAAAA,EAAAA;gBAAO5B,SAAAA,EAAU,2BAAA;AAA6Bd,gBAAAA,QAAAA,EAAAA,kBAAAA,CAAmBD,SAAS,eAAA,CAAA,IAAoBC,kBAAAA,CAAmBD,OAAAA,EAAS,UAAA,CAAA,IAAeQ,QAAQ6D;;0BAClJxD,GAAA,CAACkB,MAAAA,EAAAA;gBAAKhB,SAAAA,EAAU,uBAAA;AAAyBd,gBAAAA,QAAAA,EAAAA,kBAAAA,CAAmBD,SAAS,WAAA,CAAA,IAAgBC,kBAAAA,CAAmBD,OAAAA,EAAS,MAAA,CAAA,IAAWQ,QAAQ8D;;AACnIF,YAAAA,WAAAA,kBACGvD,GAAA,CAACmC,YAAAA,EAAAA;AAAauB,gBAAAA,IAAAA,EAAMC,mBAAmBxE,OAAAA,EAAS,kBAAA,CAAA;AAAqBkD,gBAAAA,cAAAA,EAAgB1C,QAAQ2C,oBAAoB;AAAEC,gBAAAA,OAAAA,EAASjD,YAAAA,EAAciD,OAAAA;AAAUgB,gBAAAA,QAAAA,EAAAA;;;;AAIpK;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegisteredComponentProps } from '@cratis/scene.react';
|
|
2
|
+
import { FoundationIconName } from './FoundationIcon';
|
|
3
|
+
export declare enum StatusTone {
|
|
4
|
+
Success = "success",
|
|
5
|
+
Warning = "warning",
|
|
6
|
+
Danger = "danger",
|
|
7
|
+
Info = "info",
|
|
8
|
+
Neutral = "neutral"
|
|
9
|
+
}
|
|
10
|
+
export declare const statusToneIcons: Record<StatusTone, FoundationIconName>;
|
|
11
|
+
export declare function readStatusTone(value: unknown): StatusTone;
|
|
12
|
+
export declare function StatusChip({ element }: RegisteredComponentProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=StatusChip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusChip.d.ts","sourceRoot":"","sources":["../../../foundation/StatusChip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAkB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItE,oBAAY,UAAU;IAClB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,OAAO,YAAY;CACtB;AAGD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAMlE,CAAC;AAGF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAEzD;AASD,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAY/D"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { readFoundationStrings } from './foundationStrings.js';
|
|
3
|
+
import { FoundationIcon } from './FoundationIcon.js';
|
|
4
|
+
import { readString, readOptionalString } from '../shell/elementProperties.js';
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
/** The semantic tone of a status. */ var StatusTone = /*#__PURE__*/ function(StatusTone) {
|
|
9
|
+
StatusTone["Success"] = "success";
|
|
10
|
+
StatusTone["Warning"] = "warning";
|
|
11
|
+
StatusTone["Danger"] = "danger";
|
|
12
|
+
StatusTone["Info"] = "info";
|
|
13
|
+
StatusTone["Neutral"] = "neutral";
|
|
14
|
+
return StatusTone;
|
|
15
|
+
}({});
|
|
16
|
+
/** The icon each tone gets, so a status is told by shape as well as color (WCAG 1.4.1). */ const statusToneIcons = {
|
|
17
|
+
["success"]: 'check',
|
|
18
|
+
["warning"]: 'alert',
|
|
19
|
+
["danger"]: 'close',
|
|
20
|
+
["info"]: 'info',
|
|
21
|
+
["neutral"]: 'circle'
|
|
22
|
+
};
|
|
23
|
+
/** Reads a tone, defaulting to Neutral. */ function readStatusTone(value) {
|
|
24
|
+
return Object.values(StatusTone).includes(value) ? value : "neutral";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The `statusChip` component: a status as a semantic color, an icon and its text.
|
|
28
|
+
*
|
|
29
|
+
* The text is always shown - the status of a record is never only a colored dot - and the tone picks the icon and the color from
|
|
30
|
+
* the theme's status tokens. A status the application names ("Awaiting approval") is its own `status` text; `tone` maps it onto
|
|
31
|
+
* one of the five tones.
|
|
32
|
+
*/ function StatusChip({ element }) {
|
|
33
|
+
const tone = readStatusTone(element.properties.tone);
|
|
34
|
+
const strings = readFoundationStrings(element);
|
|
35
|
+
const fallback = {
|
|
36
|
+
success: strings.statusSuccess,
|
|
37
|
+
warning: strings.statusWarning,
|
|
38
|
+
danger: strings.statusDanger,
|
|
39
|
+
info: strings.statusInfo,
|
|
40
|
+
neutral: strings.statusNeutral
|
|
41
|
+
}[tone];
|
|
42
|
+
const text = readString(element, 'status', readOptionalString(element, 'label') ?? fallback);
|
|
43
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
44
|
+
className: "foundation foundation-chip foundation-status-chip",
|
|
45
|
+
"data-scene-id": element.id,
|
|
46
|
+
"data-tone": tone,
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ jsx(FoundationIcon, {
|
|
49
|
+
name: statusToneIcons[tone]
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ jsx("span", {
|
|
52
|
+
children: text
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { StatusChip, StatusTone, readStatusTone, statusToneIcons };
|
|
59
|
+
//# sourceMappingURL=StatusChip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusChip.js","sources":["../../../foundation/StatusChip.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { readFoundationStrings } from './foundationStrings';\nimport { FoundationIcon, FoundationIconName } from './FoundationIcon';\nimport { readOptionalString, readString } from '../shell/elementProperties';\n\n/** The semantic tone of a status. */\nexport enum StatusTone {\n Success = 'success',\n Warning = 'warning',\n Danger = 'danger',\n Info = 'info',\n Neutral = 'neutral',\n}\n\n/** The icon each tone gets, so a status is told by shape as well as color (WCAG 1.4.1). */\nexport const statusToneIcons: Record<StatusTone, FoundationIconName> = {\n [StatusTone.Success]: 'check',\n [StatusTone.Warning]: 'alert',\n [StatusTone.Danger]: 'close',\n [StatusTone.Info]: 'info',\n [StatusTone.Neutral]: 'circle',\n};\n\n/** Reads a tone, defaulting to Neutral. */\nexport function readStatusTone(value: unknown): StatusTone {\n return (Object.values(StatusTone) as string[]).includes(value as string) ? (value as StatusTone) : StatusTone.Neutral;\n}\n\n/**\n * The `statusChip` component: a status as a semantic color, an icon and its text.\n *\n * The text is always shown - the status of a record is never only a colored dot - and the tone picks the icon and the color from\n * the theme's status tokens. A status the application names (\"Awaiting approval\") is its own `status` text; `tone` maps it onto\n * one of the five tones.\n */\nexport function StatusChip({ element }: RegisteredComponentProps) {\n const tone = readStatusTone(element.properties.tone);\n const strings = readFoundationStrings(element);\n const fallback = { success: strings.statusSuccess, warning: strings.statusWarning, danger: strings.statusDanger, info: strings.statusInfo, neutral: strings.statusNeutral }[tone];\n const text = readString(element, 'status', readOptionalString(element, 'label') ?? fallback);\n\n return (\n <span className='foundation foundation-chip foundation-status-chip' data-scene-id={element.id} data-tone={tone}>\n <FoundationIcon name={statusToneIcons[tone]} />\n <span>{text}</span>\n </span>\n );\n}\n"],"names":["StatusTone","statusToneIcons","readStatusTone","value","Object","values","includes","StatusChip","element","tone","properties","strings","readFoundationStrings","fallback","success","statusSuccess","warning","statusWarning","danger","statusDanger","info","statusInfo","neutral","statusNeutral","text","readString","readOptionalString","_jsxs","span","className","data-scene-id","id","data-tone","_jsx","FoundationIcon","name"],"mappings":";;;;;AAAA;AACA;AAOA,sCACO,IAAKA,UAAAA,iBAAAA,SAAAA,UAAAA,EAAAA;;;;;;AAAAA,IAAAA,OAAAA,UAAAA;AAMX,CAAA,CAAA,EAAA;AAED,4FACO,MAAMC,eAAAA,GAA0D;AACnE,IAAA,CAAA,SAAA,GAAsB,OAAA;AACtB,IAAA,CAAA,SAAA,GAAsB,OAAA;AACtB,IAAA,CAAA,QAAA,GAAqB,OAAA;AACrB,IAAA,CAAA,MAAA,GAAmB,MAAA;AACnB,IAAA,CAAA,SAAA,GAAsB;AAC1B;AAEA,4CACO,SAASC,cAAAA,CAAeC,KAAc,EAAA;AACzC,IAAA,OAAO,MAACC,CAAOC,MAAM,CAACL,UAAAA,CAAAA,CAAyBM,QAAQ,CAACH,KAAAA,CAAAA,GAAoBA,KAAAA,GAAAA,SAAAA;AAChF;AAEA;;;;;;AAMC,IACM,SAASI,UAAAA,CAAW,EAAEC,OAAO,EAA4B,EAAA;AAC5D,IAAA,MAAMC,IAAAA,GAAOP,cAAAA,CAAeM,OAAAA,CAAQE,UAAU,CAACD,IAAI,CAAA;AACnD,IAAA,MAAME,UAAUC,qBAAAA,CAAsBJ,OAAAA,CAAAA;AACtC,IAAA,MAAMK,QAAAA,GAAW;AAAEC,QAAAA,OAAAA,EAASH,QAAQI,aAAa;AAAEC,QAAAA,OAAAA,EAASL,QAAQM,aAAa;AAAEC,QAAAA,MAAAA,EAAQP,QAAQQ,YAAY;AAAEC,QAAAA,IAAAA,EAAMT,QAAQU,UAAU;AAAEC,QAAAA,OAAA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