@cratis/scene.blueprint.default 4.31.0 → 4.33.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.
Files changed (226) hide show
  1. package/ComponentName.ts +24 -0
  2. package/defaultBlueprint.ts +2 -1
  3. package/defaultBlueprintComponentMetadata.ts +2 -0
  4. package/defaultBlueprintComponents.ts +9 -0
  5. package/dist/cjs/ComponentName.js +8 -0
  6. package/dist/cjs/ComponentName.js.map +1 -1
  7. package/dist/cjs/defaultBlueprint.js +9 -5
  8. package/dist/cjs/defaultBlueprint.js.map +1 -1
  9. package/dist/cjs/defaultBlueprintComponentMetadata.js +8 -0
  10. package/dist/cjs/defaultBlueprintComponentMetadata.js.map +1 -1
  11. package/dist/cjs/defaultBlueprintComponents.js +21 -1
  12. package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
  13. package/dist/cjs/foundation/ActionButton.js +33 -0
  14. package/dist/cjs/foundation/ActionButton.js.map +1 -0
  15. package/dist/cjs/foundation/ChartWrapper.js +520 -0
  16. package/dist/cjs/foundation/ChartWrapper.js.map +1 -0
  17. package/dist/cjs/foundation/ColumnChooser.js +156 -0
  18. package/dist/cjs/foundation/ColumnChooser.js.map +1 -0
  19. package/dist/cjs/foundation/ComponentState.js +42 -0
  20. package/dist/cjs/foundation/ComponentState.js.map +1 -0
  21. package/dist/cjs/foundation/EmptyState.js +31 -0
  22. package/dist/cjs/foundation/EmptyState.js.map +1 -0
  23. package/dist/cjs/foundation/FilterBuilder.js +307 -0
  24. package/dist/cjs/foundation/FilterBuilder.js.map +1 -0
  25. package/dist/cjs/foundation/FoundationIcon.js +58 -0
  26. package/dist/cjs/foundation/FoundationIcon.js.map +1 -0
  27. package/dist/cjs/foundation/FoundationStates.js +62 -0
  28. package/dist/cjs/foundation/FoundationStates.js.map +1 -0
  29. package/dist/cjs/foundation/PermissionRule.js +22 -0
  30. package/dist/cjs/foundation/PermissionRule.js.map +1 -0
  31. package/dist/cjs/foundation/SavedViewsMenu.js +199 -0
  32. package/dist/cjs/foundation/SavedViewsMenu.js.map +1 -0
  33. package/dist/cjs/foundation/StatCard.js +61 -0
  34. package/dist/cjs/foundation/StatCard.js.map +1 -0
  35. package/dist/cjs/foundation/StateFrame.js +200 -0
  36. package/dist/cjs/foundation/StateFrame.js.map +1 -0
  37. package/dist/cjs/foundation/StatusChip.js +64 -0
  38. package/dist/cjs/foundation/StatusChip.js.map +1 -0
  39. package/dist/cjs/foundation/TrendChip.js +93 -0
  40. package/dist/cjs/foundation/TrendChip.js.map +1 -0
  41. package/dist/cjs/foundation/chartGeometry.js +101 -0
  42. package/dist/cjs/foundation/chartGeometry.js.map +1 -0
  43. package/dist/cjs/foundation/columnModel.js +43 -0
  44. package/dist/cjs/foundation/columnModel.js.map +1 -0
  45. package/dist/cjs/foundation/filterModel.js +123 -0
  46. package/dist/cjs/foundation/filterModel.js.map +1 -0
  47. package/dist/cjs/foundation/formatting.js +85 -0
  48. package/dist/cjs/foundation/formatting.js.map +1 -0
  49. package/dist/cjs/foundation/foundationComponentMetadata.js +69 -0
  50. package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -0
  51. package/dist/cjs/foundation/foundationDescriptors.js +385 -0
  52. package/dist/cjs/foundation/foundationDescriptors.js.map +1 -0
  53. package/dist/cjs/foundation/foundationSamples.js +201 -0
  54. package/dist/cjs/foundation/foundationSamples.js.map +1 -0
  55. package/dist/cjs/foundation/foundationStrings.js +130 -0
  56. package/dist/cjs/foundation/foundationStrings.js.map +1 -0
  57. package/dist/cjs/foundation/useElementWidth.js +31 -0
  58. package/dist/cjs/foundation/useElementWidth.js.map +1 -0
  59. package/dist/cjs/foundation/viewModel.js +24 -0
  60. package/dist/cjs/foundation/viewModel.js.map +1 -0
  61. package/dist/cjs/index.js +90 -0
  62. package/dist/cjs/index.js.map +1 -1
  63. package/dist/cjs/themes/dark.js +9 -1
  64. package/dist/cjs/themes/dark.js.map +1 -1
  65. package/dist/cjs/themes/light.js +10 -2
  66. package/dist/cjs/themes/light.js.map +1 -1
  67. package/dist/esm/ComponentName.d.ts +9 -1
  68. package/dist/esm/ComponentName.d.ts.map +1 -1
  69. package/dist/esm/ComponentName.js +8 -0
  70. package/dist/esm/ComponentName.js.map +1 -1
  71. package/dist/esm/defaultBlueprint.d.ts.map +1 -1
  72. package/dist/esm/defaultBlueprint.js +9 -5
  73. package/dist/esm/defaultBlueprint.js.map +1 -1
  74. package/dist/esm/defaultBlueprintComponentMetadata.d.ts.map +1 -1
  75. package/dist/esm/defaultBlueprintComponentMetadata.js +8 -0
  76. package/dist/esm/defaultBlueprintComponentMetadata.js.map +1 -1
  77. package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
  78. package/dist/esm/defaultBlueprintComponents.js +21 -1
  79. package/dist/esm/defaultBlueprintComponents.js.map +1 -1
  80. package/dist/esm/foundation/ActionButton.d.ts +13 -0
  81. package/dist/esm/foundation/ActionButton.d.ts.map +1 -0
  82. package/dist/esm/foundation/ActionButton.js +31 -0
  83. package/dist/esm/foundation/ActionButton.js.map +1 -0
  84. package/dist/esm/foundation/ChartWrapper.d.ts +5 -0
  85. package/dist/esm/foundation/ChartWrapper.d.ts.map +1 -0
  86. package/dist/esm/foundation/ChartWrapper.js +517 -0
  87. package/dist/esm/foundation/ChartWrapper.js.map +1 -0
  88. package/dist/esm/foundation/ColumnChooser.d.ts +3 -0
  89. package/dist/esm/foundation/ColumnChooser.d.ts.map +1 -0
  90. package/dist/esm/foundation/ColumnChooser.js +154 -0
  91. package/dist/esm/foundation/ColumnChooser.js.map +1 -0
  92. package/dist/esm/foundation/ComponentState.d.ts +12 -0
  93. package/dist/esm/foundation/ComponentState.d.ts.map +1 -0
  94. package/dist/esm/foundation/ComponentState.js +38 -0
  95. package/dist/esm/foundation/ComponentState.js.map +1 -0
  96. package/dist/esm/foundation/EmptyState.d.ts +3 -0
  97. package/dist/esm/foundation/EmptyState.d.ts.map +1 -0
  98. package/dist/esm/foundation/EmptyState.js +29 -0
  99. package/dist/esm/foundation/EmptyState.js.map +1 -0
  100. package/dist/esm/foundation/FilterBuilder.d.ts +3 -0
  101. package/dist/esm/foundation/FilterBuilder.d.ts.map +1 -0
  102. package/dist/esm/foundation/FilterBuilder.js +305 -0
  103. package/dist/esm/foundation/FilterBuilder.js.map +1 -0
  104. package/dist/esm/foundation/Foundation.stories.d.ts +37 -0
  105. package/dist/esm/foundation/Foundation.stories.d.ts.map +1 -0
  106. package/dist/esm/foundation/Foundation.stories.js +34 -0
  107. package/dist/esm/foundation/Foundation.stories.js.map +1 -0
  108. package/dist/esm/foundation/FoundationIcon.d.ts +7 -0
  109. package/dist/esm/foundation/FoundationIcon.d.ts.map +1 -0
  110. package/dist/esm/foundation/FoundationIcon.js +55 -0
  111. package/dist/esm/foundation/FoundationIcon.js.map +1 -0
  112. package/dist/esm/foundation/FoundationStates.d.ts +8 -0
  113. package/dist/esm/foundation/FoundationStates.d.ts.map +1 -0
  114. package/dist/esm/foundation/FoundationStates.js +60 -0
  115. package/dist/esm/foundation/FoundationStates.js.map +1 -0
  116. package/dist/esm/foundation/PermissionRule.d.ts +8 -0
  117. package/dist/esm/foundation/PermissionRule.d.ts.map +1 -0
  118. package/dist/esm/foundation/PermissionRule.js +19 -0
  119. package/dist/esm/foundation/PermissionRule.js.map +1 -0
  120. package/dist/esm/foundation/SavedViewsMenu.d.ts +4 -0
  121. package/dist/esm/foundation/SavedViewsMenu.d.ts.map +1 -0
  122. package/dist/esm/foundation/SavedViewsMenu.js +196 -0
  123. package/dist/esm/foundation/SavedViewsMenu.js.map +1 -0
  124. package/dist/esm/foundation/StatCard.d.ts +3 -0
  125. package/dist/esm/foundation/StatCard.d.ts.map +1 -0
  126. package/dist/esm/foundation/StatCard.js +59 -0
  127. package/dist/esm/foundation/StatCard.js.map +1 -0
  128. package/dist/esm/foundation/StateFrame.d.ts +15 -0
  129. package/dist/esm/foundation/StateFrame.d.ts.map +1 -0
  130. package/dist/esm/foundation/StateFrame.js +197 -0
  131. package/dist/esm/foundation/StateFrame.js.map +1 -0
  132. package/dist/esm/foundation/StatusChip.d.ts +13 -0
  133. package/dist/esm/foundation/StatusChip.d.ts.map +1 -0
  134. package/dist/esm/foundation/StatusChip.js +59 -0
  135. package/dist/esm/foundation/StatusChip.js.map +1 -0
  136. package/dist/esm/foundation/TrendChip.d.ts +18 -0
  137. package/dist/esm/foundation/TrendChip.d.ts.map +1 -0
  138. package/dist/esm/foundation/TrendChip.js +88 -0
  139. package/dist/esm/foundation/TrendChip.js.map +1 -0
  140. package/dist/esm/foundation/chartGeometry.d.ts +34 -0
  141. package/dist/esm/foundation/chartGeometry.d.ts.map +1 -0
  142. package/dist/esm/foundation/chartGeometry.js +93 -0
  143. package/dist/esm/foundation/chartGeometry.js.map +1 -0
  144. package/dist/esm/foundation/columnModel.d.ts +11 -0
  145. package/dist/esm/foundation/columnModel.d.ts.map +1 -0
  146. package/dist/esm/foundation/columnModel.js +38 -0
  147. package/dist/esm/foundation/columnModel.js.map +1 -0
  148. package/dist/esm/foundation/filterModel.d.ts +33 -0
  149. package/dist/esm/foundation/filterModel.d.ts.map +1 -0
  150. package/dist/esm/foundation/filterModel.js +112 -0
  151. package/dist/esm/foundation/filterModel.js.map +1 -0
  152. package/dist/esm/foundation/formatting.d.ts +13 -0
  153. package/dist/esm/foundation/formatting.d.ts.map +1 -0
  154. package/dist/esm/foundation/formatting.js +78 -0
  155. package/dist/esm/foundation/formatting.js.map +1 -0
  156. package/dist/esm/foundation/foundationComponentMetadata.d.ts +3 -0
  157. package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -0
  158. package/dist/esm/foundation/foundationComponentMetadata.js +67 -0
  159. package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -0
  160. package/dist/esm/foundation/foundationDescriptors.d.ts +6 -0
  161. package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -0
  162. package/dist/esm/foundation/foundationDescriptors.js +380 -0
  163. package/dist/esm/foundation/foundationDescriptors.js.map +1 -0
  164. package/dist/esm/foundation/foundationSamples.d.ts +10 -0
  165. package/dist/esm/foundation/foundationSamples.d.ts.map +1 -0
  166. package/dist/esm/foundation/foundationSamples.js +198 -0
  167. package/dist/esm/foundation/foundationSamples.js.map +1 -0
  168. package/dist/esm/foundation/foundationStrings.d.ts +103 -0
  169. package/dist/esm/foundation/foundationStrings.d.ts.map +1 -0
  170. package/dist/esm/foundation/foundationStrings.js +126 -0
  171. package/dist/esm/foundation/foundationStrings.js.map +1 -0
  172. package/dist/esm/foundation/index.d.ts +25 -0
  173. package/dist/esm/foundation/index.d.ts.map +1 -0
  174. package/dist/esm/foundation/index.js +25 -0
  175. package/dist/esm/foundation/index.js.map +1 -0
  176. package/dist/esm/foundation/useElementWidth.d.ts +3 -0
  177. package/dist/esm/foundation/useElementWidth.d.ts.map +1 -0
  178. package/dist/esm/foundation/useElementWidth.js +29 -0
  179. package/dist/esm/foundation/useElementWidth.js.map +1 -0
  180. package/dist/esm/foundation/viewModel.d.ts +7 -0
  181. package/dist/esm/foundation/viewModel.d.ts.map +1 -0
  182. package/dist/esm/foundation/viewModel.js +22 -0
  183. package/dist/esm/foundation/viewModel.js.map +1 -0
  184. package/dist/esm/gallery/widgets.js +1 -1
  185. package/dist/esm/index.d.ts +1 -0
  186. package/dist/esm/index.d.ts.map +1 -1
  187. package/dist/esm/index.js +24 -0
  188. package/dist/esm/index.js.map +1 -1
  189. package/dist/esm/themes/dark.d.ts.map +1 -1
  190. package/dist/esm/themes/dark.js +9 -1
  191. package/dist/esm/themes/dark.js.map +1 -1
  192. package/dist/esm/themes/light.d.ts.map +1 -1
  193. package/dist/esm/themes/light.js +10 -2
  194. package/dist/esm/themes/light.js.map +1 -1
  195. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  196. package/foundation/ActionButton.tsx +39 -0
  197. package/foundation/ChartWrapper.tsx +252 -0
  198. package/foundation/ColumnChooser.tsx +73 -0
  199. package/foundation/ComponentState.ts +53 -0
  200. package/foundation/EmptyState.tsx +22 -0
  201. package/foundation/FilterBuilder.tsx +144 -0
  202. package/foundation/Foundation.stories.tsx +46 -0
  203. package/foundation/FoundationIcon.tsx +49 -0
  204. package/foundation/FoundationStates.tsx +46 -0
  205. package/foundation/PermissionRule.ts +26 -0
  206. package/foundation/SavedViewsMenu.tsx +94 -0
  207. package/foundation/StatCard.tsx +44 -0
  208. package/foundation/StateFrame.tsx +126 -0
  209. package/foundation/StatusChip.tsx +51 -0
  210. package/foundation/TrendChip.tsx +78 -0
  211. package/foundation/chartGeometry.ts +108 -0
  212. package/foundation/columnModel.ts +39 -0
  213. package/foundation/filterModel.ts +111 -0
  214. package/foundation/formatting.ts +69 -0
  215. package/foundation/foundationComponentMetadata.ts +21 -0
  216. package/foundation/foundationDescriptors.ts +204 -0
  217. package/foundation/foundationSamples.ts +63 -0
  218. package/foundation/foundationStrings.ts +137 -0
  219. package/foundation/index.ts +27 -0
  220. package/foundation/useElementWidth.ts +31 -0
  221. package/foundation/viewModel.ts +21 -0
  222. package/index.ts +1 -0
  223. package/package.json +9 -8
  224. package/shell/layout.css +526 -0
  225. package/themes/dark.ts +8 -0
  226. package/themes/light.ts +9 -1
