@colixsystems/widget-sdk 0.259.0 → 0.261.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 +9 -1
- package/dist/accordion.js +2 -1
- package/dist/accordion.native.js +2 -1
- package/dist/banner.js +1 -1
- package/dist/banner.native.js +2 -1
- package/dist/bounded-text.native.js +29 -0
- package/dist/button.js +1 -1
- package/dist/button.native.js +2 -1
- package/dist/card-photo.js +1 -1
- package/dist/card.js +1 -1
- package/dist/chart.js +1 -1
- package/dist/chart.native.js +2 -1
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.native.js +2 -1
- package/dist/chip.js +1 -1
- package/dist/chip.native.js +2 -1
- package/dist/confirm-dialog.js +1 -1
- package/dist/confirm-dialog.native.js +3 -3
- package/dist/contract.cjs +22 -18
- package/dist/contract.js +23 -18
- package/dist/data-table.js +1 -1
- package/dist/data-table.native.js +2 -1
- package/dist/datetimepicker.js +2 -1
- package/dist/datetimepicker.native.js +2 -1
- package/dist/detail-parts.js +1 -1
- package/dist/detail-parts.native.js +2 -1
- package/dist/emoji-picker.js +1 -1
- package/dist/emoji-picker.native.js +2 -1
- package/dist/file-image.js +1 -1
- package/dist/file-upload.js +2 -1
- package/dist/file-upload.native.js +2 -1
- package/dist/filter-bar.js +1 -1
- package/dist/form.js +1 -1
- package/dist/form.native.js +2 -1
- package/dist/gradient.js +1 -1
- package/dist/grid.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/linter.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/list.native.js +2 -1
- package/dist/loading.js +1 -1
- package/dist/loading.native.js +2 -1
- package/dist/markdown-input.js +1 -1
- package/dist/markdown-input.native.js +2 -1
- package/dist/modal.js +1 -1
- package/dist/modal.native.js +1 -1
- package/dist/overlay.js +1 -1
- package/dist/people-picker.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/popover.native.js +2 -1
- package/dist/primitives.js +1 -1
- package/dist/primitives.native.js +2 -2
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.native.js +2 -1
- package/dist/richtext.js +1 -1
- package/dist/richtext.native.js +2 -1
- package/dist/search-field.js +1 -1
- package/dist/search-field.native.js +2 -1
- package/dist/select.js +1 -1
- package/dist/select.native.js +2 -1
- package/dist/sortable.js +1 -1
- package/dist/sortable.native.js +2 -1
- package/dist/surface-theme.js +2 -2
- package/dist/switch.js +1 -1
- package/dist/switch.native.js +2 -1
- package/dist/tabs.js +1 -1
- package/dist/tabs.native.js +2 -1
- package/dist/text-field.js +1 -1
- package/dist/text-field.native.js +2 -1
- package/dist/text-scale-style.js +60 -0
- package/dist/text-scale.d.ts +11 -0
- package/dist/text-scale.js +40 -0
- package/dist/video.js +1 -1
- package/package.json +7 -1
- package/src/contract.js +23 -18
package/dist/index.d.ts
CHANGED
|
@@ -5868,6 +5868,8 @@ export interface AiWidgetContract {
|
|
|
5868
5868
|
readonly bundleExportContract: ReadonlyArray<ContractBundleShape>;
|
|
5869
5869
|
/** sc-10829 — the export name of a `badgeCounter: true` entry's hook. */
|
|
5870
5870
|
readonly badgeCounterExport: "useBadgeCount";
|
|
5871
|
+
/** The most native Text / TextInput grow with the device font-scale setting. */
|
|
5872
|
+
readonly maxFontSizeMultiplier: number;
|
|
5871
5873
|
readonly bannedApis: ReadonlyArray<ContractBannedApi>;
|
|
5872
5874
|
readonly allowedBareImports: ReadonlyArray<string>;
|
|
5873
5875
|
/** Bare specifiers the web host provides by exact name; a widget bundle never inlines them. */
|
package/dist/linter.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// The ESM `linter.js` is the source-of-truth. This file MUST mirror its
|
|
5
5
|
// rule set byte-for-byte — the contract test in packages/widget-sdk
|
|
6
6
|
// asserts the two are behaviour-equivalent. When you edit one, edit the
|
|
7
|
-
// other in the same PR.
|
|
7
|
+
// other in the same PR.
|
|
8
8
|
//
|
|
9
9
|
// The SDK build script copies both into `dist/`.
|
|
10
10
|
|
package/dist/list.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<List>`, `<ListRow>`, `<ListHeader>`, `<EmptyState>` (web). Binds
|
|
2
2
|
// ./list-view.js to react-native-web; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { Card } from "./card.js";
|
|
6
6
|
import { makeList } from "./list-view.js";
|
|
7
7
|
|
package/dist/list.native.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<List>`, `<ListRow>`, `<ListHeader>`, `<EmptyState>` (native). Binds
|
|
2
2
|
// ./list-view.js to React Native's own primitives; only the imports differ from ./list.js.
|
|
3
3
|
|
|
4
|
-
import { View,
|
|
4
|
+
import { View, Pressable } from "react-native";
|
|
5
|
+
import { Text } from "./bounded-text.native.js";
|
|
5
6
|
import { Card } from "./card.native.js";
|
|
6
7
|
import { makeList } from "./list-view.js";
|
|
7
8
|
|
package/dist/loading.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<Spinner>` and `<Skeleton>` (web). Binds ./loading-view.js to
|
|
2
2
|
// react-native-web; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeLoading } from "./loading-view.js";
|
|
6
6
|
|
|
7
7
|
export const { Spinner, Skeleton } = makeLoading(ReactNative, { useNativeDriver: false });
|
package/dist/loading.native.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<Spinner>` and `<Skeleton>` (native). Binds ./loading-view.js to React
|
|
2
2
|
// Native's own primitives; only the import differs from ./loading.js.
|
|
3
3
|
|
|
4
|
-
import { View,
|
|
4
|
+
import { View, Animated, Easing, AccessibilityInfo } from "react-native";
|
|
5
|
+
import { Text } from "./bounded-text.native.js";
|
|
5
6
|
import { makeLoading } from "./loading-view.js";
|
|
6
7
|
|
|
7
8
|
export const { Spinner, Skeleton } = makeLoading(
|
package/dist/markdown-input.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ./markdown-input-view.js to react-native-web's primitives, and to the web
|
|
3
3
|
// `<RichText>` it renders its preview with.
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { ReactNative } from "./text-scale.js";
|
|
6
6
|
import { makeMarkdownInput } from "./markdown-input-view.js";
|
|
7
7
|
import { RichText } from "./richtext.js";
|
|
8
8
|
import { Modal } from "./modal.js";
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// ./markdown-input-view.js to React Native's own primitives and the native
|
|
3
3
|
// `<RichText>`. Only the imports differ from the web mirror.
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { View, Pressable, ScrollView } from "react-native";
|
|
6
|
+
import { Text, TextInput } from "./bounded-text.native.js";
|
|
6
7
|
import { makeMarkdownInput } from "./markdown-input-view.js";
|
|
7
8
|
import { RichText } from "./richtext.native.js";
|
|
8
9
|
import { Modal } from "./modal.native.js";
|
package/dist/modal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<Modal>` (web). Binds ./modal-view.js to react-native-web and the web
|
|
2
2
|
// `<Overlay>`; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeModal } from "./modal-view.js";
|
|
6
6
|
import { Overlay } from "./overlay.js";
|
|
7
7
|
|
package/dist/modal.native.js
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import {
|
|
8
8
|
View,
|
|
9
|
-
Text,
|
|
10
9
|
Pressable,
|
|
11
10
|
ScrollView,
|
|
12
11
|
KeyboardAvoidingView,
|
|
13
12
|
Platform,
|
|
14
13
|
} from "react-native";
|
|
14
|
+
import { Text } from "./bounded-text.native.js";
|
|
15
15
|
// Host-provided: the exported app pins it and mounts its provider at the root.
|
|
16
16
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
17
17
|
import { makeModal } from "./modal-view.js";
|
package/dist/overlay.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// container at `position: fixed`, which is exactly what makes the overlay
|
|
9
9
|
// escape the widget's clipping ancestors.
|
|
10
10
|
|
|
11
|
-
import
|
|
11
|
+
import { ReactNative } from "./text-scale.js";
|
|
12
12
|
import { makeOverlay } from "./overlay-view.js";
|
|
13
13
|
import { WebModal } from "./web-modal.js";
|
|
14
14
|
|
package/dist/people-picker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<PeoplePicker>` (web). Binds ./people-picker-view.js to the web `<Select>`
|
|
2
2
|
// and `<Avatar>`; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makePeoplePicker } from "./people-picker-view.js";
|
|
6
6
|
import { Select } from "./select.js";
|
|
7
7
|
import { Avatar } from "./detail-parts.js";
|
package/dist/popover.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// ./menu-view.js and ./tooltip-view.js to react-native-web and the web
|
|
3
3
|
// `<Overlay>`; see ./primitives.js for why not the bare specifier.
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { ReactNative } from "./text-scale.js";
|
|
6
6
|
import { makePopover } from "./popover-view.js";
|
|
7
7
|
import { makeMenu } from "./menu-view.js";
|
|
8
8
|
import { makeTooltip } from "./tooltip-view.js";
|
package/dist/popover.native.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// differ from ./popover.js, plus the safe-area inset a bottom sheet pads by.
|
|
4
4
|
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { View,
|
|
6
|
+
import { View, Pressable, ScrollView, Platform, useWindowDimensions } from "react-native";
|
|
7
|
+
import { Text } from "./bounded-text.native.js";
|
|
7
8
|
// Host-provided: the exported app pins it and mounts its provider at the root.
|
|
8
9
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
9
10
|
import { makePopover } from "./popover-view.js";
|
package/dist/primitives.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
// installed dep (no stub), and runtime property access sidesteps the
|
|
40
40
|
// static re-export tracing. Behaviour is identical to the old
|
|
41
41
|
// `react-native` alias path on the web.
|
|
42
|
-
import
|
|
42
|
+
import { ReactNative } from "./text-scale.js";
|
|
43
43
|
import { makeTextInput } from "./text-input-view.js";
|
|
44
44
|
|
|
45
45
|
export const Text = ReactNative.Text;
|
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
// `./primitives.js`.
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
|
-
Text,
|
|
11
10
|
View,
|
|
12
11
|
Pressable,
|
|
13
12
|
Image,
|
|
14
13
|
ScrollView,
|
|
15
|
-
TextInput,
|
|
16
14
|
FlatList,
|
|
17
15
|
SectionList,
|
|
18
16
|
ActivityIndicator,
|
|
@@ -20,6 +18,8 @@ export {
|
|
|
20
18
|
StyleSheet,
|
|
21
19
|
Linking,
|
|
22
20
|
} from "react-native";
|
|
21
|
+
// sc-9168 — bounded to the device font-scale cap; no web twin (no such setting).
|
|
22
|
+
export { Text, TextInput } from "./bounded-text.native.js";
|
|
23
23
|
|
|
24
24
|
// REQ-WSDK-PLATFORM §6 — `<Icon>` is implemented in one file that runs on
|
|
25
25
|
// both platforms (lucide-react-native ships a working build for both).
|
package/dist/radio-group.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<RadioGroup>` (web). Binds ./radio-group-view.js to react-native-web; see
|
|
2
2
|
// ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeRadioGroup } from "./radio-group-view.js";
|
|
6
6
|
|
|
7
7
|
export const RadioGroup = makeRadioGroup({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<RadioGroup>` (native). Binds ./radio-group-view.js to React Native's own
|
|
2
2
|
// primitives; only the import differs from ./radio-group.js.
|
|
3
3
|
|
|
4
|
-
import { View,
|
|
4
|
+
import { View, Pressable, Platform } from "react-native";
|
|
5
|
+
import { Text } from "./bounded-text.native.js";
|
|
5
6
|
import { makeRadioGroup } from "./radio-group-view.js";
|
|
6
7
|
|
|
7
8
|
export const RadioGroup = makeRadioGroup({ View, Text, Pressable, Platform });
|
package/dist/richtext.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// specifier for the rolldown optional-peer-dep reason spelled out at the top of
|
|
6
6
|
// ./primitives.js.
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { ReactNative } from "./text-scale.js";
|
|
9
9
|
import { makeRichText } from "./richtext-view.js";
|
|
10
10
|
|
|
11
11
|
export const RichText = makeRichText(ReactNative);
|
package/dist/richtext.native.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// ./richtext-view.js to React Native's own primitives. Only the import differs
|
|
3
3
|
// from the web mirror in ./richtext.js.
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { View, Image } from "react-native";
|
|
6
|
+
import { Text } from "./bounded-text.native.js";
|
|
6
7
|
import { makeRichText } from "./richtext-view.js";
|
|
7
8
|
|
|
8
9
|
export const RichText = makeRichText({ Text, View, Image });
|
package/dist/search-field.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<SearchField>` (web). Binds ./search-field-view.js to react-native-web and
|
|
2
2
|
// the web `<TextField>`; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeSearchField } from "./search-field-view.js";
|
|
6
6
|
import { TextField } from "./text-field.js";
|
|
7
7
|
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// primitives and the native `<TextField>`; only the imports differ from
|
|
3
3
|
// ./search-field.js.
|
|
4
4
|
|
|
5
|
-
import { View,
|
|
5
|
+
import { View, Pressable } from "react-native";
|
|
6
|
+
import { Text } from "./bounded-text.native.js";
|
|
6
7
|
import { makeSearchField } from "./search-field-view.js";
|
|
7
8
|
import { TextField } from "./text-field.native.js";
|
|
8
9
|
|
package/dist/select.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// `<Overlay>`, `<Button>`, `<Chip>`, `<SearchField>` and `<Spinner>`; see
|
|
3
3
|
// ./primitives.js for why not the bare specifier.
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { ReactNative } from "./text-scale.js";
|
|
6
6
|
import { makeSelect } from "./select-view.js";
|
|
7
7
|
import { Overlay } from "./overlay.js";
|
|
8
8
|
import { Button } from "./button.js";
|
package/dist/select.native.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// primitives and the native `<Overlay>`, `<Button>`, `<Chip>`,
|
|
3
3
|
// `<SearchField>` and `<Spinner>`; only the imports differ from ./select.js.
|
|
4
4
|
|
|
5
|
-
import { View,
|
|
5
|
+
import { View, Pressable, ScrollView, Platform } from "react-native";
|
|
6
|
+
import { Text } from "./bounded-text.native.js";
|
|
6
7
|
import { makeSelect } from "./select-view.js";
|
|
7
8
|
import { Overlay } from "./overlay.native.js";
|
|
8
9
|
import { Button } from "./button.native.js";
|
package/dist/sortable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<SortableList>` and `<Board>` (web). Bind ./sortable-view.js to
|
|
2
2
|
// react-native-web; see ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { List, ListRow } from "./list.js";
|
|
6
6
|
import { Card } from "./card.js";
|
|
7
7
|
import { Menu } from "./popover.js";
|
package/dist/sortable.native.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Native's own primitives; only the imports and the handle style differ from
|
|
3
3
|
// ./sortable.js.
|
|
4
4
|
|
|
5
|
-
import { View,
|
|
5
|
+
import { View, ScrollView, Animated, PanResponder, Platform, AccessibilityInfo } from "react-native";
|
|
6
|
+
import { Text } from "./bounded-text.native.js";
|
|
6
7
|
import { List, ListRow } from "./list.native.js";
|
|
7
8
|
import { Card } from "./card.native.js";
|
|
8
9
|
import { Menu } from "./popover.native.js";
|
package/dist/surface-theme.js
CHANGED
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
* derived from an image, so its subtree keeps what it inherited and the scrim
|
|
27
27
|
* plus an explicit light text colour carries the hero.
|
|
28
28
|
*
|
|
29
|
-
* The web Player
|
|
30
|
-
*
|
|
29
|
+
* The web Player and the export's generated layout renderer both call this,
|
|
30
|
+
* so the two hosts cannot differ here (CLAUDE.md §8).
|
|
31
31
|
*/
|
|
32
32
|
export function surfaceAwareTheme(tenantTheme, backgroundColor) {
|
|
33
33
|
const surfaceTokens = deriveSurfaceTokens(backgroundColor);
|
package/dist/switch.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// - it forwards only a label to its `<input>`, dropping the other ARIA props.
|
|
11
11
|
|
|
12
12
|
import React from "react";
|
|
13
|
-
import
|
|
13
|
+
import { ReactNative } from "./text-scale.js";
|
|
14
14
|
import { makeSwitch } from "./switch-view.js";
|
|
15
15
|
import { DISABLED_OPACITY } from "./form-control-tokens.js";
|
|
16
16
|
import { shareRef } from "./form-control-logic.js";
|
package/dist/switch.native.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<Switch>` (native). Binds ./switch-view.js to React Native's own
|
|
2
2
|
// primitives; only the import differs from ./switch.js.
|
|
3
3
|
|
|
4
|
-
import { View,
|
|
4
|
+
import { View, Pressable, Switch as PlatformSwitch } from "react-native";
|
|
5
|
+
import { Text } from "./bounded-text.native.js";
|
|
5
6
|
import { makeSwitch } from "./switch-view.js";
|
|
6
7
|
|
|
7
8
|
export const Switch = makeSwitch({ View, Text, Pressable, Switch: PlatformSwitch });
|
package/dist/tabs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<Tabs>` (web). Binds ./tabs-view.js to react-native-web; see
|
|
2
2
|
// ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeTabs } from "./tabs-view.js";
|
|
6
6
|
|
|
7
7
|
export const Tabs = makeTabs(ReactNative);
|
package/dist/tabs.native.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<Tabs>` (native). Binds ./tabs-view.js to React Native's own primitives;
|
|
2
2
|
// only the import differs from ./tabs.js.
|
|
3
3
|
|
|
4
|
-
import { View,
|
|
4
|
+
import { View, Pressable, ScrollView } from "react-native";
|
|
5
|
+
import { Text } from "./bounded-text.native.js";
|
|
5
6
|
import { makeTabs } from "./tabs-view.js";
|
|
6
7
|
|
|
7
8
|
export const Tabs = makeTabs({ View, Text, Pressable, ScrollView });
|
package/dist/text-field.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `<TextField>` (web). Binds ./text-field-view.js to react-native-web; see
|
|
2
2
|
// ./primitives.js for why not the bare specifier.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { ReactNative } from "./text-scale.js";
|
|
5
5
|
import { makeTextField } from "./text-field-view.js";
|
|
6
6
|
import { TextInput } from "./primitives.js";
|
|
7
7
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// `<TextField>` (native). Binds ./text-field-view.js to React Native's own
|
|
2
2
|
// primitives; only the import differs from ./text-field.js.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { View, Pressable } from "react-native";
|
|
5
|
+
import { TextInput, Text } from "./bounded-text.native.js";
|
|
5
6
|
import { makeTextField } from "./text-field-view.js";
|
|
6
7
|
|
|
7
8
|
export const TextField = makeTextField({ TextInput, View, Text, Pressable });
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// sc-12791: device font-scale arithmetic, React-free so node tests can load it.
|
|
2
|
+
|
|
3
|
+
// Unstyled text renders at 14px in both React Native and react-native-web.
|
|
4
|
+
export const DEFAULT_FONT_SIZE = 14;
|
|
5
|
+
|
|
6
|
+
// `em` is relative to an already-scaled parent, so it is left alone.
|
|
7
|
+
const ABSOLUTE_LENGTH = /\d(?:px|rem)$/;
|
|
8
|
+
|
|
9
|
+
function flattenStyle(style, into = {}) {
|
|
10
|
+
if (Array.isArray(style)) {
|
|
11
|
+
for (const entry of style) flattenStyle(entry, into);
|
|
12
|
+
} else if (style && typeof style === "object") {
|
|
13
|
+
Object.assign(into, style);
|
|
14
|
+
}
|
|
15
|
+
return into;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function scaleLength(value, factor) {
|
|
19
|
+
if (typeof value === "number") return value * factor;
|
|
20
|
+
if (typeof value === "string" && ABSOLUTE_LENGTH.test(value.trim())) {
|
|
21
|
+
return `calc(${value.trim()} * ${factor})`;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The multiplier one text element gets under a preview scale, honouring the
|
|
28
|
+
* same per-element props React Native does.
|
|
29
|
+
*
|
|
30
|
+
* @param {number} scale The previewed device font scale.
|
|
31
|
+
* @param {{ allowFontScaling?: boolean, maxFontSizeMultiplier?: number }} props
|
|
32
|
+
* @returns {number}
|
|
33
|
+
*/
|
|
34
|
+
export function textScaleFactor(scale, props) {
|
|
35
|
+
if (!(scale > 1) || props?.allowFontScaling === false) return 1;
|
|
36
|
+
const cap = props?.maxFontSizeMultiplier;
|
|
37
|
+
return typeof cap === "number" && cap >= 1 ? Math.min(scale, cap) : scale;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `style` with its font size and line height multiplied by `factor`.
|
|
42
|
+
*
|
|
43
|
+
* @param {any} style A React Native style (object, array, or falsy).
|
|
44
|
+
* @param {number} factor
|
|
45
|
+
* @param {{ inheritsSize?: boolean }} [options] `inheritsSize` marks text
|
|
46
|
+
* nested in already-scaled text: without its own size it inherits the
|
|
47
|
+
* parent's, which must not be multiplied twice.
|
|
48
|
+
* @returns {any} The original style when nothing changes.
|
|
49
|
+
*/
|
|
50
|
+
export function scaleTextStyle(style, factor, { inheritsSize = false } = {}) {
|
|
51
|
+
if (factor === 1) return style;
|
|
52
|
+
const flat = flattenStyle(style);
|
|
53
|
+
const override = {};
|
|
54
|
+
const fontSize = flat.fontSize ?? (inheritsSize ? undefined : DEFAULT_FONT_SIZE);
|
|
55
|
+
const scaledFontSize = scaleLength(fontSize, factor);
|
|
56
|
+
if (scaledFontSize !== undefined) override.fontSize = scaledFontSize;
|
|
57
|
+
const scaledLineHeight = scaleLength(flat.lineHeight, factor);
|
|
58
|
+
if (scaledLineHeight !== undefined) override.lineHeight = scaledLineHeight;
|
|
59
|
+
return Object.keys(override).length > 0 ? [style, override] : style;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Previews a device font scale for every SDK `Text` / `TextInput` below it, as
|
|
3
|
+
* a phone's text-size setting would: font sizes and line heights grow, layout
|
|
4
|
+
* boxes do not. Web hosts only — native text already follows the device.
|
|
5
|
+
*/
|
|
6
|
+
export function TextScaleProvider(props: { scale?: number; children?: unknown }): unknown;
|
|
7
|
+
|
|
8
|
+
/** react-native-web's `Text`, following the nearest `TextScaleProvider`. */
|
|
9
|
+
export const Text: unknown;
|
|
10
|
+
/** react-native-web's `TextInput`, following the nearest `TextScaleProvider`. */
|
|
11
|
+
export const TextInput: unknown;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Web twin of ./bounded-text.native.js: previews a device text-size setting.
|
|
2
|
+
// Every SDK web module takes react-native-web from here (text-scale.test.js).
|
|
3
|
+
import React from "react";
|
|
4
|
+
import * as ReactNativeWeb from "react-native-web";
|
|
5
|
+
import { scaleTextStyle, textScaleFactor } from "./text-scale-style.js";
|
|
6
|
+
|
|
7
|
+
const TextScaleContext = React.createContext(1);
|
|
8
|
+
const ScaledTextAncestorContext = React.createContext(false);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Previews a device font scale for every SDK Text / TextInput below it.
|
|
12
|
+
* Web hosts only: native text already follows the device setting.
|
|
13
|
+
*
|
|
14
|
+
* @param {{ scale?: number, children?: React.ReactNode }} props
|
|
15
|
+
*/
|
|
16
|
+
export function TextScaleProvider({ scale = 1, children }) {
|
|
17
|
+
const value = Number.isFinite(scale) && scale > 0 ? scale : 1;
|
|
18
|
+
return React.createElement(TextScaleContext.Provider, { value }, children);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function withTextScale(Base, { displayName, nests = false }) {
|
|
22
|
+
const Scaled = React.forwardRef(function ScaledText(props, ref) {
|
|
23
|
+
const scale = React.useContext(TextScaleContext);
|
|
24
|
+
const insideScaledText = React.useContext(ScaledTextAncestorContext);
|
|
25
|
+
if (scale === 1) return React.createElement(Base, { ...props, ref });
|
|
26
|
+
const factor = textScaleFactor(scale, props);
|
|
27
|
+
const style = scaleTextStyle(props.style, factor, { inheritsSize: insideScaledText });
|
|
28
|
+
const element = React.createElement(Base, { ...props, ref, style });
|
|
29
|
+
// Children inherit this size even when this element opted out of scaling.
|
|
30
|
+
if (!nests || insideScaledText) return element;
|
|
31
|
+
return React.createElement(ScaledTextAncestorContext.Provider, { value: true }, element);
|
|
32
|
+
});
|
|
33
|
+
Scaled.displayName = displayName;
|
|
34
|
+
return Scaled;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Text = withTextScale(ReactNativeWeb.Text, { displayName: "Text", nests: true });
|
|
38
|
+
export const TextInput = withTextScale(ReactNativeWeb.TextInput, { displayName: "TextInput" });
|
|
39
|
+
// Spread, not re-exported; see ./primitives.js for why.
|
|
40
|
+
export const ReactNative = { ...ReactNativeWeb, Text, TextInput };
|
package/dist/video.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// thumbnail; Safari draws nothing before playback without the fragment.
|
|
10
10
|
|
|
11
11
|
import React from "react";
|
|
12
|
-
import
|
|
12
|
+
import { ReactNative } from "./text-scale.js";
|
|
13
13
|
|
|
14
14
|
const FIRST_FRAME = "#t=0.001";
|
|
15
15
|
const FITS = { contain: "contain", cover: "cover" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.261.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"homepage": "https://github.com/Colix-AB/AppStudio",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/host.js",
|
|
30
30
|
"default": "./dist/host.js"
|
|
31
31
|
},
|
|
32
|
+
"./text-scale": {
|
|
33
|
+
"types": "./dist/text-scale.d.ts",
|
|
34
|
+
"import": "./dist/text-scale.js",
|
|
35
|
+
"default": "./dist/text-scale.js"
|
|
36
|
+
},
|
|
32
37
|
"./contract": {
|
|
33
38
|
"types": "./dist/index.d.ts",
|
|
34
39
|
"require": "./dist/contract.cjs",
|
|
@@ -56,6 +61,7 @@
|
|
|
56
61
|
],
|
|
57
62
|
"scripts": {
|
|
58
63
|
"build": "node scripts/build.js",
|
|
64
|
+
"generate:contract": "node scripts/contract-cjs.js",
|
|
59
65
|
"test": "node --test \"src/__tests__/*.test.js\""
|
|
60
66
|
},
|
|
61
67
|
"engines": {
|