@seanyeh77/ui 0.48.3 → 0.49.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/dist/styles.css CHANGED
@@ -686,6 +686,105 @@ label:has(> .ui-switch) {
686
686
  stroke: var(--surface);
687
687
  stroke-width: 2;
688
688
  }
689
+
690
+ /* Text on a data fill (ZoneMap zones, FloorPlan labels): the pick of textOn() for each step, per theme, so it follows a
691
+ theme switch without a render. */
692
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-1'] {
693
+ color: #ffffff;
694
+ }
695
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-2'] {
696
+ color: #171512;
697
+ }
698
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-3'] {
699
+ color: #171512;
700
+ }
701
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-4'] {
702
+ color: #171512;
703
+ }
704
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-5'] {
705
+ color: #171512;
706
+ }
707
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-6'] {
708
+ color: #171512;
709
+ }
710
+ :is(.ui-zone, .ui-fp-label)[data-fill='heat-7'] {
711
+ color: #ffffff;
712
+ }
713
+ :is(.ui-zone, .ui-fp-label)[data-fill='diverge-neg-strong'] {
714
+ color: #ffffff;
715
+ }
716
+ :is(.ui-zone, .ui-fp-label)[data-fill='diverge-neg'] {
717
+ color: #171512;
718
+ }
719
+ :is(.ui-zone, .ui-fp-label)[data-fill='diverge-zero'] {
720
+ color: #171512;
721
+ }
722
+ :is(.ui-zone, .ui-fp-label)[data-fill='diverge-pos'] {
723
+ color: #171512;
724
+ }
725
+ :is(.ui-zone, .ui-fp-label)[data-fill='diverge-pos-strong'] {
726
+ color: #ffffff;
727
+ }
728
+ :is(.ui-zone, .ui-fp-label)[data-fill='chart-1'] {
729
+ color: #ffffff;
730
+ }
731
+ :is(.ui-zone, .ui-fp-label)[data-fill='chart-2'] {
732
+ color: #171512;
733
+ }
734
+ :is(.ui-zone, .ui-fp-label)[data-fill='chart-3'] {
735
+ color: #171512;
736
+ }
737
+ :is(.ui-zone, .ui-fp-label)[data-fill='chart-4'] {
738
+ color: #171512;
739
+ }
740
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-1'] {
741
+ color: #ffffff;
742
+ }
743
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-2'] {
744
+ color: #171512;
745
+ }
746
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-3'] {
747
+ color: #171512;
748
+ }
749
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-4'] {
750
+ color: #ffffff;
751
+ }
752
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-5'] {
753
+ color: #171512;
754
+ }
755
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-6'] {
756
+ color: #171512;
757
+ }
758
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='heat-7'] {
759
+ color: #171512;
760
+ }
761
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='diverge-neg-strong'] {
762
+ color: #171512;
763
+ }
764
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='diverge-neg'] {
765
+ color: #171512;
766
+ }
767
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='diverge-zero'] {
768
+ color: #ffffff;
769
+ }
770
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='diverge-pos'] {
771
+ color: #171512;
772
+ }
773
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='diverge-pos-strong'] {
774
+ color: #171512;
775
+ }
776
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='chart-1'] {
777
+ color: #171512;
778
+ }
779
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='chart-2'] {
780
+ color: #171512;
781
+ }
782
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='chart-3'] {
783
+ color: #171512;
784
+ }
785
+ [data-theme='dark'] :is(.ui-zone, .ui-fp-label)[data-fill='chart-4'] {
786
+ color: #171512;
787
+ }
689
788
  /* Link: accent text, always underlined (a link in a sentence is told apart by more than its colour), a thin line
690
789
  that thickens on hover. Bare <a> in Markdown or older content gets the same look from base.css. */
691
790
  .ui-textlink {
@@ -9609,103 +9708,6 @@ button.ui-md-link.is-row {
9609
9708
  background: CanvasText;
9610
9709
  }
9611
9710
  }