@@ -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,OAA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AAAA,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,cA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,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,OAAAA,EAASX,QAAQY;AAAc,KAAC,CAACd,IAAAA,CAAK;AACjL,IAAA,MAAMe,OAAOC,UAAAA,CAAWjB,OAAAA,EAAS,QAAA,EAAUkB,kBAAAA,CAAmBlB,SAAS,OAAA,CAAA,IAAYK,QAAAA,CAAAA;AAEnF,IAAA,qBACIc,IAAA,CAACC,MAAAA,EAAAA;QAAKC,SAAAA,EAAU,mDAAA;AAAoDC,QAAAA,eAAAA,EAAetB,QAAQuB,EAAE;QAAEC,WAAAA,EAAWvB,IAAAA;;0BACtGwB,GAAA,CAACC,cAAAA,EAAAA;gBAAeC,IAAAA,EAAMlC,eAAe,CAACQ,IAAAA;;0BACtCwB,GAAA,CAACL,MAAAA,EAAAA;AAAMJ,gBAAAA,QAAAA,EAAAA;;;;AAGnB;;"}
@@ -0,0 +1,18 @@
1
+ import { RegisteredComponentProps } from '@cratis/scene.react';
2
+ import { NumberFormat } from './formatting';
3
+ import { readFoundationStrings } from './foundationStrings';
4
+ export type TrendDirection = 'up' | 'down' | 'flat';
5
+ export type TrendOutcome = 'good' | 'bad' | 'neutral';
6
+ export declare function trendDirection(change: number): TrendDirection;
7
+ export declare function trendOutcome(direction: TrendDirection, goodDirection: 'up' | 'down'): TrendOutcome;
8
+ export interface TrendChipViewProps {
9
+ change: number;
10
+ locale: string;
11
+ goodDirection?: 'up' | 'down';
12
+ comparison?: string;
13
+ format?: NumberFormat;
14
+ strings: ReturnType<typeof readFoundationStrings>;
15
+ }
16
+ export declare function TrendChipView({ change, locale, goodDirection, comparison, format, strings }: TrendChipViewProps): import("react").JSX.Element;
17
+ export declare function TrendChip({ element }: RegisteredComponentProps): import("react").JSX.Element | undefined;
18
+ //# sourceMappingURL=TrendChip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrendChip.d.ts","sourceRoot":"","sources":["../../../foundation/TrendChip.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAgB,YAAY,EAAc,MAAM,cAAc,CAAC;AACtE,OAAO,EAAc,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAGpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAGtD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAE7D;AAGD,wBAAgB,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,IAAI,GAAG,MAAM,GAAG,YAAY,CAElG;AAMD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CACrD;AAQD,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,aAAoB,EAAE,UAAU,EAAE,MAA6B,EAAE,OAAO,EAAE,EAAE,kBAAkB,+BAc7I;AAQD,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,2CAW9D"}
@@ -0,0 +1,88 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { FoundationIcon } from './FoundationIcon.js';
3
+ import { NumberFormat, readLocale, formatNumber } from './formatting.js';
4
+ import { readFoundationStrings, formatText } from './foundationStrings.js';
5
+ import { readOptionalString } from '../shell/elementProperties.js';
6
+
7
+ // Copyright (c) Cratis. All rights reserved.
8
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
9
+ /** The direction a change moved in. */ function trendDirection(change) {
10
+ return change > 0 ? 'up' : change < 0 ? 'down' : 'flat';
11
+ }
12
+ /** Whether a movement is good for a measure, given which direction is the good one. */ function trendOutcome(direction, goodDirection) {
13
+ return direction === 'flat' ? 'neutral' : direction === goodDirection ? 'good' : 'bad';
14
+ }
15
+ /** The tone each outcome is drawn in. */ const tones = {
16
+ good: 'success',
17
+ bad: 'danger',
18
+ neutral: 'neutral'
19
+ };
20
+ /**
21
+ * A change, drawn as an arrow, the change and what it is compared to.
22
+ *
23
+ * Color says whether the movement is good, but never alone: the arrow gives direction and a visually hidden sentence
24
+ * says all of it ("up 12.5% compared to last month"), so the chip reads the same without color.
25
+ */ function TrendChipView({ change, locale, goodDirection = 'up', comparison, format = NumberFormat.Percent, strings }) {
26
+ const direction = trendDirection(change);
27
+ const outcome = trendOutcome(direction, goodDirection);
28
+ const magnitude = formatNumber(Math.abs(change), locale, format);
29
+ const spoken = direction === 'flat' ? strings.trendFlat : formatText(direction === 'up' ? strings.trendUp : strings.trendDown, {
30
+ value: magnitude
31
+ });
32
+ return /*#__PURE__*/ jsxs("span", {
33
+ className: "foundation-chip foundation-trend",
34
+ "data-tone": tones[outcome],
35
+ "data-direction": direction,
36
+ children: [
37
+ /*#__PURE__*/ jsx(FoundationIcon, {
38
+ name: direction === 'up' ? 'arrow-up' : direction === 'down' ? 'arrow-down' : 'minus'
39
+ }),
40
+ /*#__PURE__*/ jsx("span", {
41
+ "aria-hidden": "true",
42
+ children: direction === 'flat' ? magnitude : magnitude
43
+ }),
44
+ /*#__PURE__*/ jsxs("span", {
45
+ className: "foundation-visually-hidden",
46
+ children: [
47
+ spoken,
48
+ comparison ? ` ${formatText(strings.trendComparison, {
49
+ period: comparison
50
+ })}` : ''
51
+ ]
52
+ }),
53
+ comparison && /*#__PURE__*/ jsx("span", {
54
+ className: "foundation-trend-comparison",
55
+ "aria-hidden": "true",
56
+ children: formatText(strings.trendComparison, {
57
+ period: comparison
58
+ })
59
+ })
60
+ ]
61
+ });
62
+ }
63
+ /**
64
+ * The `trendChip` component: a change with its direction, whether that is good, and what it is compared to.
65
+ *
66
+ * `change` is the movement as a number (a percentage by default), `goodDirection` says which way is good, and `comparison` names
67
+ * the period. Without a number the chip is empty, and then it draws nothing rather than an invented zero.
68
+ */ function TrendChip({ element }) {
69
+ const change = element.properties.change;
70
+ if (typeof change !== 'number') return undefined;
71
+ return /*#__PURE__*/ jsx("span", {
72
+ className: "foundation foundation-trend-chip",
73
+ "data-scene-id": element.id,
74
+ children: /*#__PURE__*/ jsx(TrendChipView, {
75
+ change: change,
76
+ locale: readLocale(element),
77
+ goodDirection: element.properties.goodDirection === 'down' ? 'down' : 'up',
78
+ comparison: readOptionalString(element, 'comparison'),
79
+ strings: readFoundationStrings(element),
80
+ ...typeof element.properties.format === 'string' && Object.values(NumberFormat).includes(element.properties.format) ? {
81
+ format: element.properties.format
82
+ } : {}
83
+ })
84
+ });
85
+ }
86
+
87
+ export { TrendChip, TrendChipView, trendDirection, trendOutcome };
88
+ //# sourceMappingURL=TrendChip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrendChip.js","sources":["../../../foundation/TrendChip.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 { FoundationIcon } from './FoundationIcon';\nimport { formatNumber, NumberFormat, readLocale } from './formatting';\nimport { formatText, readFoundationStrings } from './foundationStrings';\nimport { readOptionalString } from '../shell/elementProperties';\n\n/** The direction a measure moved. */\nexport type TrendDirection = 'up' | 'down' | 'flat';\n\n/** Whether a movement is good, bad or neither, which is independent of whether the number rose: falling response time is good. */\nexport type TrendOutcome = 'good' | 'bad' | 'neutral';\n\n/** The direction a change moved in. */\nexport function trendDirection(change: number): TrendDirection {\n return change > 0 ? 'up' : change < 0 ? 'down' : 'flat';\n}\n\n/** Whether a movement is good for a measure, given which direction is the good one. */\nexport function trendOutcome(direction: TrendDirection, goodDirection: 'up' | 'down'): TrendOutcome {\n return direction === 'flat' ? 'neutral' : direction === goodDirection ? 'good' : 'bad';\n}\n\n/** The tone each outcome is drawn in. */\nconst tones: Record<TrendOutcome, string> = { good: 'success', bad: 'danger', neutral: 'neutral' };\n\n/** The props of a trend chip drawn directly, as the stat card does. */\nexport interface TrendChipViewProps {\n change: number;\n locale: string;\n goodDirection?: 'up' | 'down';\n comparison?: string;\n format?: NumberFormat;\n strings: ReturnType<typeof readFoundationStrings>;\n}\n\n/**\n * A change, drawn as an arrow, the change and what it is compared to.\n *\n * Color says whether the movement is good, but never alone: the arrow gives direction and a visually hidden sentence\n * says all of it (\"up 12.5% compared to last month\"), so the chip reads the same without color.\n */\nexport function TrendChipView({ change, locale, goodDirection = 'up', comparison, format = NumberFormat.Percent, strings }: TrendChipViewProps) {\n const direction = trendDirection(change);\n const outcome = trendOutcome(direction, goodDirection);\n const magnitude = formatNumber(Math.abs(change), locale, format);\n const spoken = direction === 'flat' ? strings.trendFlat : formatText(direction === 'up' ? strings.trendUp : strings.trendDown, { value: magnitude });\n\n return (\n <span className='foundation-chip foundation-trend' data-tone={tones[outcome]} data-direction={direction}>\n <FoundationIcon name={direction === 'up' ? 'arrow-up' : direction === 'down' ? 'arrow-down' : 'minus'} />\n <span aria-hidden='true'>{direction === 'flat' ? magnitude : magnitude}</span>\n <span className='foundation-visually-hidden'>{spoken}{comparison ? ` ${formatText(strings.trendComparison, { period: comparison })}` : ''}</span>\n {comparison && <span className='foundation-trend-comparison' aria-hidden='true'>{formatText(strings.trendComparison, { period: comparison })}</span>}\n </span>\n );\n}\n\n/**\n * The `trendChip` component: a change with its direction, whether that is good, and what it is compared to.\n *\n * `change` is the movement as a number (a percentage by default), `goodDirection` says which way is good, and `comparison` names\n * the period. Without a number the chip is empty, and then it draws nothing rather than an invented zero.\n */\nexport function TrendChip({ element }: RegisteredComponentProps) {\n const change = element.properties.change;\n if (typeof change !== 'number') return undefined;\n\n return (\n <span className='foundation foundation-trend-chip' data-scene-id={element.id}>\n <TrendChipView change={change} locale={readLocale(element)} goodDirection={element.properties.goodDirection === 'down' ? 'down' : 'up'}\n comparison={readOptionalString(element, 'comparison')} strings={readFoundationStrings(element)}\n {...(typeof element.properties.format === 'string' && (Object.values(NumberFormat) as string[]).includes(element.properties.format) ? { format: element.properties.format as NumberFormat } : {})} />\n </span>\n );\n}\n"],"names":["trendDirection","change","trendOutcome","direction","goodDirection","tones","good","bad","neutral","TrendChipView","locale","comparison","format","NumberFormat","Percent","strings","outcome","magnitude","formatNumber","Math","abs","spoken","trendFlat","formatText","trendUp","trendDown","value","_jsxs","span","className","data-tone","data-direction","_jsx","FoundationIcon","name","aria-hidden","trendComparison","period","TrendChip","element","properties","undefined","data-scene-id","id","readLocale","readOptionalString","readFoundationStrings","Object","values","includes"],"mappings":";;;;;;AAAA;AACA;AAcA,wCACO,SAASA,cAAAA,CAAeC,MAAc,EAAA;AACzC,IAAA,OAAOA,MAAAA,GAAS,CAAA,GAAI,IAAA,GAAOA,MAAAA,GAAS,IAAI,MAAA,GAAS,MAAA;AACrD;AAEA,wFACO,SAASC,YAAAA,CAAaC,SAAyB,EAAEC,aAA4B,EAAA;AAChF,IAAA,OAAOD,SAAAA,KAAc,MAAA,GAAS,SAAA,GAAYA,SAAAA,KAAcC,gBAAgB,MAAA,GAAS,KAAA;AACrF;AAEA,0CACA,MAAMC,KAAAA,GAAsC;IAAEC,IAAAA,EAAM,SAAA;IAAWC,GAAAA,EAAK,QAAA;IAAUC,OAAAA,EAAS;AAAU,CAAA;AAYjG;;;;;AAKC,IACM,SAASC,aAAAA,CAAc,EAAER,MAAM,EAAES,MAAM,EAAEN,aAAAA,GAAgB,IAAI,EAAEO,UAAU,EAAEC,MAAAA,GAASC,aAAaC,OAAO,EAAEC,OAAO,EAAsB,EAAA;AAC1I,IAAA,MAAMZ,YAAYH,cAAAA,CAAeC,MAAAA,CAAAA;IACjC,MAAMe,OAAAA,GAAUd,aAAaC,SAAAA,EAAWC,aAAAA,CAAAA;AACxC,IAAA,MAAMa,YAAYC,YAAAA,CAAaC,IAAAA,CAAKC,GAAG,CAACnB,SAASS,MAAAA,EAAQE,MAAAA,CAAAA;AACzD,IAAA,MAAMS,MAAAA,GAASlB,SAAAA,KAAc,MAAA,GAASY,OAAAA,CAAQO,SAAS,GAAGC,UAAAA,CAAWpB,SAAAA,KAAc,IAAA,GAAOY,OAAAA,CAAQS,OAAO,GAAGT,OAAAA,CAAQU,SAA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A,eAAAA,EAAeH,QAAQI,EAAE;AACxE,QAAA,QAAA,gBAAAX,GAAA,CAACvB,aAAAA,EAAAA;YAAcR,MAAAA,EAAQA,MAAAA;AAAQS,YAAAA,MAAAA,EAAQkC,UAAAA,CAAWL,OAAAA,CAAAA;AAAUnC,YAAAA,aAAAA,EAAemC,QAAQC,UAAU,CAACpC,aAAa,KAAK,SAAS,MAAA,GAAS,IAAA;AAC9HO,YAAAA,UAAAA,EAAYkC,mBAAmBN,OAAAA,EAAS,YAAA,CAAA;AAAexB,YAAAA,OAAAA,EAAS+B,qBAAAA,CAAsBP,OAAAA,CAAAA;AACrF,YAAA,GAAI,OAAOA,OAAAA,CAAQC,UAAU,CAAC5B,MAAM,KAAK,YAAY,MAACmC,CAAOC,MAAM,CAACnC,cAA2BoC,QAAQ,CAACV,QAAQC,UAAU,CAAC5B,MAAM,CAAA,GAAI;gBAAEA,MAAAA,EAAQ2B,OAAAA,CAAQC,UAAU,CAAC5B;AAAuB,aAAA,GAAI;;;AAG9M;;"}
@@ -0,0 +1,34 @@
1
+ export declare enum ChartKind {
2
+ Line = "line",
3
+ Bar = "bar",
4
+ Stacked = "stacked",
5
+ Donut = "donut",
6
+ Funnel = "funnel"
7
+ }
8
+ export interface ChartSeries {
9
+ name: string;
10
+ values: number[];
11
+ }
12
+ export interface ChartScale {
13
+ maximum: number;
14
+ ticks: number[];
15
+ }
16
+ export declare function niceScale(maximum: number, target?: number): ChartScale;
17
+ export declare function readSeries(value: unknown): ChartSeries[];
18
+ export declare function dataMaximum(kind: ChartKind, series: ChartSeries[], categoryCount: number): number;
19
+ export interface DonutSlice {
20
+ index: number;
21
+ value: number;
22
+ share: number;
23
+ start: number;
24
+ end: number;
25
+ }
26
+ export declare function donutSlices(values: number[]): DonutSlice[];
27
+ export declare function ringPath(centerX: number, centerY: number, outer: number, inner: number, start: number, end: number): string;
28
+ export interface FunnelStage {
29
+ index: number;
30
+ value: number;
31
+ widthRatio: number;
32
+ }
33
+ export declare function funnelStages(values: number[]): FunnelStage[];
34
+ //# sourceMappingURL=chartGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartGeometry.d.ts","sourceRoot":"","sources":["../../../foundation/chartGeometry.ts"],"names":[],"mappings":"AAIA,oBAAY,SAAS;IACjB,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAGD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAGD,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB;AAGD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,UAAU,CAWjE;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,EAAE,CASxD;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAMjG;AAGD,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AAGD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAa1D;AAGD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAS3H;AAGD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EA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