@santi020k/lumen-astro 3.0.0 → 4.0.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/README.md +403 -7
- package/components/AmountField.astro +21 -0
- package/components/AnimatedNumber.astro +1 -1
- package/components/ApprovalCard.astro +30 -0
- package/components/AttachmentList.astro +15 -0
- package/components/AttachmentPreview.astro +51 -0
- package/components/Avatar.astro +2 -0
- package/components/BarChart.astro +95 -31
- package/components/BoxPlot.astro +77 -0
- package/components/Breadcrumb.astro +2 -1
- package/components/BulletChart.astro +64 -0
- package/components/Button.astro +1 -1
- package/components/Calendar.astro +54 -65
- package/components/CalendarHeatmap.astro +76 -0
- package/components/Card.astro +4 -0
- package/components/ChangeSummary.astro +36 -0
- package/components/ChartDatumActions.astro +24 -0
- package/components/ChartMotion.astro +11 -0
- package/components/Code.astro +18 -3
- package/components/CodeTabs.astro +12 -0
- package/components/ComboChart.astro +93 -11
- package/components/CountryFlag.astro +23 -0
- package/components/DataTable.astro +15 -7
- package/components/DatePicker.astro +24 -17
- package/components/DescriptionDetail.astro +18 -0
- package/components/DescriptionItem.astro +18 -0
- package/components/DescriptionTerm.astro +18 -0
- package/components/DeviceFrame.astro +79 -0
- package/components/DialogBody.astro +20 -0
- package/components/DialogClose.astro +21 -0
- package/components/DialogFooter.astro +20 -0
- package/components/DialogHeader.astro +20 -0
- package/components/DialogTitle.astro +21 -0
- package/components/DumbbellChart.astro +8 -0
- package/components/FileUpload.astro +3 -1
- package/components/FilterBar.astro +25 -0
- package/components/FunnelChart.astro +50 -0
- package/components/Grid.astro +2 -2
- package/components/Heatmap.astro +61 -12
- package/components/Histogram.astro +30 -0
- package/components/Icon.astro +7 -3
- package/components/ImageComparison.astro +74 -0
- package/components/Input.astro +2 -2
- package/components/LineChart.astro +127 -67
- package/components/LollipopChart.astro +8 -0
- package/components/MediaFilmstrip.astro +19 -0
- package/components/MediaThumbnail.astro +29 -0
- package/components/MediaViewport.astro +38 -0
- package/components/Mentions.astro +2 -1
- package/components/MessageScroller.astro +6 -0
- package/components/MotionGroup.astro +19 -0
- package/components/NativeSelect.astro +2 -2
- package/components/Pagination.astro +2 -1
- package/components/PasswordField.astro +1 -1
- package/components/PhoneInput.astro +60 -9
- package/components/PhoneNumber.astro +19 -0
- package/components/PieChart.astro +26 -3
- package/components/PromptComposer.astro +36 -0
- package/components/RangeChart.astro +38 -8
- package/components/ScatterChart.astro +62 -14
- package/components/Segmented.astro +5 -5
- package/components/Select.astro +8 -8
- package/components/SourceCitation.astro +18 -0
- package/components/Sparkline.astro +9 -10
- package/components/Stack.astro +2 -2
- package/components/StreamMessage.astro +26 -0
- package/components/Tabs.astro +3 -0
- package/components/ToolActivity.astro +17 -0
- package/components/TreeSelect.astro +1 -0
- package/components/VirtualList.astro +5 -2
- package/components/VisualEffect.astro +21 -0
- package/components/WaterfallChart.astro +27 -0
- package/components/WorldMap.astro +213 -0
- package/forms.ts +17 -4
- package/index.ts +37 -0
- package/internal/ChartInspection.astro +27 -0
- package/internal/ComparisonChart.astro +69 -0
- package/internal/IntervalChart.astro +66 -0
- package/package.json +6 -4
- package/runtime/UIPrimitives.astro +670 -647
- package/runtime/chart-actions.ts +19 -0
- package/runtime/controllers/amount-field.ts +12 -0
- package/runtime/controllers/attachments.ts +13 -0
- package/runtime/controllers/chart-activation.ts +33 -0
- package/runtime/controllers/charts.ts +33 -0
- package/runtime/controllers/combobox.ts +39 -0
- package/runtime/controllers/comparison-reset.ts +20 -0
- package/runtime/controllers/data-table.ts +142 -0
- package/runtime/controllers/dialogs.ts +32 -32
- package/runtime/controllers/document-navigation.ts +54 -22
- package/runtime/controllers/file-upload.ts +89 -0
- package/runtime/controllers/image-comparison.ts +53 -0
- package/runtime/controllers/media-selection.ts +20 -0
- package/runtime/controllers/media-viewport.ts +54 -0
- package/runtime/controllers/media-workspace.ts +8 -0
- package/runtime/controllers/message-scroller.ts +13 -0
- package/runtime/controllers/motion.ts +15 -16
- package/runtime/controllers/optional-media.ts +29 -0
- package/runtime/controllers/phone-input.ts +128 -39
- package/runtime/controllers/visual-interactions.ts +75 -0
- package/runtime/controllers/world-map.ts +154 -0
- package/styles/critical.css +634 -61
- package/styles/lumen.css +101 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
|
|
4
|
+
import { createLumenComparisonGeometry, getLumenChartToneClassName, type LumenChartLabels, type LumenComparisonDatum, type LumenComparisonOptions, resolveLumenChartLabels } from '@santi020k/lumen-core'
|
|
5
|
+
|
|
6
|
+
import Chart from '../components/Chart.astro'
|
|
7
|
+
|
|
8
|
+
interface Props extends HTMLAttributes<'figure'>, LumenComparisonOptions {
|
|
9
|
+
data: readonly LumenComparisonDatum[]
|
|
10
|
+
className?: string
|
|
11
|
+
heading?: string
|
|
12
|
+
description?: string
|
|
13
|
+
caption?: string
|
|
14
|
+
presentation?: 'bare' | 'default'
|
|
15
|
+
summary?: string
|
|
16
|
+
formatValue?: (value: number) => string
|
|
17
|
+
labels?: Partial<LumenChartLabels>
|
|
18
|
+
referenceLabel?: string
|
|
19
|
+
valueLabel?: string
|
|
20
|
+
showTable?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { data, domain, paired = false, formatValue = String, labels, referenceLabel = 'Before', valueLabel, showTable = true, class: classProp, className, ...props } = Astro.props
|
|
24
|
+
const text = resolveLumenChartLabels(labels)
|
|
25
|
+
const title = valueLabel ?? text.value
|
|
26
|
+
const model = createLumenComparisonGeometry(data, { domain, paired })
|
|
27
|
+
const format = (value: number | null) => value === null ? text.notAvailable : formatValue(value)
|
|
28
|
+
---
|
|
29
|
+
<Chart
|
|
30
|
+
{...props}
|
|
31
|
+
class:list={['ui-comparison-chart', classProp, className]}
|
|
32
|
+
>
|
|
33
|
+
{!model.valid || model.rows.length === 0 ?
|
|
34
|
+
<p class="ui-chart__empty" role="status">{model.valid ? text.empty : text.invalidData}</p> :
|
|
35
|
+
(
|
|
36
|
+
<>
|
|
37
|
+
<div class="ui-comparison-chart__legend"><span>{text.category}</span><span>{paired ? `${referenceLabel} → ${title}` : title}</span></div>
|
|
38
|
+
<ul class="ui-comparison-chart__rows">
|
|
39
|
+
{model.rows.map((row, index) => (
|
|
40
|
+
<li class={getLumenChartToneClassName(row.tone, index)}>
|
|
41
|
+
<div class="ui-comparison-chart__label"><span>{row.label}</span><span>{paired && <>{format(row.reference)} <span aria-hidden="true">→</span> </>}<strong>{format(row.value)}</strong></span></div>
|
|
42
|
+
<div class="ui-comparison-chart__track" aria-hidden="true">
|
|
43
|
+
{row.valuePosition !== null && row.referencePosition !== null && (
|
|
44
|
+
<span
|
|
45
|
+
class="ui-comparison-chart__connector"
|
|
46
|
+
style={{ left: `${row.start * 100}%`, width: `${row.width * 100}%` }}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
{paired && row.referencePosition !== null && (
|
|
50
|
+
<span
|
|
51
|
+
class="ui-comparison-chart__reference"
|
|
52
|
+
style={{ left: `${row.referencePosition * 100}%` }}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
{row.valuePosition !== null && <span class="ui-comparison-chart__dot" style={{ left: `${row.valuePosition * 100}%` }} />}
|
|
56
|
+
</div>
|
|
57
|
+
</li>
|
|
58
|
+
))}
|
|
59
|
+
</ul>
|
|
60
|
+
<div class="ui-bullet-chart__ticks" aria-hidden="true">{model.ticks.map(tick => <span>{formatValue(tick)}</span>)}</div>
|
|
61
|
+
{showTable && (
|
|
62
|
+
<details class="ui-chart__data"><summary>{text.viewData}</summary><div role="group" tabindex="0" aria-label={text.chartData}><table>
|
|
63
|
+
<thead><tr><th scope="col">{text.category}</th>{paired && <th scope="col">{referenceLabel}</th>}<th scope="col">{title}</th></tr></thead>
|
|
64
|
+
<tbody>{model.rows.map(row => <tr><th scope="row">{row.label}</th>{paired && <td>{format(row.reference)}</td>}<td>{format(row.value)}</td></tr>)}</tbody>
|
|
65
|
+
</table></div></details>
|
|
66
|
+
)}
|
|
67
|
+
</>
|
|
68
|
+
)}
|
|
69
|
+
</Chart>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type createLumenHistogramGeometry,
|
|
6
|
+
type createLumenWaterfallGeometry,
|
|
7
|
+
formatLumenChartSummary,
|
|
8
|
+
getLumenChartToneClassName,
|
|
9
|
+
type LumenChartLabels,
|
|
10
|
+
resolveLumenChartLabels
|
|
11
|
+
} from '@santi020k/lumen-core'
|
|
12
|
+
|
|
13
|
+
import Chart from '../components/Chart.astro'
|
|
14
|
+
|
|
15
|
+
interface Props extends HTMLAttributes<'figure'> {
|
|
16
|
+
caption?: string | undefined
|
|
17
|
+
className?: string | undefined
|
|
18
|
+
description?: string | undefined
|
|
19
|
+
heading?: string | undefined
|
|
20
|
+
labels?: Partial<LumenChartLabels> | undefined
|
|
21
|
+
model: ReturnType<typeof createLumenWaterfallGeometry> | ReturnType<typeof createLumenHistogramGeometry>
|
|
22
|
+
formatValue: (value: number) => string
|
|
23
|
+
formatBoundary: (value: number) => string
|
|
24
|
+
presentation?: 'bare' | 'default' | undefined
|
|
25
|
+
showTable?: boolean | undefined
|
|
26
|
+
summary?: string | undefined
|
|
27
|
+
valueLabel: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { model, labels, formatValue, formatBoundary, showTable = true, summary, valueLabel, ...rest } = Astro.props
|
|
31
|
+
const text = resolveLumenChartLabels(labels)
|
|
32
|
+
const data = model.marks.map(mark => ({ x: mark.key, xLabel: mark.label, y: mark.value }))
|
|
33
|
+
const factualSummary = formatLumenChartSummary([{ id: 'values', label: valueLabel, data }], formatValue, text)
|
|
34
|
+
const hasData = model.marks.length > 0
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
<Chart {...rest} summary={summary ?? (model.valid ? factualSummary : text.invalidData)}>
|
|
38
|
+
{!hasData && <p class="ui-chart__empty" role="status">{model.valid ? text.empty : text.invalidData}</p>}
|
|
39
|
+
{hasData && (
|
|
40
|
+
<>
|
|
41
|
+
<p class="ui-chart__axis-title">{valueLabel}</p>
|
|
42
|
+
<div class="ui-chart__plot" role="region" tabindex="0" aria-label={rest['aria-label'] ?? rest.heading ?? text.chartData}>
|
|
43
|
+
<svg aria-hidden="true" viewBox={`0 0 ${model.width} ${model.height}`}>
|
|
44
|
+
<g class="ui-chart__grid">{model.ticks.map(tick => <><line x1={model.left} x2={model.right} y1={model.y(tick)} y2={model.y(tick)} /><text x={model.left - 8} y={model.y(tick)}>{formatValue(tick)}</text></>)}</g>
|
|
45
|
+
<g class="ui-chart__axis-labels">{model.categoryTicks.map(tick => <text text-anchor={tick.textAnchor} x={tick.position} y={model.height - 16}>{tick.label}</text>)}</g>
|
|
46
|
+
{'connectors' in model && model.connectors.map(connector => (
|
|
47
|
+
<line
|
|
48
|
+
class="ui-waterfall-chart__connector"
|
|
49
|
+
x1={connector.x1}
|
|
50
|
+
x2={connector.x2}
|
|
51
|
+
y1={connector.y}
|
|
52
|
+
y2={connector.y}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
<g class="ui-bar-chart__marks">{model.marks.map(mark => <rect class={getLumenChartToneClassName(mark.tone)} x={mark.x} y={mark.y} width={mark.width} height={mark.height}><title>{mark.label}: {formatValue(mark.value)}</title></rect>)}</g>
|
|
56
|
+
</svg>
|
|
57
|
+
</div>
|
|
58
|
+
</>
|
|
59
|
+
)}
|
|
60
|
+
{showTable && hasData && (
|
|
61
|
+
<details class="ui-chart__data"><summary>{text.viewData}</summary><div role="group" tabindex="0" aria-label={text.chartData}><table>
|
|
62
|
+
<thead><tr><th scope="col">{text.category}</th><th scope="col">{text.start}</th><th scope="col">{text.end}</th><th scope="col">{valueLabel}</th>{'bins' in model && model.frequency === 'density' && <th scope="col">{text.count}</th>}</tr></thead>
|
|
63
|
+
<tbody>{model.marks.map((mark, index) => <tr><th scope="row">{mark.label}</th><td>{formatBoundary(mark.start)}</td><td>{formatBoundary(mark.end)}</td><td>{formatValue(mark.value)}</td>{'bins' in model && model.frequency === 'density' && <td>{model.bins[index]?.count}</td>}</tr>)}</tbody>
|
|
64
|
+
</table></div></details>
|
|
65
|
+
)}
|
|
66
|
+
</Chart>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santi020k/lumen-astro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"bin",
|
|
33
33
|
"components",
|
|
34
|
+
"internal",
|
|
34
35
|
"runtime",
|
|
35
36
|
"styles",
|
|
36
37
|
"index.ts",
|
|
@@ -42,15 +43,16 @@
|
|
|
42
43
|
"lumen": "./bin/lumen.mjs"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@santi020k/lumen": "^
|
|
46
|
-
"@santi020k/lumen-core": "^
|
|
46
|
+
"@santi020k/lumen": "^4.0.0",
|
|
47
|
+
"@santi020k/lumen-core": "^4.0.0",
|
|
47
48
|
"uqr": "^0.1.3"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@astrojs/ts-plugin": "^1.10.12",
|
|
51
52
|
"astro": "^7.3.5",
|
|
53
|
+
"jsdom": "^30.1.1",
|
|
52
54
|
"typescript": "~6.0.3",
|
|
53
|
-
"vitest": "^5.0.
|
|
55
|
+
"vitest": "^5.0.3"
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"astro": ">=5"
|