9612
- .ui-zone[data-fill='heat-1'] {
9613
- color: #ffffff;
9614
- }
9615
- .ui-zone[data-fill='heat-2'] {
9616
- color: #171512;
9617
- }
9618
- .ui-zone[data-fill='heat-3'] {
9619
- color: #171512;
9620
- }
9621
- .ui-zone[data-fill='heat-4'] {
9622
- color: #171512;
9623
- }
9624
- .ui-zone[data-fill='heat-5'] {
9625
- color: #171512;
9626
- }
9627
- .ui-zone[data-fill='heat-6'] {
9628
- color: #171512;
9629
- }
9630
- .ui-zone[data-fill='heat-7'] {
9631
- color: #ffffff;
9632
- }
9633
- .ui-zone[data-fill='diverge-neg-strong'] {
9634
- color: #ffffff;
9635
- }
9636
- .ui-zone[data-fill='diverge-neg'] {
9637
- color: #171512;
9638
- }
9639
- .ui-zone[data-fill='diverge-zero'] {
9640
- color: #171512;
9641
- }
9642
- .ui-zone[data-fill='diverge-pos'] {
9643
- color: #171512;
9644
- }
9645
- .ui-zone[data-fill='diverge-pos-strong'] {
9646
- color: #ffffff;
9647
- }
9648
- .ui-zone[data-fill='chart-1'] {
9649
- color: #ffffff;
9650
- }
9651
- .ui-zone[data-fill='chart-2'] {
9652
- color: #171512;
9653
- }
9654
- .ui-zone[data-fill='chart-3'] {
9655
- color: #171512;
9656
- }
9657
- .ui-zone[data-fill='chart-4'] {
9658
- color: #171512;
9659
- }
9660
- [data-theme='dark'] .ui-zone[data-fill='heat-1'] {
9661
- color: #ffffff;
9662
- }
9663
- [data-theme='dark'] .ui-zone[data-fill='heat-2'] {
9664
- color: #171512;
9665
- }
9666
- [data-theme='dark'] .ui-zone[data-fill='heat-3'] {
9667
- color: #171512;
9668
- }
9669
- [data-theme='dark'] .ui-zone[data-fill='heat-4'] {
9670
- color: #ffffff;
9671
- }
9672
- [data-theme='dark'] .ui-zone[data-fill='heat-5'] {
9673
- color: #171512;
9674
- }
9675
- [data-theme='dark'] .ui-zone[data-fill='heat-6'] {
9676
- color: #171512;
9677
- }
9678
- [data-theme='dark'] .ui-zone[data-fill='heat-7'] {
9679
- color: #171512;
9680
- }
9681
- [data-theme='dark'] .ui-zone[data-fill='diverge-neg-strong'] {
9682
- color: #171512;
9683
- }
9684
- [data-theme='dark'] .ui-zone[data-fill='diverge-neg'] {
9685
- color: #171512;
9686
- }
9687
- [data-theme='dark'] .ui-zone[data-fill='diverge-zero'] {
9688
- color: #ffffff;
9689
- }
9690
- [data-theme='dark'] .ui-zone[data-fill='diverge-pos'] {
9691
- color: #171512;
9692
- }
9693
- [data-theme='dark'] .ui-zone[data-fill='diverge-pos-strong'] {
9694
- color: #171512;
9695
- }
9696
- [data-theme='dark'] .ui-zone[data-fill='chart-1'] {
9697
- color: #171512;
9698
- }
9699
- [data-theme='dark'] .ui-zone[data-fill='chart-2'] {
9700
- color: #171512;
9701
- }
9702
- [data-theme='dark'] .ui-zone[data-fill='chart-3'] {
9703
- color: #171512;
9704
- }
9705
- [data-theme='dark'] .ui-zone[data-fill='chart-4'] {
9706
- color: #171512;
9707
- }
9708
-
9709
9711
  /* ZoneMap: zones on a grid, filled by value. Name 16 px and state on one line, the figure 31 px with a 16 px unit,
9710
9712
  one 13 px detail line. Selected: an ink outline 4 px outside; attention: a 4 px warning or danger border. */
