@kanso-labs/react-native-kanso-ui 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/README.md +205 -2
- package/dist/button/index.d.ts +56 -0
- package/dist/button/index.js +169 -0
- package/dist/button/index.js.map +1 -0
- package/dist/button/palettes.js +47 -0
- package/dist/button/palettes.js.map +1 -0
- package/dist/chip/index.js +194 -0
- package/dist/chip/index.js.map +1 -0
- package/dist/chip/styles.js +36 -0
- package/dist/chip/styles.js.map +1 -0
- package/dist/clipboard/index.js +58 -0
- package/dist/clipboard/index.js.map +1 -0
- package/dist/components/avatar/index.d.ts +82 -0
- package/dist/components/avatar/index.js +62 -0
- package/dist/components/avatar/index.js.map +1 -0
- package/dist/components/button/index.d.ts +87 -0
- package/dist/components/button/index.js +377 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/card/index.d.ts +78 -0
- package/dist/components/card/index.js +315 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +76 -0
- package/dist/components/checkbox/index.js +360 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/chip/index.d.ts +84 -0
- package/dist/components/chip/index.js +257 -0
- package/dist/components/chip/index.js.map +1 -0
- package/dist/components/chip-group/index.d.ts +143 -0
- package/dist/components/chip-group/index.js +669 -0
- package/dist/components/chip-group/index.js.map +1 -0
- package/dist/components/copy-field/index.d.ts +60 -0
- package/dist/components/copy-field/index.js +277 -0
- package/dist/components/copy-field/index.js.map +1 -0
- package/dist/components/currency/index.d.ts +69 -0
- package/dist/components/currency/index.js +162 -0
- package/dist/components/currency/index.js.map +1 -0
- package/dist/components/form/index.d.ts +84 -0
- package/dist/components/form/index.js +95 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/icon-button/index.d.ts +68 -0
- package/dist/components/icon-button/index.js +289 -0
- package/dist/components/icon-button/index.js.map +1 -0
- package/dist/components/link/index.d.ts +59 -0
- package/dist/components/link/index.js +191 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/number-field/index.d.ts +151 -0
- package/dist/components/number-field/index.js +832 -0
- package/dist/components/number-field/index.js.map +1 -0
- package/dist/components/product-icon/index.d.ts +70 -0
- package/dist/components/product-icon/index.js +60 -0
- package/dist/components/product-icon/index.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +105 -0
- package/dist/components/radio-group/index.js +597 -0
- package/dist/components/radio-group/index.js.map +1 -0
- package/dist/components/search-field/index.d.ts +98 -0
- package/dist/components/search-field/index.js +521 -0
- package/dist/components/search-field/index.js.map +1 -0
- package/dist/components/segmented-button/index.d.ts +113 -0
- package/dist/components/segmented-button/index.js +937 -0
- package/dist/components/segmented-button/index.js.map +1 -0
- package/dist/components/separator/index.d.ts +45 -0
- package/dist/components/separator/index.js +109 -0
- package/dist/components/separator/index.js.map +1 -0
- package/dist/components/stack/index.d.ts +70 -0
- package/dist/components/stack/index.js +107 -0
- package/dist/components/stack/index.js.map +1 -0
- package/dist/components/switch/index.d.ts +76 -0
- package/dist/components/switch/index.js +591 -0
- package/dist/components/switch/index.js.map +1 -0
- package/dist/components/text/index.d.ts +44 -0
- package/dist/components/text/index.js +78 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text-field/index.d.ts +146 -0
- package/dist/components/text-field/index.js +228 -0
- package/dist/components/text-field/index.js.map +1 -0
- package/dist/control/index.js +117 -0
- package/dist/control/index.js.map +1 -0
- package/dist/control/styles.js +36 -0
- package/dist/control/styles.js.map +1 -0
- package/dist/field/index.d.ts +13 -0
- package/dist/field/index.js +1007 -0
- package/dist/field/index.js.map +1 -0
- package/dist/field/styles.js +131 -0
- package/dist/field/styles.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +209 -0
- package/dist/form/index.js.map +1 -0
- package/dist/glyphs/icon-style.d.ts +25 -0
- package/dist/glyphs/icon-style.js +22 -0
- package/dist/glyphs/icon-style.js.map +1 -0
- package/dist/glyphs/index.js +170 -0
- package/dist/glyphs/index.js.map +1 -0
- package/dist/glyphs/styles.js +7 -0
- package/dist/glyphs/styles.js.map +1 -0
- package/dist/hooks/useWindowSizeClass.d.ts +25 -0
- package/dist/hooks/useWindowSizeClass.js +39 -0
- package/dist/hooks/useWindowSizeClass.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +27 -0
- package/dist/mark/image.js +61 -0
- package/dist/mark/image.js.map +1 -0
- package/dist/mark/index.d.ts +9 -0
- package/dist/mark/index.js +234 -0
- package/dist/mark/index.js.map +1 -0
- package/dist/mark/initials.js +65 -0
- package/dist/mark/initials.js.map +1 -0
- package/dist/mark/styles.d.ts +1 -0
- package/dist/mark/styles.js +73 -0
- package/dist/mark/styles.js.map +1 -0
- package/dist/number/parser.js +321 -0
- package/dist/number/parser.js.map +1 -0
- package/dist/number/state.js +235 -0
- package/dist/number/state.js.map +1 -0
- package/dist/overlay/host.js +111 -0
- package/dist/overlay/host.js.map +1 -0
- package/dist/press/index.js +350 -0
- package/dist/press/index.js.map +1 -0
- package/dist/press/styles.js +31 -0
- package/dist/press/styles.js.map +1 -0
- package/dist/router/index.d.ts +28 -0
- package/dist/router/index.js +82 -0
- package/dist/router/index.js.map +1 -0
- package/dist/theme/color.js +25 -0
- package/dist/theme/color.js.map +1 -0
- package/dist/theme/resolve.d.ts +6 -0
- package/dist/theme/resolve.js +310 -0
- package/dist/theme/resolve.js.map +1 -0
- package/dist/theme/scope.d.ts +42 -0
- package/dist/theme/scope.js +80 -0
- package/dist/theme/scope.js.map +1 -0
- package/dist/theme/styles.js +39 -0
- package/dist/theme/styles.js.map +1 -0
- package/dist/theme-scope.d.ts +56 -0
- package/dist/theme-scope.js +127 -0
- package/dist/theme-scope.js.map +1 -0
- package/dist/tokens/defaults.d.ts +407 -0
- package/dist/tokens/defaults.js +403 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/typography/fonts.js +84 -0
- package/dist/typography/fonts.js.map +1 -0
- package/dist/typography/roles.d.ts +10 -0
- package/dist/typography/roles.js +82 -0
- package/dist/typography/roles.js.map +1 -0
- package/package.json +132 -4
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useIconStyle } from "./icon-style.js";
|
|
2
|
+
import { glyphStyles } from "./styles.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { I18nManager, Platform, StyleSheet } from "react-native";
|
|
5
|
+
import Svg, { Path } from "react-native-svg";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/glyphs/index.tsx
|
|
8
|
+
const HIDDEN = Platform.select({
|
|
9
|
+
default: {
|
|
10
|
+
accessibilityElementsHidden: true,
|
|
11
|
+
importantForAccessibility: "no-hide-descendants"
|
|
12
|
+
},
|
|
13
|
+
web: { "aria-hidden": true }
|
|
14
|
+
});
|
|
15
|
+
function CheckGlyph(props) {
|
|
16
|
+
const $ = c(3);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" });
|
|
20
|
+
$[0] = t0;
|
|
21
|
+
} else t0 = $[0];
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[1] !== props) {
|
|
24
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
25
|
+
...props,
|
|
26
|
+
children: t0
|
|
27
|
+
});
|
|
28
|
+
$[1] = props;
|
|
29
|
+
$[2] = t1;
|
|
30
|
+
} else t1 = $[2];
|
|
31
|
+
return t1;
|
|
32
|
+
}
|
|
33
|
+
function CloseGlyph(props) {
|
|
34
|
+
const $ = c(3);
|
|
35
|
+
let t0;
|
|
36
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
37
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" });
|
|
38
|
+
$[0] = t0;
|
|
39
|
+
} else t0 = $[0];
|
|
40
|
+
let t1;
|
|
41
|
+
if ($[1] !== props) {
|
|
42
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
43
|
+
...props,
|
|
44
|
+
children: t0
|
|
45
|
+
});
|
|
46
|
+
$[1] = props;
|
|
47
|
+
$[2] = t1;
|
|
48
|
+
} else t1 = $[2];
|
|
49
|
+
return t1;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The svg every glyph draws: the 24-unit grid its path is on, a square of the
|
|
53
|
+
* slot's size filled in the slot's colour, and nothing a screen reader
|
|
54
|
+
* announces, since the control around a glyph carries the name. A glyph whose
|
|
55
|
+
* direction means "onward" or "back" passes `mirrored`, which turns it over
|
|
56
|
+
* under a right-to-left layout as `:dir(rtl)` does on web.
|
|
57
|
+
*/
|
|
58
|
+
function Glyph(t0) {
|
|
59
|
+
const $ = c(9);
|
|
60
|
+
const { children, color, mirrored: t1, size, style, testID } = t0;
|
|
61
|
+
const mirrored = t1 === void 0 ? false : t1;
|
|
62
|
+
const slot = useIconStyle();
|
|
63
|
+
const side = size ?? slot.size;
|
|
64
|
+
const t2 = color ?? slot.color;
|
|
65
|
+
let t3;
|
|
66
|
+
if ($[0] !== mirrored || $[1] !== style) {
|
|
67
|
+
t3 = StyleSheet.compose(mirrored && I18nManager.isRTL ? glyphStyles.mirrored : void 0, style);
|
|
68
|
+
$[0] = mirrored;
|
|
69
|
+
$[1] = style;
|
|
70
|
+
$[2] = t3;
|
|
71
|
+
} else t3 = $[2];
|
|
72
|
+
let t4;
|
|
73
|
+
if ($[3] !== children || $[4] !== side || $[5] !== t2 || $[6] !== t3 || $[7] !== testID) {
|
|
74
|
+
t4 = /* @__PURE__ */ jsx(Svg, {
|
|
75
|
+
...HIDDEN,
|
|
76
|
+
color: t2,
|
|
77
|
+
fill: "currentColor",
|
|
78
|
+
height: side,
|
|
79
|
+
style: t3,
|
|
80
|
+
testID,
|
|
81
|
+
viewBox: "0 0 24 24",
|
|
82
|
+
width: side,
|
|
83
|
+
children
|
|
84
|
+
});
|
|
85
|
+
$[3] = children;
|
|
86
|
+
$[4] = side;
|
|
87
|
+
$[5] = t2;
|
|
88
|
+
$[6] = t3;
|
|
89
|
+
$[7] = testID;
|
|
90
|
+
$[8] = t4;
|
|
91
|
+
} else t4 = $[8];
|
|
92
|
+
return t4;
|
|
93
|
+
}
|
|
94
|
+
function MinusGlyph(props) {
|
|
95
|
+
const $ = c(3);
|
|
96
|
+
let t0;
|
|
97
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
98
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M19 13H5v-2h14v2z" });
|
|
99
|
+
$[0] = t0;
|
|
100
|
+
} else t0 = $[0];
|
|
101
|
+
let t1;
|
|
102
|
+
if ($[1] !== props) {
|
|
103
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
104
|
+
...props,
|
|
105
|
+
children: t0
|
|
106
|
+
});
|
|
107
|
+
$[1] = props;
|
|
108
|
+
$[2] = t1;
|
|
109
|
+
} else t1 = $[2];
|
|
110
|
+
return t1;
|
|
111
|
+
}
|
|
112
|
+
const IndeterminateGlyph = MinusGlyph;
|
|
113
|
+
function PersonGlyph(props) {
|
|
114
|
+
const $ = c(3);
|
|
115
|
+
let t0;
|
|
116
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
117
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" });
|
|
118
|
+
$[0] = t0;
|
|
119
|
+
} else t0 = $[0];
|
|
120
|
+
let t1;
|
|
121
|
+
if ($[1] !== props) {
|
|
122
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
123
|
+
...props,
|
|
124
|
+
children: t0
|
|
125
|
+
});
|
|
126
|
+
$[1] = props;
|
|
127
|
+
$[2] = t1;
|
|
128
|
+
} else t1 = $[2];
|
|
129
|
+
return t1;
|
|
130
|
+
}
|
|
131
|
+
function PlusGlyph(props) {
|
|
132
|
+
const $ = c(3);
|
|
133
|
+
let t0;
|
|
134
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
135
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" });
|
|
136
|
+
$[0] = t0;
|
|
137
|
+
} else t0 = $[0];
|
|
138
|
+
let t1;
|
|
139
|
+
if ($[1] !== props) {
|
|
140
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
141
|
+
...props,
|
|
142
|
+
children: t0
|
|
143
|
+
});
|
|
144
|
+
$[1] = props;
|
|
145
|
+
$[2] = t1;
|
|
146
|
+
} else t1 = $[2];
|
|
147
|
+
return t1;
|
|
148
|
+
}
|
|
149
|
+
function SearchGlyph(props) {
|
|
150
|
+
const $ = c(3);
|
|
151
|
+
let t0;
|
|
152
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
153
|
+
t0 = /* @__PURE__ */ jsx(Path, { d: "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" });
|
|
154
|
+
$[0] = t0;
|
|
155
|
+
} else t0 = $[0];
|
|
156
|
+
let t1;
|
|
157
|
+
if ($[1] !== props) {
|
|
158
|
+
t1 = /* @__PURE__ */ jsx(Glyph, {
|
|
159
|
+
...props,
|
|
160
|
+
children: t0
|
|
161
|
+
});
|
|
162
|
+
$[1] = props;
|
|
163
|
+
$[2] = t1;
|
|
164
|
+
} else t1 = $[2];
|
|
165
|
+
return t1;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { CheckGlyph, CloseGlyph, IndeterminateGlyph, MinusGlyph, PersonGlyph, PlusGlyph, SearchGlyph };
|
|
169
|
+
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactNode","ColorValue","StyleProp","ViewStyle","SvgProps","I18nManager","Platform","StyleSheet","Svg","Path","useIconStyle","glyphStyles","GlyphProps","color","size","style","testID","HIDDEN","select","default","accessibilityElementsHidden","importantForAccessibility","web","ArrowBackGlyph","props","$","_c","t0","Symbol","for","t1","ArrowDownwardGlyph","ArrowDropDownGlyph","ArrowUpwardGlyph","CalendarGlyph","CheckGlyph","ChevronDownGlyph","ChevronEndGlyph","ClockGlyph","CloseGlyph","Glyph","children","mirrored","undefined","slot","side","t2","t3","compose","isRTL","t4","KeyboardGlyph","MinusGlyph","IndeterminateGlyph","PersonGlyph","PlusGlyph","SearchGlyph","_c"],"sources":["../../src/glyphs/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { ColorValue, StyleProp, ViewStyle } from 'react-native'\nimport type { SvgProps } from 'react-native-svg'\n\nimport { I18nManager, Platform, StyleSheet } from 'react-native'\nimport Svg, { Path } from 'react-native-svg'\n\nimport { useIconStyle } from './icon-style'\nimport { glyphStyles } from './styles'\n\n// The glyphs the library's own controls draw, the same set kanso-ui draws on\n// web: the check and the dash a checkbox shows, the plus and minus a number\n// field's steppers show, the magnifier and cross a search field shows, and the\n// rest named beside each one. Private to the library, as on web: a call site\n// with icons of its own passes them to the slots that take a node, and reads\n// the slot's colour and size through `useIconStyle()`.\n//\n// The paths are kanso-ui's, unchanged: Material Symbols on their 24-unit grid,\n// which is what the checkbox page draws at 18dp, the icon buttons page at 20\n// and the search, menus, date picker and time picker pages at 24.\n\ntype GlyphProps = {\n /** The fill. Defaults to the colour of the slot the glyph sits in. */\n readonly color?: ColorValue\n /** The square's side in dp. Defaults to the size of the slot. */\n readonly size?: number\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n}\n\n// What hides a glyph from screen readers. On iOS and Android that is React\n// Native's two props, one for VoiceOver and one for TalkBack. Under React\n// Native Web, react-native-svg hands its props to the `<svg>` as they are, so\n// it is `aria-hidden` there, which is the one the browser reads.\nconst HIDDEN = Platform.select<SvgProps>({\n default: {\n accessibilityElementsHidden: true,\n importantForAccessibility: 'no-hide-descendants',\n },\n web: { 'aria-hidden': true },\n})\n\n// What a search view's back button draws, pointing at the page it returns to.\n// It says \"back\" rather than \"to the left\", so it mirrors under a right-to-left\n// layout.\nfunction ArrowBackGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\" />\n </Glyph>\n )\n}\n\n// Which way a sorted column is ordered. Up is ascending and down is\n// descending. Neither mirrors under a right-to-left layout: they say \"up\" and\n// \"down\" rather than \"onward\", and those do not flip.\nfunction ArrowDownwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n </Glyph>\n )\n}\n\n// What a menu button draws after its label, pointing at the list it opens.\n// Down is down in either writing direction, so it does not mirror.\nfunction ArrowDropDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M7 10l5 5 5-5z\" />\n </Glyph>\n )\n}\n\nfunction ArrowUpwardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n </Glyph>\n )\n}\n\n// What the date picker's trigger draws: the calendar a date is picked from.\nfunction CalendarGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 4h-1V2h-2v2H8V2H6v2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z\" />\n </Glyph>\n )\n}\n\nfunction CheckGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z\" />\n </Glyph>\n )\n}\n\n// Points down at the menu a split button's second half opens.\nfunction ChevronDownGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z\" />\n </Glyph>\n )\n}\n\n// Points at the submenu a menu item opens. It says \"further in\" rather than\n// \"to the right\", so it mirrors under a right-to-left layout.\nfunction ChevronEndGlyph(props: GlyphProps) {\n return (\n <Glyph {...props} mirrored>\n <Path d=\"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\" />\n </Glyph>\n )\n}\n\n// What the time picker's trigger draws, and the button that takes its keyboard\n// entry back to the dial: the clock a time is picked from.\nfunction ClockGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z\" />\n </Glyph>\n )\n}\n\nfunction CloseGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\" />\n </Glyph>\n )\n}\n\n/**\n * The svg every glyph draws: the 24-unit grid its path is on, a square of the\n * slot's size filled in the slot's colour, and nothing a screen reader\n * announces, since the control around a glyph carries the name. A glyph whose\n * direction means \"onward\" or \"back\" passes `mirrored`, which turns it over\n * under a right-to-left layout as `:dir(rtl)` does on web.\n */\nfunction Glyph({\n children,\n color,\n mirrored = false,\n size,\n style,\n testID,\n}: GlyphProps & { readonly children: ReactNode; readonly mirrored?: boolean }) {\n const slot = useIconStyle()\n const side = size ?? slot.size\n return (\n <Svg\n {...HIDDEN}\n color={color ?? slot.color}\n fill=\"currentColor\"\n height={side}\n style={StyleSheet.compose(\n mirrored && I18nManager.isRTL ? glyphStyles.mirrored : undefined,\n style,\n )}\n testID={testID}\n viewBox=\"0 0 24 24\"\n width={side}\n >\n {children}\n </Svg>\n )\n}\n\n// What the time picker's dial draws on the button that switches it to typed\n// entry.\nfunction KeyboardGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 12H4V7h16v10zm-9-9h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-3 0h2v2H5zm0-3h2v2H5zm3 6h8v2H8zm6-3h2v2h-2zm0-3h2v2h-2zm3 3h2v2h-2zm0-3h2v2h-2z\" />\n </Glyph>\n )\n}\n\n// The same rule stands for a partly selected checkbox and for a stepper's\n// decrement; the two names say which is meant at the call site.\nfunction MinusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13H5v-2h14v2z\" />\n </Glyph>\n )\n}\n\nconst IndeterminateGlyph = MinusGlyph\n\n// What an avatar with no name to take initials from draws: Material Design's\n// anonymous person, a head over shoulders.\nfunction PersonGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\" />\n </Glyph>\n )\n}\n\nfunction PlusGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\" />\n </Glyph>\n )\n}\n\nfunction SearchGlyph(props: GlyphProps) {\n return (\n <Glyph {...props}>\n <Path d=\"M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\" />\n </Glyph>\n )\n}\n\nexport {\n ArrowBackGlyph,\n ArrowDownwardGlyph,\n ArrowDropDownGlyph,\n ArrowUpwardGlyph,\n CalendarGlyph,\n CheckGlyph,\n ChevronDownGlyph,\n ChevronEndGlyph,\n ClockGlyph,\n CloseGlyph,\n IndeterminateGlyph,\n KeyboardGlyph,\n MinusGlyph,\n PersonGlyph,\n PlusGlyph,\n SearchGlyph,\n}\nexport type { GlyphProps }\n"],"mappings":";;;;;;;AAkCA,MAAMiB,SAASX,SAASY,OAAiB;CACvCC,SAAS;EACPC,6BAA6B;EAC7BC,2BAA2B;CAC7B;CACAC,KAAK,EAAE,eAAe,KAAK;AAC7B,CAAC;AAmDD,SAAAa,WAAAX,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,oDAAmD,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADhEM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAiCZ,SAAAS,WAAAf,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,wGAAuG,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADpHM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;;;;;;;;AAWZ,SAAAU,MAAAb,IAAA;CAAA,MAAAF,IAAAC,EAAA,CAAA;CAAe,MAAA,EAAAe,UAAA5B,OAAA6B,UAAAZ,IAAAhB,MAAAC,OAAAC,WAAAW;CAGb,MAAAe,WAAAZ,OAAAa,KAAAA,IAAA,QAAAb;CAKA,MAAAc,OAAalC,aAAa;CAC1B,MAAAmC,OAAa/B,QAAQ8B,KAAI9B;CAId,MAAAgC,KAAAjC,SAAS+B,KAAI/B;CAAM,IAAAkC;CAAA,IAAAtB,EAAA,OAAAiB,YAAAjB,EAAA,OAAAV,OAAA;EAGnBgC,KAAAxC,WAAUyC,QACfN,YAAYrC,YAAW4C,QAAStC,YAAW+B,WAA3CC,KAAAA,GACA5B,KACF;EAACU,EAAA,KAAAiB;EAAAjB,EAAA,KAAAV;EAAAU,EAAA,KAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,IAAAyB;CAAA,IAAAzB,EAAA,OAAAgB,YAAAhB,EAAA,OAAAoB,QAAApB,EAAA,OAAAqB,MAAArB,EAAA,OAAAsB,MAAAtB,EAAA,OAAAT,QAAA;EARHkC,KAAA,oBAAC,KAAD;GAAI,GACEjC;GACG,OAAA6B;GACF,MAAA;GACGD,QAAAA;GACD,OAAAE;GAIC/B;GACA,SAAA;GACD6B,OAAAA;GAENJ;EAbC,CAAA;EAcEhB,EAAA,KAAAgB;EAAAhB,EAAA,KAAAoB;EAAApB,EAAA,KAAAqB;EAAArB,EAAA,KAAAsB;EAAAtB,EAAA,KAAAT;EAAAS,EAAA,KAAAyB;CAAA,OAAAA,KAAAzB,EAAA;CAAA,OAdNyB;AAcM;AAgBV,SAAAE,WAAA5B,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,oBAAmB,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADhCM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAIZ,MAAMuB,qBAAqBD;AAI3B,SAAAE,YAAA9B,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,gHAA+G,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EAD5HM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAIZ,SAAAyB,UAAA/B,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,sCAAqC,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADlDM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ;AAIZ,SAAA0B,YAAAhC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAGMF,KAAA,oBAAC,MAAD,EAAQ,GAAA,6MAA4M,CAAA;EAAGF,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAD,OAAA;EADzNM,KAAA,oBAAC,OAAD;GAAM,GAAKN;GACTG,UAAAA;EADI,CAAA;EAEEF,EAAA,KAAAD;EAAAC,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFRK;AAEQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","names":["StyleSheet","glyphStyles","create","mirrored","transform","scaleX"],"sources":["../../src/glyphs/styles.ts"],"sourcesContent":["import { StyleSheet } from 'react-native'\n\n// The glyphs' one style, apart from the glyphs in ./index.tsx so that file\n// exports components alone, which is what keeps fast refresh working for it.\nconst glyphStyles = StyleSheet.create({\n mirrored: {\n transform: [{ scaleX: -1 }],\n },\n})\n\nexport { glyphStyles }\n"],"mappings":";;AAIA,MAAMC,cAAcD,WAAWE,OAAO,EACpCC,UAAU,EACRC,WAAW,CAAC,EAAEC,QAAQ,GAAG,CAAC,EAC5B,EACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { breakpoints } from "../tokens/defaults.js";
|
|
2
|
+
//#region src/hooks/useWindowSizeClass.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Material Design's window size classes, which kanso-ui's breakpoint tokens
|
|
5
|
+
* bound: `compact` from 0, `medium` from 600dp, `expanded` from 840dp, `large`
|
|
6
|
+
* from 1200dp and `extraLarge` from 1600dp.
|
|
7
|
+
*/
|
|
8
|
+
type WindowSizeClass = keyof typeof breakpoints;
|
|
9
|
+
/**
|
|
10
|
+
* The window size class the app's window is in, by its width, as the library's
|
|
11
|
+
* own components lay themselves out by it. It changes as the window does: on
|
|
12
|
+
* rotation, in split screen, and when a foldable unfolds.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const sizeClass = useWindowSizeClass()
|
|
16
|
+
* const columns = sizeClass === 'compact' ? 1 : 2
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The classes are at
|
|
20
|
+
* https://m3.material.io/foundations/layout/applying-layout/window-size-classes.
|
|
21
|
+
*/
|
|
22
|
+
declare function useWindowSizeClass(): WindowSizeClass;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { type WindowSizeClass, useWindowSizeClass };
|
|
25
|
+
//# sourceMappingURL=useWindowSizeClass.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { breakpoints } from "../tokens/defaults.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { useWindowDimensions } from "react-native";
|
|
4
|
+
//#region src/hooks/useWindowSizeClass.ts
|
|
5
|
+
const CLASSES = [
|
|
6
|
+
"extraLarge",
|
|
7
|
+
"large",
|
|
8
|
+
"expanded",
|
|
9
|
+
"medium",
|
|
10
|
+
"compact"
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* The window size class the app's window is in, by its width, as the library's
|
|
14
|
+
* own components lay themselves out by it. It changes as the window does: on
|
|
15
|
+
* rotation, in split screen, and when a foldable unfolds.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const sizeClass = useWindowSizeClass()
|
|
19
|
+
* const columns = sizeClass === 'compact' ? 1 : 2
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The classes are at
|
|
23
|
+
* https://m3.material.io/foundations/layout/applying-layout/window-size-classes.
|
|
24
|
+
*/
|
|
25
|
+
function useWindowSizeClass() {
|
|
26
|
+
const $ = c(2);
|
|
27
|
+
const { width } = useWindowDimensions();
|
|
28
|
+
let t0;
|
|
29
|
+
if ($[0] !== width) {
|
|
30
|
+
t0 = CLASSES.find((sizeClass) => width >= breakpoints[sizeClass]) ?? "compact";
|
|
31
|
+
$[0] = width;
|
|
32
|
+
$[1] = t0;
|
|
33
|
+
} else t0 = $[1];
|
|
34
|
+
return t0;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useWindowSizeClass };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=useWindowSizeClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowSizeClass.js","names":["useWindowDimensions","breakpoints","WindowSizeClass","CLASSES","useWindowSizeClass","$","_c","width","t0","find","sizeClass","_c"],"sources":["../../src/hooks/useWindowSizeClass.ts"],"sourcesContent":["import { useWindowDimensions } from 'react-native'\n\nimport { breakpoints } from '../tokens/defaults'\n\n/**\n * Material Design's window size classes, which kanso-ui's breakpoint tokens\n * bound: `compact` from 0, `medium` from 600dp, `expanded` from 840dp, `large`\n * from 1200dp and `extraLarge` from 1600dp.\n */\ntype WindowSizeClass = keyof typeof breakpoints\n\n// Widest first, so the first class whose lower bound the window reaches is\n// the one it is in. The bounds themselves are the tokens'.\nconst CLASSES: readonly WindowSizeClass[] = [\n 'extraLarge',\n 'large',\n 'expanded',\n 'medium',\n 'compact',\n]\n\n/**\n * The window size class the app's window is in, by its width, as the library's\n * own components lay themselves out by it. It changes as the window does: on\n * rotation, in split screen, and when a foldable unfolds.\n *\n * ```tsx\n * const sizeClass = useWindowSizeClass()\n * const columns = sizeClass === 'compact' ? 1 : 2\n * ```\n *\n * The classes are at\n * https://m3.material.io/foundations/layout/applying-layout/window-size-classes.\n */\nfunction useWindowSizeClass(): WindowSizeClass {\n const { width } = useWindowDimensions()\n\n return (\n CLASSES.find((sizeClass) => width >= breakpoints[sizeClass]) ?? 'compact'\n )\n}\n\nexport { useWindowSizeClass }\nexport type { WindowSizeClass }\n"],"mappings":";;;;AAaA,MAAMG,UAAsC;CAC1C;CACA;CACA;CACA;CACA;AAAS;;;;;;;;;;;;;;AAgBX,SAAAC,qBAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACE,MAAA,EAAAC,UAAkBP,oBAAoB;CAAC,IAAAQ;CAAA,IAAAH,EAAA,OAAAE,OAAA;EAGrCC,KAAAL,QAAOM,MAAMC,cAAeH,SAASN,YAAYS,UAAuB,KAAxE;EAAyEL,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAAzEG;AAAyE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Avatar, AvatarProps } from "./components/avatar/index.js";
|
|
2
|
+
import { Button, ButtonProps, ButtonShape, ButtonSize, ButtonVariant } from "./components/button/index.js";
|
|
3
|
+
import { Card, CardProps, CardVariant } from "./components/card/index.js";
|
|
4
|
+
import { Checkbox, CheckboxProps } from "./components/checkbox/index.js";
|
|
5
|
+
import { Chip, ChipActionProps, ChipFilterProps, ChipProps, ChipVariant } from "./components/chip/index.js";
|
|
6
|
+
import { ChipGroup, ChipGroupChip, ChipGroupChipProps, ChipGroupProps } from "./components/chip-group/index.js";
|
|
7
|
+
import { CopyField, CopyFieldProps } from "./components/copy-field/index.js";
|
|
8
|
+
import { Currency, CurrencyProps, CurrencySignDisplay, CurrencyTone } from "./components/currency/index.js";
|
|
9
|
+
import { Form, FormHandle, FormProps } from "./components/form/index.js";
|
|
10
|
+
import { IconButton, IconButtonProps, IconButtonSize, IconButtonVariant } from "./components/icon-button/index.js";
|
|
11
|
+
import { Link, LinkProps, LinkTone, LinkUnderline } from "./components/link/index.js";
|
|
12
|
+
import { FieldVariant } from "./field/index.js";
|
|
13
|
+
import { NumberField, NumberFieldProps } from "./components/number-field/index.js";
|
|
14
|
+
import { ProductIcon, ProductIconProps } from "./components/product-icon/index.js";
|
|
15
|
+
import { Radio, RadioGroup, RadioGroupOrientation, RadioGroupProps, RadioProps } from "./components/radio-group/index.js";
|
|
16
|
+
import { SearchField, SearchFieldProps } from "./components/search-field/index.js";
|
|
17
|
+
import { SegmentedButton, SegmentedButtonProps, SegmentedButtonSegment, SegmentedButtonSegmentProps } from "./components/segmented-button/index.js";
|
|
18
|
+
import { Separator, SeparatorInset, SeparatorProps } from "./components/separator/index.js";
|
|
19
|
+
import { Stack, StackAlign, StackGap, StackJustify, StackProps } from "./components/stack/index.js";
|
|
20
|
+
import { Switch, SwitchProps } from "./components/switch/index.js";
|
|
21
|
+
import { TypeRole } from "./typography/roles.js";
|
|
22
|
+
import { Text, TextProps } from "./components/text/index.js";
|
|
23
|
+
import { TextField, TextFieldProps } from "./components/text-field/index.js";
|
|
24
|
+
import { IconStyle, useIconStyle } from "./glyphs/icon-style.js";
|
|
25
|
+
import { KuiTheme } from "./tokens/defaults.js";
|
|
26
|
+
import { WindowSizeClass, useWindowSizeClass } from "./hooks/useWindowSizeClass.js";
|
|
27
|
+
import { RouterProvider, RouterProviderProps } from "./router/index.js";
|
|
28
|
+
import { ThemeScope, ThemeScopeProps } from "./theme-scope.js";
|
|
29
|
+
import { ResolvedTheme, useTheme } from "./theme/scope.js";
|
|
30
|
+
import { Key, Selection } from "react-stately";
|
|
31
|
+
export { Avatar, type AvatarProps, Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, Card, type CardProps, type CardVariant, Checkbox, type CheckboxProps, Chip, type ChipActionProps, type ChipFilterProps, ChipGroup, ChipGroupChip, type ChipGroupChipProps, type ChipGroupProps, type ChipProps, type ChipVariant, CopyField, type CopyFieldProps, Currency, type CurrencyProps, type CurrencySignDisplay, type CurrencyTone, type FieldVariant, Form, type FormHandle, type FormProps, IconButton, type IconButtonProps, type IconButtonSize, type IconButtonVariant, type IconStyle, type Key, type KuiTheme, Link, type LinkProps, type LinkTone, type LinkUnderline, NumberField, type NumberFieldProps, ProductIcon, type ProductIconProps, Radio, RadioGroup, type RadioGroupOrientation, type RadioGroupProps, type RadioProps, type ResolvedTheme, RouterProvider, type RouterProviderProps, SearchField, type SearchFieldProps, SegmentedButton, type SegmentedButtonProps, SegmentedButtonSegment, type SegmentedButtonSegmentProps, type Selection, Separator, type SeparatorInset, type SeparatorProps, Stack, type StackAlign, type StackGap, type StackJustify, type StackProps, Switch, type SwitchProps, Text, TextField, type TextFieldProps, type TextProps, ThemeScope, type ThemeScopeProps, type TypeRole, type WindowSizeClass, useIconStyle, useTheme, useWindowSizeClass };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useIconStyle } from "./glyphs/icon-style.js";
|
|
2
|
+
import { useTheme } from "./theme/scope.js";
|
|
3
|
+
import { Avatar } from "./components/avatar/index.js";
|
|
4
|
+
import { RouterProvider } from "./router/index.js";
|
|
5
|
+
import { Button } from "./components/button/index.js";
|
|
6
|
+
import { Card } from "./components/card/index.js";
|
|
7
|
+
import { Checkbox } from "./components/checkbox/index.js";
|
|
8
|
+
import { Chip } from "./components/chip/index.js";
|
|
9
|
+
import { ChipGroup, ChipGroupChip } from "./components/chip-group/index.js";
|
|
10
|
+
import { CopyField } from "./components/copy-field/index.js";
|
|
11
|
+
import { Currency } from "./components/currency/index.js";
|
|
12
|
+
import { Form } from "./components/form/index.js";
|
|
13
|
+
import { IconButton } from "./components/icon-button/index.js";
|
|
14
|
+
import { Link } from "./components/link/index.js";
|
|
15
|
+
import { NumberField } from "./components/number-field/index.js";
|
|
16
|
+
import { ProductIcon } from "./components/product-icon/index.js";
|
|
17
|
+
import { Radio, RadioGroup } from "./components/radio-group/index.js";
|
|
18
|
+
import { SearchField } from "./components/search-field/index.js";
|
|
19
|
+
import { SegmentedButton, SegmentedButtonSegment } from "./components/segmented-button/index.js";
|
|
20
|
+
import { Separator } from "./components/separator/index.js";
|
|
21
|
+
import { Stack } from "./components/stack/index.js";
|
|
22
|
+
import { Switch } from "./components/switch/index.js";
|
|
23
|
+
import { Text } from "./components/text/index.js";
|
|
24
|
+
import { TextField } from "./components/text-field/index.js";
|
|
25
|
+
import { useWindowSizeClass } from "./hooks/useWindowSizeClass.js";
|
|
26
|
+
import { ThemeScope } from "./theme-scope.js";
|
|
27
|
+
export { Avatar, Button, Card, Checkbox, Chip, ChipGroup, ChipGroupChip, CopyField, Currency, Form, IconButton, Link, NumberField, ProductIcon, Radio, RadioGroup, RouterProvider, SearchField, SegmentedButton, SegmentedButtonSegment, Separator, Stack, Switch, Text, TextField, ThemeScope, useIconStyle, useTheme, useWindowSizeClass };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
//#region src/mark/image.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether the picture at `src` can be shown yet, from what the component's
|
|
6
|
+
* own `Image` reports, as kanso-ui's `useImageLoadingStatus` reads it from an
|
|
7
|
+
* `<img>`. The image is rendered from the start and hidden until it loads,
|
|
8
|
+
* so the platform fetches it as it would any image, and hands `onLoad` and
|
|
9
|
+
* `onError` to that element. A component keeps its fallback until the
|
|
10
|
+
* picture is ready and brings it back if the picture fails, so a blank or
|
|
11
|
+
* broken image is never what shows.
|
|
12
|
+
*
|
|
13
|
+
* `previous` is the picture last loaded, while a new `src` is still loading,
|
|
14
|
+
* so the component can keep showing it rather than drop back to the fallback
|
|
15
|
+
* for as long as the new one takes. It is cached by then, so it shows at
|
|
16
|
+
* once.
|
|
17
|
+
*
|
|
18
|
+
* No `src` counts as a failure, since the outcome is the same: the fallback
|
|
19
|
+
* shows. Outcomes are remembered against the `src` they came for, so a
|
|
20
|
+
* change of `src` reads as loading rather than as the old outcome.
|
|
21
|
+
*/
|
|
22
|
+
function useImageLoadingStatus(src) {
|
|
23
|
+
const $ = c(4);
|
|
24
|
+
const [loaded, setLoaded] = useState(null);
|
|
25
|
+
const [failed, setFailed] = useState(null);
|
|
26
|
+
let status = "loading";
|
|
27
|
+
if (src === void 0 || failed === src) status = "error";
|
|
28
|
+
else if (loaded === src) status = "loaded";
|
|
29
|
+
let t0;
|
|
30
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
31
|
+
t0 = function handlersFor(uri) {
|
|
32
|
+
return {
|
|
33
|
+
onError: () => {
|
|
34
|
+
setFailed(uri);
|
|
35
|
+
},
|
|
36
|
+
onLoad: () => {
|
|
37
|
+
setLoaded(uri);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
$[0] = t0;
|
|
42
|
+
} else t0 = $[0];
|
|
43
|
+
const handlersFor = t0;
|
|
44
|
+
const t1 = status === "loading" ? loaded ?? void 0 : void 0;
|
|
45
|
+
let t2;
|
|
46
|
+
if ($[1] !== status || $[2] !== t1) {
|
|
47
|
+
t2 = {
|
|
48
|
+
handlersFor,
|
|
49
|
+
previous: t1,
|
|
50
|
+
status
|
|
51
|
+
};
|
|
52
|
+
$[1] = status;
|
|
53
|
+
$[2] = t1;
|
|
54
|
+
$[3] = t2;
|
|
55
|
+
} else t2 = $[3];
|
|
56
|
+
return t2;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { useImageLoadingStatus };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","names":["useState","ImageHandlers","onError","onLoad","ImageLoadingStatus","useImageLoadingStatus","src","$","_c","loaded","setLoaded","failed","setFailed","status","undefined","t0","Symbol","for","handlersFor","uri","t1","t2","previous","_c"],"sources":["../../src/mark/image.ts"],"sourcesContent":["import { useState } from 'react'\n\n/** What a picture's own `Image` reports, bound to the `src` it shows. */\ntype ImageHandlers = {\n readonly onError: () => void\n readonly onLoad: () => void\n}\n\ntype ImageLoadingStatus = 'error' | 'loaded' | 'loading'\n\n/**\n * Whether the picture at `src` can be shown yet, from what the component's\n * own `Image` reports, as kanso-ui's `useImageLoadingStatus` reads it from an\n * `<img>`. The image is rendered from the start and hidden until it loads,\n * so the platform fetches it as it would any image, and hands `onLoad` and\n * `onError` to that element. A component keeps its fallback until the\n * picture is ready and brings it back if the picture fails, so a blank or\n * broken image is never what shows.\n *\n * `previous` is the picture last loaded, while a new `src` is still loading,\n * so the component can keep showing it rather than drop back to the fallback\n * for as long as the new one takes. It is cached by then, so it shows at\n * once.\n *\n * No `src` counts as a failure, since the outcome is the same: the fallback\n * shows. Outcomes are remembered against the `src` they came for, so a\n * change of `src` reads as loading rather than as the old outcome.\n */\nfunction useImageLoadingStatus(src: string | undefined) {\n const [loaded, setLoaded] = useState<null | string>(null)\n const [failed, setFailed] = useState<null | string>(null)\n\n let status: ImageLoadingStatus = 'loading'\n if (src === undefined || failed === src) {\n status = 'error'\n } else if (loaded === src) {\n status = 'loaded'\n }\n\n // Bound to the `src` the element is keyed on, which is the one its events\n // are about: an element left over from the `src` before cannot report for\n // the one after it.\n function handlersFor(uri: string): ImageHandlers {\n return {\n onError: () => {\n setFailed(uri)\n },\n onLoad: () => {\n setLoaded(uri)\n },\n }\n }\n\n return {\n handlersFor,\n previous: status === 'loading' ? (loaded ?? undefined) : undefined,\n status,\n }\n}\n\nexport type { ImageLoadingStatus }\n\nexport { useImageLoadingStatus }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4BA,SAAAK,sBAAAC,KAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACE,MAAA,CAAAC,QAAAC,aAA4BV,SAAwB,IAAI;CACxD,MAAA,CAAAW,QAAAC,aAA4BZ,SAAwB,IAAI;CAExD,IAAAa,SAAiC;CACjC,IAAIP,QAAQQ,KAAAA,KAAaH,WAAWL,KAClCO,SAASA;MACJ,IAAIJ,WAAWH,KACpBO,SAASA;CACV,IAAAE;CAAA,IAAAR,EAAA,OAAAS,OAAAC,IAAA,2BAAA,GAAA;EAKDF,KAAA,SAAAG,YAAAC,KAAA;GAAA,OACS;IAAAjB,eACI;KACPU,UAAUO,GAAG;IAAC;IACfhB,cACO;KACNO,UAAUS,GAAG;IAAC;GAElB;EAAC;EACFZ,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CATD,MAAAW,cAAAH;CAaY,MAAAK,KAAAP,WAAW,YAAaJ,UAAAK,KAAAA,IAAxBA,KAAAA;CAAwD,IAAAO;CAAA,IAAAd,EAAA,OAAAM,UAAAN,EAAA,OAAAa,IAAA;EAF7DC,KAAA;GAAAH;GAAAI,UAEKF;GAAwDP;EAEpE;EAACN,EAAA,KAAAM;EAAAN,EAAA,KAAAa;EAAAb,EAAA,KAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OAJMc;AAIN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./styles.js";
|
|
2
|
+
import { ImageProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
|
|
3
|
+
import { Ref } from "react";
|
|
4
|
+
//#region src/mark/index.d.ts
|
|
5
|
+
/** The native props a picture's own `Image` takes, as Avatar and ProductIcon take them. */
|
|
6
|
+
type MarkImageProps = Pick<ImageProps, 'crossOrigin' | 'fadeDuration' | 'progressiveRenderingEnabled' | 'referrerPolicy' | 'resizeMethod'>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export type { MarkImageProps };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { PersonGlyph } from "../glyphs/index.js";
|
|
2
|
+
import { useTheme } from "../theme/scope.js";
|
|
3
|
+
import { composeStyles } from "../theme/styles.js";
|
|
4
|
+
import { useTypeRole } from "../typography/roles.js";
|
|
5
|
+
import { useImageLoadingStatus } from "./image.js";
|
|
6
|
+
import { initialOfThing, initialsOfPerson } from "./initials.js";
|
|
7
|
+
import { DIAMETERS, GLYPH_SHARE, initialsStylesOf, markStyles, markStylesOf } from "./styles.js";
|
|
8
|
+
import { c } from "react/compiler-runtime";
|
|
9
|
+
import { Image, Text, View } from "react-native";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/mark/index.tsx
|
|
12
|
+
const KINDS = {
|
|
13
|
+
person: {
|
|
14
|
+
initials: initialsOfPerson,
|
|
15
|
+
resizeMode: "cover",
|
|
16
|
+
shape: "circle",
|
|
17
|
+
tintsFallback: false
|
|
18
|
+
},
|
|
19
|
+
thing: {
|
|
20
|
+
initials: initialOfThing,
|
|
21
|
+
resizeMode: "contain",
|
|
22
|
+
shape: "square",
|
|
23
|
+
tintsFallback: true
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const CONTENT = {
|
|
27
|
+
negative: "onNegativeContainer",
|
|
28
|
+
positive: "onPositiveContainer",
|
|
29
|
+
primary: "onPrimaryContainer",
|
|
30
|
+
secondary: "onSecondaryContainer",
|
|
31
|
+
tertiary: "onTertiaryContainer"
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The small identity mark Avatar and ProductIcon both render: a picture once
|
|
35
|
+
* it has loaded, initials until then or if it fails, named for whoever or
|
|
36
|
+
* whatever it stands for. Shared rather than written into each, so a fix to
|
|
37
|
+
* one reaches both, as on web. Not a component of the library's own, and not
|
|
38
|
+
* exported from the package.
|
|
39
|
+
*/
|
|
40
|
+
function Mark(t0) {
|
|
41
|
+
const $ = c(62);
|
|
42
|
+
let imgProps;
|
|
43
|
+
let kind;
|
|
44
|
+
let name;
|
|
45
|
+
let props;
|
|
46
|
+
let size;
|
|
47
|
+
let src;
|
|
48
|
+
let style;
|
|
49
|
+
let t1;
|
|
50
|
+
let t2;
|
|
51
|
+
let tone;
|
|
52
|
+
if ($[0] !== t0) {
|
|
53
|
+
({decorative: t1, imgProps, kind, name, showPersonIcon: t2, size, src, style, tone, ...props} = t0);
|
|
54
|
+
$[0] = t0;
|
|
55
|
+
$[1] = imgProps;
|
|
56
|
+
$[2] = kind;
|
|
57
|
+
$[3] = name;
|
|
58
|
+
$[4] = props;
|
|
59
|
+
$[5] = size;
|
|
60
|
+
$[6] = src;
|
|
61
|
+
$[7] = style;
|
|
62
|
+
$[8] = t1;
|
|
63
|
+
$[9] = t2;
|
|
64
|
+
$[10] = tone;
|
|
65
|
+
} else {
|
|
66
|
+
imgProps = $[1];
|
|
67
|
+
kind = $[2];
|
|
68
|
+
name = $[3];
|
|
69
|
+
props = $[4];
|
|
70
|
+
size = $[5];
|
|
71
|
+
src = $[6];
|
|
72
|
+
style = $[7];
|
|
73
|
+
t1 = $[8];
|
|
74
|
+
t2 = $[9];
|
|
75
|
+
tone = $[10];
|
|
76
|
+
}
|
|
77
|
+
const decorative = t1 === void 0 ? false : t1;
|
|
78
|
+
const showPersonIcon = t2 === void 0 ? true : t2;
|
|
79
|
+
const { initials, resizeMode, shape, tintsFallback } = KINDS[kind];
|
|
80
|
+
const theme = useTheme();
|
|
81
|
+
const label = useTypeRole("labelLarge");
|
|
82
|
+
const { handlersFor, previous, status } = useImageLoadingStatus(src);
|
|
83
|
+
let T0;
|
|
84
|
+
let initialsNode;
|
|
85
|
+
let t3;
|
|
86
|
+
let t4;
|
|
87
|
+
let t5;
|
|
88
|
+
let t6;
|
|
89
|
+
let t7;
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[11] !== decorative || $[12] !== initials || $[13] !== kind || $[14] !== label || $[15] !== name || $[16] !== previous || $[17] !== props || $[18] !== shape || $[19] !== showPersonIcon || $[20] !== size || $[21] !== status || $[22] !== style || $[23] !== theme || $[24] !== tintsFallback || $[25] !== tone) {
|
|
92
|
+
const own = markStylesOf(theme);
|
|
93
|
+
const text = initialsStylesOf(theme);
|
|
94
|
+
let t9;
|
|
95
|
+
if ($[34] !== initials || $[35] !== name) {
|
|
96
|
+
t9 = initials(name);
|
|
97
|
+
$[34] = initials;
|
|
98
|
+
$[35] = name;
|
|
99
|
+
$[36] = t9;
|
|
100
|
+
} else t9 = $[36];
|
|
101
|
+
const fallback = t9;
|
|
102
|
+
const named = !decorative && name.trim() !== "";
|
|
103
|
+
const showsPicture = status === "loaded" || previous !== void 0;
|
|
104
|
+
initialsNode = null;
|
|
105
|
+
if (!showsPicture && kind === "person" && fallback === "") {
|
|
106
|
+
let t10;
|
|
107
|
+
if ($[37] !== showPersonIcon || $[38] !== size || $[39] !== theme || $[40] !== tone) {
|
|
108
|
+
t10 = showPersonIcon ? /* @__PURE__ */ jsx(PersonGlyph, {
|
|
109
|
+
color: theme.colors[CONTENT[tone]],
|
|
110
|
+
size: DIAMETERS[size] * GLYPH_SHARE
|
|
111
|
+
}) : null;
|
|
112
|
+
$[37] = showPersonIcon;
|
|
113
|
+
$[38] = size;
|
|
114
|
+
$[39] = theme;
|
|
115
|
+
$[40] = tone;
|
|
116
|
+
$[41] = t10;
|
|
117
|
+
} else t10 = $[41];
|
|
118
|
+
initialsNode = t10;
|
|
119
|
+
} else if (!showsPicture) {
|
|
120
|
+
const initialsText = /* @__PURE__ */ jsx(Text, {
|
|
121
|
+
allowFontScaling: false,
|
|
122
|
+
style: composeStyles(label, text[size], text[tone]),
|
|
123
|
+
children: fallback
|
|
124
|
+
});
|
|
125
|
+
initialsNode = tintsFallback ? /* @__PURE__ */ jsx(View, {
|
|
126
|
+
style: composeStyles(markStyles.fallback, own[tone]),
|
|
127
|
+
children: initialsText
|
|
128
|
+
}) : initialsText;
|
|
129
|
+
}
|
|
130
|
+
T0 = View;
|
|
131
|
+
t3 = named ? true : void 0;
|
|
132
|
+
t4 = decorative ? true : void 0;
|
|
133
|
+
t5 = named ? name : void 0;
|
|
134
|
+
t6 = named ? "img" : void 0;
|
|
135
|
+
t7 = props;
|
|
136
|
+
t8 = composeStyles(own.base, own[shape], markStyles[size], tintsFallback ? void 0 : own[tone], style);
|
|
137
|
+
$[11] = decorative;
|
|
138
|
+
$[12] = initials;
|
|
139
|
+
$[13] = kind;
|
|
140
|
+
$[14] = label;
|
|
141
|
+
$[15] = name;
|
|
142
|
+
$[16] = previous;
|
|
143
|
+
$[17] = props;
|
|
144
|
+
$[18] = shape;
|
|
145
|
+
$[19] = showPersonIcon;
|
|
146
|
+
$[20] = size;
|
|
147
|
+
$[21] = status;
|
|
148
|
+
$[22] = style;
|
|
149
|
+
$[23] = theme;
|
|
150
|
+
$[24] = tintsFallback;
|
|
151
|
+
$[25] = tone;
|
|
152
|
+
$[26] = T0;
|
|
153
|
+
$[27] = initialsNode;
|
|
154
|
+
$[28] = t3;
|
|
155
|
+
$[29] = t4;
|
|
156
|
+
$[30] = t5;
|
|
157
|
+
$[31] = t6;
|
|
158
|
+
$[32] = t7;
|
|
159
|
+
$[33] = t8;
|
|
160
|
+
} else {
|
|
161
|
+
T0 = $[26];
|
|
162
|
+
initialsNode = $[27];
|
|
163
|
+
t3 = $[28];
|
|
164
|
+
t4 = $[29];
|
|
165
|
+
t5 = $[30];
|
|
166
|
+
t6 = $[31];
|
|
167
|
+
t7 = $[32];
|
|
168
|
+
t8 = $[33];
|
|
169
|
+
}
|
|
170
|
+
let t9;
|
|
171
|
+
if ($[42] !== previous || $[43] !== resizeMode) {
|
|
172
|
+
t9 = previous === void 0 ? null : /* @__PURE__ */ jsx(Image, {
|
|
173
|
+
accessibilityIgnoresInvertColors: true,
|
|
174
|
+
resizeMode,
|
|
175
|
+
source: sourceOf(previous),
|
|
176
|
+
style: markStyles.image
|
|
177
|
+
}, previous);
|
|
178
|
+
$[42] = previous;
|
|
179
|
+
$[43] = resizeMode;
|
|
180
|
+
$[44] = t9;
|
|
181
|
+
} else t9 = $[44];
|
|
182
|
+
let t10;
|
|
183
|
+
if ($[45] !== handlersFor || $[46] !== imgProps || $[47] !== resizeMode || $[48] !== src || $[49] !== status) {
|
|
184
|
+
t10 = src === void 0 || status === "error" ? null : /* @__PURE__ */ jsx(Image, {
|
|
185
|
+
accessibilityIgnoresInvertColors: true,
|
|
186
|
+
...imgProps,
|
|
187
|
+
...handlersFor(src),
|
|
188
|
+
resizeMode,
|
|
189
|
+
source: sourceOf(src),
|
|
190
|
+
style: composeStyles(markStyles.image, status === "loaded" ? void 0 : markStyles.imagePending)
|
|
191
|
+
}, src);
|
|
192
|
+
$[45] = handlersFor;
|
|
193
|
+
$[46] = imgProps;
|
|
194
|
+
$[47] = resizeMode;
|
|
195
|
+
$[48] = src;
|
|
196
|
+
$[49] = status;
|
|
197
|
+
$[50] = t10;
|
|
198
|
+
} else t10 = $[50];
|
|
199
|
+
let t11;
|
|
200
|
+
if ($[51] !== T0 || $[52] !== initialsNode || $[53] !== t10 || $[54] !== t3 || $[55] !== t4 || $[56] !== t5 || $[57] !== t6 || $[58] !== t7 || $[59] !== t8 || $[60] !== t9) {
|
|
201
|
+
t11 = /* @__PURE__ */ jsxs(T0, {
|
|
202
|
+
accessible: t3,
|
|
203
|
+
"aria-hidden": t4,
|
|
204
|
+
"aria-label": t5,
|
|
205
|
+
role: t6,
|
|
206
|
+
...t7,
|
|
207
|
+
style: t8,
|
|
208
|
+
children: [
|
|
209
|
+
initialsNode,
|
|
210
|
+
t9,
|
|
211
|
+
t10
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
$[51] = T0;
|
|
215
|
+
$[52] = initialsNode;
|
|
216
|
+
$[53] = t10;
|
|
217
|
+
$[54] = t3;
|
|
218
|
+
$[55] = t4;
|
|
219
|
+
$[56] = t5;
|
|
220
|
+
$[57] = t6;
|
|
221
|
+
$[58] = t7;
|
|
222
|
+
$[59] = t8;
|
|
223
|
+
$[60] = t9;
|
|
224
|
+
$[61] = t11;
|
|
225
|
+
} else t11 = $[61];
|
|
226
|
+
return t11;
|
|
227
|
+
}
|
|
228
|
+
function sourceOf(uri) {
|
|
229
|
+
return { uri };
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { Mark };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=index.js.map
|