9711
9713
  .ui-zonemap {
@@ -9807,6 +9809,271 @@ button.ui-md-link.is-row {
9807
9809
  .ui-zone.is-empty .ui-zone-name {
9808
9810
  color: var(--ink);
9809
9811
  }
9812
+ /* FloorPlan: zones with any outline in an SVG, labels as HTML on top (the same size at every zoom). Fills, the 4 px
9813
+ attention border, the forecast stripes, the selection outline (ink, 2 px, 4 px outside) and the label type follow
9814
+ ZoneMap. */
9815
+ .ui-floorplan {
9816
+ display: flex;
9817
+ flex-direction: column;
9818
+ gap: var(--space-3);
9819
+ min-width: 0;
9820
+ }
9821
+ .ui-floorplan.is-fill {
9822
+ flex: 1 1 auto;
9823
+ min-height: 0;
9824
+ }
9825
+ .ui-fp-box {
9826
+ position: relative;
9827
+ width: 100%;
9828
+ min-height: 240px;
9829
+ max-height: 640px;
9830
+ overflow: hidden;
9831
+ border-radius: var(--radius-md);
9832
+ }
9833
+ .ui-floorplan.is-fill .ui-fp-box {
9834
+ flex: 1 1 auto;
9835
+ max-height: none;
9836
+ }
9837
+ .ui-fp-svg {
9838
+ position: absolute;
9839
+ inset: 0;
9840
+ display: block;
9841
+ width: 100%;
9842
+ height: 100%;
9843
+ touch-action: none;
9844
+ -webkit-user-select: none;
9845
+ user-select: none;
9846
+ }
9847
+ .ui-fp-shell {
9848
+ fill: var(--surface-sub);
9849
+ stroke: var(--line-strong);
9850
+ stroke-width: 1.5px;
9851
+ vector-effect: non-scaling-stroke;
9852
+ }
9853
+ .ui-fp-zone {
9854
+ cursor: pointer;
9855
+ outline: none;
9856
+ }
9857
+ .ui-fp-fill {
9858
+ stroke: var(--surface);
9859
+ stroke-width: 1.5px;
9860
+ stroke-linejoin: round;
9861
+ vector-effect: non-scaling-stroke;
9862
+ }
9863
+ .ui-fp-zone.is-warning .ui-fp-tone {
9864
+ stroke: var(--warning);
9865
+ }
9866
+ .ui-fp-zone.is-danger .ui-fp-tone {
9867
+ stroke: var(--danger);
9868
+ }
9869
+ .ui-fp-stripe {
9870
+ fill: var(--forecast-stripe);
9871
+ }
9872
+ .ui-fp-empty {
9873
+ fill: transparent;
9874
+ stroke: var(--line-strong);
9875
+ stroke-width: 1px;
9876
+ stroke-dasharray: 4 3;
9877
+ vector-effect: non-scaling-stroke;
9878
+ }
9879
+ .ui-fp-edge {
9880
+ fill: none;
9881
+ stroke: var(--ink-muted);
9882
+ stroke-width: 1.5px;
9883
+ stroke-dasharray: 5 4;
9884
+ vector-effect: non-scaling-stroke;
9885
+ pointer-events: none;
9886
+ }
9887
+ .ui-fp-group {
9888
+ fill: var(--ink-muted);
9889
+ pointer-events: none;
9890
+ }
9891
+
9892
+ /* Labels: centred on the zone's label point, sized by FloorPlan (width and height set inline). */
9893
+ .ui-fp-labels {
9894
+ position: absolute;
9895
+ inset: 0;
9896
+ pointer-events: none;
9897
+ }
9898
+ .ui-fp-labels > * {
9899
+ position: absolute;
9900
+ box-sizing: border-box;
9901
+ overflow: hidden;
9902
+ white-space: nowrap;
9903
+ }
9904
+ .ui-fp-label {
9905
+ display: flex;
9906
+ flex-direction: column;
9907
+ align-items: center;
9908
+ justify-content: center;
9909
+ color: var(--ink);
9910
+ text-align: center;
9911
+ }
9912
+ .ui-fp-name {
9913
+ max-width: 100%;
9914
+ overflow: hidden;
9915
+ text-overflow: ellipsis;
9916
+ font-size: var(--text-body);
9917
+ font-weight: 600;
9918
+ line-height: 22px;
9919
+ }
9920
+ .ui-fp-value {
9921
+ font-family: var(--font-mono);
9922
+ font-size: var(--text-h3);
9923
+ font-weight: 700;
9924
+ line-height: 32px;
9925
+ font-variant-numeric: tabular-nums;
9926
+ }
9927
+ .ui-fp-unit {
9928
+ font-family: var(--font-sans);
9929
+ font-size: var(--text-body);
9930
+ font-weight: 500;
9931
+ }
9932
+ .ui-fp-state {
9933
+ font-size: var(--text-small);
9934
+ font-weight: 600;
9935
+ line-height: 20px;
9936
+ }
9937
+ .ui-fp-label.is-muted .ui-fp-name {
9938
+ font-size: var(--text-small);
9939
+ line-height: 20px;
9940
+ }
9941
+ .ui-fp-label.is-muted .ui-fp-value {
9942
+ font-size: var(--text-body);
9943
+ line-height: 22px;
9944
+ }
9945
+ .ui-fp-label.is-muted .ui-fp-unit {
9946
+ font-size: var(--text-small);
9947
+ }
9948
+ .ui-fp-label.is-empty .ui-fp-state {
9949
+ color: var(--ink-muted);
9950
+ font-weight: 400;
9951
+ }
9952
+ /* One line on a pill of its own ground: slender zones, and zones too small for the full label. */
9953
+ .ui-fp-pill {
9954
+ padding: 0 8px;
9955
+ border: 1px solid var(--line-strong);
9956
+ border-radius: var(--radius-full);
9957
+ background: var(--surface);
9958
+ color: var(--ink);
9959
+ font-size: var(--text-small);
9960
+ font-weight: 600;
9961
+ line-height: 22px;
9962
+ text-align: center;
9963
+ }
9964
+ .ui-fp-pill.is-empty {
9965
+ color: var(--ink-muted);
9966
+ }
9967
+ .ui-fp-num {
9968
+ font-family: var(--font-mono);
9969
+ font-variant-numeric: tabular-nums;
9970
+ }
9971
+ .ui-fp-group-name {
9972
+ padding: 0 6px;
9973
+ border-radius: var(--radius-xs);
9974
+ background: var(--surface);
9975
+ color: var(--ink-muted);
9976
+ font-size: var(--text-small);
9977
+ font-weight: 600;
9978
+ line-height: 22px;
9979
+ }
9980
+
9981
+ /* Tooltip: the look of Tooltip, beside the pointer (or the label point, for keyboard focus). */
9982
+ .ui-fp-tip {
9983
+ position: absolute;
9984
+ z-index: var(--z-raised);
9985
+ display: flex;
9986
+ flex-direction: column;
9987
+ max-width: 240px;
9988
+ padding: 6px 10px;
9989
+ border-radius: var(--radius-chip);
9990
+ background: var(--ink);
9991
+ color: var(--bg);
9992
+ font-size: var(--text-small);
9993
+ line-height: 20px;
9994
+ pointer-events: none;
9995
+ }
9996
+ .ui-fp-tip-name {
9997
+ font-weight: 600;
9998
+ }
9999
+
10000
+ .ui-fp-controls {
10001
+ position: absolute;
10002
+ right: var(--space-2);
10003
+ bottom: var(--space-2);
10004
+ display: flex;
10005
+ gap: var(--space-1);
10006
+ }
10007
+ .ui-fp-controls > * {
10008
+ background: var(--surface);
10009
+ }
10010
+
10011
+ /* Legend: the heat scale with its ends, the watch and limit marks, and a note when there are muted zones. */
10012
+ .ui-fp-legend {
10013
+ display: flex;
10014
+ flex-wrap: wrap;
10015
+ align-items: center;
10016
+ gap: var(--space-2) var(--space-4);
10017
+ color: var(--ink-muted);
10018
+ font-size: var(--text-small);
10019
+ line-height: 20px;
10020
+ }
10021
+ .ui-fp-scale {
10022
+ display: inline-flex;
10023
+ align-items: center;
10024
+ gap: var(--space-2);
10025
+ }
10026
+ .ui-fp-bar {
10027
+ position: relative;
10028
+ display: inline-flex;
10029
+ width: 168px;
10030
+ height: 12px;
10031
+ border-radius: var(--radius-xs);
10032
+ }
10033
+ .ui-fp-bar > span:not(.ui-fp-tick) {
10034
+ flex: 1;
10035
+ }
10036
+ .ui-fp-bar > span:first-child {
10037
+ border-radius: var(--radius-xs) 0 0 var(--radius-xs);
10038
+ }
10039
+ .ui-fp-bar > span:nth-child(7) {
10040
+ border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
10041
+ }
10042
+ .ui-fp-tick {
10043
+ position: absolute;
10044
+ top: -4px;
10045
+ width: 2px;
10046
+ height: 20px;
10047
+ margin-left: -1px;
10048
+ }
10049
+ .ui-fp-tick.is-warning,
10050
+ .ui-fp-key.is-warning::before {
10051
+ background: var(--warning);
10052
+ }
10053
+ .ui-fp-tick.is-danger,
10054
+ .ui-fp-key.is-danger::before {
10055
+ background: var(--danger);
10056
+ }
10057
+ .ui-fp-key {
10058
+ display: inline-flex;
10059
+ align-items: center;
10060
+ gap: 6px;
10061
+ }
10062
+ .ui-fp-key::before {
10063
+ content: '';
10064
+ width: 2px;
10065
+ height: 14px;
10066
+ }
10067
+ .ui-fp-key.is-muted::before {
10068
+ width: 14px;
10069
+ border-radius: 3px;
10070
+ background: color-mix(in srgb, var(--heat-4) 40%, var(--surface));
10071
+ box-shadow: inset 0 0 0 1px var(--line);
10072
+ }
10073
+ .ui-fp-pill .ui-fp-unit {
10074
+ font-size: inherit;
10075
+ font-weight: inherit;
10076
+ }
9810
10077
  /* EventTimeline: newest first; time, kind icon (no fill), what happened. */
9811
10078
  .ui-events {
9812
10079
  margin: 0;
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 用法
4
4
 
5
- 資料用的顏色:圖表的類別色、熱度色階、差值發散色階,以及預測值的斜線紋理;全部有淺色與深色兩套,由 `tokens.css` 提供。用 LineChart、BarChart、ZoneMap 時已經套好;自己畫資料時讀這份。
5
+ 資料用的顏色:圖表的類別色、熱度色階、差值發散色階,以及預測值的斜線紋理;全部有淺色與深色兩套,由 `tokens.css` 提供。用 LineChart、BarChart、ZoneMap、FloorPlan 時已經套好;自己畫資料時讀這份。
6
6
 
7
7
  ```js
8
8
  h('div', { style: { background: 'var(--' + UI.heatToken(24.6, 20, 30) + ')', color: UI.textOn(UI.heatToken(24.6, 20, 30)) } }, '24.6 °C');
@@ -0,0 +1,43 @@
1
+ # FloorPlan
2
+
3
+ ## 用法
4
+
5
+ 多邊形平面圖:分區是任意外框(L 形、凹形、分成好幾塊、有洞),依數值填熱度色階,每區寫名稱、主數值和狀態,可以縮放平移。分區排在規則格線上時用 ZoneMap。
6
+
7
+ ```js
8
+ h(UI.FloorPlan, {
9
+ label: '機房平面圖',
10
+ value: sel,
11
+ onChange: setSel,
12
+ min: 20, max: 30, warn: 27, limit: 30,
13
+ groups: [{ id: 'north', name: '北側機櫃列' }],
14
+ zones: [
15
+ { id: 'a', name: '冷通道 A', value: 23.1, unit: '°C', outline: [[[[2, 2], [14, 2], [14, 8], [8, 8], [8, 14], [2, 14]]]], label: [5, 5] },
16
+ { id: 'f', name: '機櫃區 F', value: 29.6, unit: '°C', tone: 'danger', state: '超過上限', group: 'north', outline: [[[[16, 17], [26, 17], [26, 22], [16, 22]]]], label: [21, 19.5] },
17
+ { id: 'e', name: '走道 E', value: 22.4, unit: '°C', emphasis: 'muted', outline: [[[[16, 14], [38, 14], [38, 16], [16, 16]]]], label: [27, 15] },
18
+ ],
19
+ });
20
+ ```
21
+
22
+ - 分區的欄位和 ZoneMap 的 `Zone` 相同(`tone`、`state`、`forecast`、`detail`、`fill`、`value: null` 是沒有資料),`area` 換成 `outline` 和 `label`。
23
+ - `outline` 是 MultiPolygon,單位公尺,y 向上是北:`[多邊形][環][點][x, y]`,每個多邊形的第一個環是外框,其餘是洞。元件自己翻轉 y、算出視角。
24
+ - `label` 是標籤的位置,由呼叫端算好(例如內部離邊最遠的點),一定要在外框裡。
25
+ - 寬度小於 600 px 時圖很小,大部分標籤會被捨棄:旁邊附 DataTable 的清單檢視,列出同樣的分區。
26
+ - `warn`、`limit` 只畫在圖例上,數值由呼叫端給,元件不假設門檻。
27
+
28
+ ## 細節
29
+
30
+ - 標籤:在分區裡放得下時寫名稱(16 px 半粗)、主數值(25 px Geist Mono,單位 16 px)和狀態(13 px 半粗);外框包圍盒長寬比大於 4 的細長分區,或完整標籤放不下時,改用一行膠囊(13 px,`surface` 底);膠囊也會和別的標籤重疊時不顯示。標籤一律同樣大小,放大後放得下的就會出現。
31
+ - 標籤的優先序:primary 在 muted 之前,各自面積小的先;被捨棄的分區仍然有游標提示,也在 Tab 順序裡。
32
+ - `emphasis: 'muted'`:次要區域,填色是原色 40 % 混 `surface`,標籤 13 px 名稱加 16 px 數值,字用 `ink`;可以選,`tone` 的 4 px 內框和「⚠」照常顯示;螢幕閱讀器多念「次要」。有 muted 分區時圖例多一行「淡色=次要區域」。
33
+ - 填色、字色、4 px 注意內框、預測斜線、沒有資料的虛線框、數值和單位之間的空格,都和 ZoneMap 相同(見 `ui docs ZoneMap`)。
34
+ - 選取:`ink` 色 2 px 外框,在分區外 4 px。鍵盤焦點:`focus` 色 2 px 外框,緊貼分區外側,並顯示提示。
35
+ - `groups`:同一組的分區外面畫一圈 1.5 px `ink-muted` 細框(沿著整組的外形),左上角寫組名(13 px)。不計算也不顯示整組的數值。
36
+ - `shell`:建築外框,`surface-sub` 底加 `line-strong` 邊。`edges`:分區之間的邊界,1.5 px `ink-muted` 虛線。
37
+ - 縮放與平移:滾輪、雙指縮放、拖曳平移;右下角「放大」「縮小」「重設視角」;鍵盤在圖上(包括分區上)按 + − 縮放、方向鍵平移。最多放大 8 倍,全景時不能平移。按鈕和鍵盤的變化有 200 ms 的動畫,`prefers-reduced-motion` 時直接跳過去。拖曳超過 4 px 不算點選。
38
+ - 鍵盤:每個分區是按鈕,Tab 順序和標籤的優先序相同;Enter 或空白鍵選取(`aria-pressed`)。螢幕閱讀器念「機櫃區 F,29.6 °C,超過上限,進氣 27.9 °C」。沒有資料的分區不能選。
39
+ - 提示:滑鼠停在分區上或鍵盤聚焦時顯示名稱、數值、狀態、`detail`。
40
+ - 觸控:寬度小於 600 px 或觸控螢幕上,畫面上小於 48 px 的分區在標籤位置多一個 48 px 的圓形點擊範圍。圖上的手勢都交給地圖(`touch-action: none`),頁面要在圖外捲動。
41
+ - 大小:沒有 `fill` 時照外框的比例,高 240~640 px;放在 ConsoleLayout 的主視覺卡片裡時加 `fill`,撐滿卡片的高度(最少 240 px),和 ZoneMap 的 `fill` 相同。
42
+ - 標籤的寬度用固定的估算(中文 1 em、Geist Mono 0.6 em),網頁字型載入前後、伺服器渲染時排法都一樣。
43
+ - 30 個分區、每區 30 個點時,縮放與游標提示只重算標籤位置,路徑不重算。
package/docs/ZoneMap.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 用法
4
4
 
5
- 分區平面圖:分區是格線上的矩形,依數值填熱度色階,每區寫名稱、狀態、主數值和一行次要資訊。
5
+ 分區平面圖:分區是格線上的矩形,依數值填熱度色階,每區寫名稱、狀態、主數值和一行次要資訊。分區是任意多邊形時用 FloorPlan。
6
6
 
7
7
  ```js
8
8
  h(UI.ZoneMap, {
@@ -28,7 +28,7 @@ h(UI.ZoneMap, {
28
28
  - 填色:沒給 `fill` 時,用 `value` 在 `min`~`max` 之間對應 `heat-1`…`heat-7`。`min`、`max` 預設是各分區數值的最小值和最大值,溫度、濕度、負載都適用;要固定的範圍(例如溫度 20~30 °C,不同時間的地圖顏色才能比較)時自己給。字的顏色自動選深色或白色(`textOn()`),跟著主題切換。
29
29
  - 選取:`ink` 色 2 px 外框,在分區外 4 px。
30
30
  - 沒有資料(`value` 是 `null`):虛線框,名稱加「沒有資料」,不能選。
31
- - 位置:`area: { row, col, rows, cols }`(從 1 開始);沒給時依序排入 `columns` 欄(預設 4)、每列 `rowHeight` px(預設 120)。目前只有矩形。
31
+ - 位置:`area: { row, col, rows, cols }`(從 1 開始);沒給時依序排入 `columns` 欄(預設 4)、每列 `rowHeight` px(預設 120)。只有矩形;任意多邊形用 FloorPlan。
32
32
  - `fill`:列高平分地圖拿到的高度,最少 `rowHeight` px,不留空白。
33
33
  - 選取是受控的 `value`(選中分區的 `id`)加 `onChange(id, zone)`。
34
34
  - 數值和單位之間有一個空格,畫面上寫「23.1 °C」,和按鈕的名稱一樣(WCAG 2.5.3)。
package/docs/agents.md CHANGED
@@ -65,11 +65,11 @@ export default [ui.configs.recommended];
65
65
  ```html
66
66
  <meta charset="utf-8">
67
67
  <meta name="viewport" content="width=device-width, initial-scale=1">
68
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/fonts.css">
69
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/tokens.css">
70
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/styles.css">
68
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.49.0/fonts.css">
69
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.49.0/tokens.css">
70
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.49.0/styles.css">
71
71
  <div id="root"></div>
72
- <script src="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/bundle.js"></script>
72
+ <script src="https://seanyeh77.github.io/ui-design-system/dist/0.49.0/bundle.js"></script>
73
73
  <script>
74
74
  const h = React.createElement;
75
75
  UI.initTheme();
@@ -77,6 +77,6 @@ export default [ui.configs.recommended];
77
77
  </script>
78
78
  ```
79
79
 
80
- Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.48.3/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.48.3/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
80
+ Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.49.0/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.49.0/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
81
81
 
82
82
  Scope: web UI, and the tokens of SeanYeh's Slidev decks (`initTheme({ preset: 'teaching' })`, see `theme.md`). Slide layout, Notion documents and teaching diagrams follow the separate `teaching-materials-style` skill.
@@ -107,6 +107,10 @@
107
107
  "name": "FileUpload",
108
108
  "group": "Forms"
109
109
  },
110
+ {
111
+ "name": "FloorPlan",
112
+ "group": "Monitoring"
113
+ },
110
114
  {
111
115
  "name": "FormGrid",
112
116
  "group": "Forms"
package/docs/data.md CHANGED
@@ -16,7 +16,8 @@
16
16
  | 類別比較 | `BarChart` |
17
17
  | 知道進度 | `ProgressBar`;不知道要多久用 `LoadingBar`;達成率用 `ProgressRing` |
18
18
  | 數值和它的界線 | `Meter` |
19
- | 依數值上色的平面圖 | `ZoneMap` |
19
+ | 依數值上色的平面圖,分區在格線上 | `ZoneMap` |
20
+ | 依數值上色的平面圖,分區是任意多邊形 | `FloorPlan`(何時用哪個見 [monitoring.md](monitoring.md)) |
20
21
  | 元件架構 | `LayerGraph`;其他方框與箭頭的圖用 Graph 的 class |
21
22
 
22
23
  ## 表格與結果清單
@@ -14,13 +14,19 @@
14
14
 
15
15
  | 用途 | 元件 |
16
16
  |---|---|
17
- | 分區平面圖,依數值填熱度色 | `ZoneMap`(名稱 16 px 和狀態同一行,主數值 31 px,次要資訊 13 px) |
17
+ | 分區平面圖,分區排在規則格線上(矩形) | `ZoneMap`(名稱 16 px 和狀態同一行,主數值 31 px,次要資訊 13 px) |
18
+ | 分區平面圖,分區是任意多邊形(建築模型算出的外框、L 形、有洞),可縮放 | `FloorPlan`(名稱 16 px,主數值 25 px,狀態 13 px;放不下的標籤改膠囊或捨棄) |
18
19
  | 事件列表,由新到舊 | `EventTimeline`(時間、類型圖示、說明) |
19
20
  | 時鐘、回放、回到現在 | `TimeControl`(直排,時鐘 28 px) |
20
21
  | 預測與實際、節能的折線 | `LineChart`(`dashed`、`band`、`now`、`thresholds`、`marker`、`playhead`、`headline`) |
21
22
  | 沿時間軸的狀態色帶 | `StatusBand`(12 px,貼在折線圖底部,名稱寫在圖例) |
22
23
  | 數值和注意線、上限 | `Meter` |
23
24
 
25
+ ## 平面圖
26
+
27
+ - 分區能排成格線(每區一格或跨幾格)時用 `ZoneMap`:每區都有完整的字,最好讀。分區的外框來自圖面或建築模型、形狀不規則時用 `FloorPlan`:位置和形狀照實際,字放不下時改成膠囊或只在游標提示裡。
28
+ - 兩者的填色、注意、預測、沒有資料、選取的樣子相同,同一頁可以並用。FloorPlan 在手機上旁邊附 DataTable 的清單檢視。
29
+
24
30
  ## 圖表
25
31
 
26
32
  - 預測與實際的圖:實際是實線,預測是虛線(`chart-3`);「現在」是一條實線,之後的未來區疊預測斜線;注意線和上限是 1.5 px 的 `warning`/`danger` 虛線,標籤靠右寫在線上方;下一回合的單點預測是空心圓加標籤。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seanyeh77/ui",
3
- "version": "0.48.3",
3
+ "version": "0.49.0",
4
4
  "description": "SeanYeh's design system: typed React components on Base UI, styled with design tokens.",
5
5
  "license": "MIT",
6
6
  "author": "Hsiu-An Yeh",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@base-ui/react": "^1.9.0",
61
- "@seanyeh77/tokens": "^0.48.3"
61
+ "@seanyeh77/tokens": "^0.49.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",