@colixsystems/widget-sdk 0.343.0 → 0.343.2
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 +10 -2
- package/dist/contract.cjs +1 -1
- package/dist/contract.js +1 -1
- package/dist/datetimepicker-cells.js +1 -1
- package/dist/datetimepicker-names.js +6 -5
- package/dist/datetimepicker-sheet-header.js +1 -1
- package/dist/datetimepicker-sheet-parts.js +2 -2
- package/dist/datetimepicker-sheet-state.js +1 -1
- package/dist/datetimepicker-sheet.js +8 -7
- package/dist/datetimepicker-time-columns.js +2 -2
- package/dist/datetimepicker-view.js +1 -2
- package/dist/datetimepicker.native.js +24 -6
- package/dist/linter.cjs +590 -17
- package/dist/linter.js +590 -17
- package/dist/primitives.native.js +2 -6
- package/dist/sdk-texts.cjs +5 -0
- package/dist/sdk-texts.js +5 -0
- package/dist/source-mask.cjs +4 -2
- package/dist/source-mask.js +4 -2
- package/package.json +1 -1
- package/src/contract.js +1 -1
- package/src/sdk-texts.js +5 -0
package/README.md
CHANGED
|
@@ -91,7 +91,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.343.
|
|
94
|
+
`v0.343.2` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.343.2 (contract 1.280.0)
|
|
97
|
+
|
|
98
|
+
**`style-field-unread` counts the fields `<Card>` paints from the widget's style when it is handed whole.** The recommended `<Card style={style}>` names none of `cardBackground`, `cardBorderColor`, `cardRadius`, `cardPadding`, `cardGradient`, `shadow` or `margin`, so the rule called every one a dead control, and the widget agent's style repair removed them from the manifest. A widget that hands its style to `<Card style>` now reads all of them, less `margin` under `withoutMargin` (or `withoutMargin={true}`), less any field a `<Card>` prop overrides (`background`, `borderColor`, `radius`, `padding`, `gradient`, `shadow`), and less `cardGradient` on a photo card (`image`). The style counts only where it is the widget's own: `useWidgetStyle()` or a name bound to it, `props.style` (any component's parameter), `style` destructured from a component's props in its parameters or its body (renamed or not), a prop a call site fills from one of those (`<Post cardStyle={style} />`, read as `cardStyle` or `props.cardStyle`, even from another file of the bundle), or a `{ ...style }` copy. A default export wrapped in `memo(…)` or bound to a lowercase name is a component; an array method's callback is not. It may be handed alone, with a fallback (`style || {}`), as either branch of a ternary, as an item of a style array, or spread into an object literal (`{ ...style, flex: 1 }`). A style sheet, the theme, a record's `item.style` or a sub-object such as `style.header` hands over nothing, and neither does a tag whose brackets do not pair. The helpers count for the fields each paints, called or spread (`{ ...marginStyle(style) }`): `cardOverlay` (the card fields except the gradient, plus `shadow` and `margin`), `cardSurfaceStyle` (the same, without `margin`), `cardGradientProps` (`cardGradient`) and `marginStyle` (`margin`). Only names imported from `@colixsystems/widget-sdk` count, under any local alias. Every other field is still read by name. Fix-only: no rule was added or renamed.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.343.1 (contract 1.280.0)
|
|
101
|
+
|
|
102
|
+
**`<DateTimePicker>` opens its calendar on the first tap on iOS.** iOS's own picker opened as a compact date chip below the field, and only a second tap on the chip showed the calendar. The field now opens the same themed calendar and time sheet the web shows: in the app's language and theme, with its bounds. The sheet scrolls when the calendar and the time columns stack taller than a small phone, and a keyboard left up by a text field closes as it opens. Android keeps its own date and time dialogs, which already open on the first tap. Fix-only: no prop or export changed.
|
|
95
103
|
|
|
96
104
|
### What's new in 0.343.0 (contract 1.280.0)
|
|
97
105
|
|
|
@@ -2758,7 +2766,7 @@ Additive — one new hook, one new optional context-slice member; no existing ex
|
|
|
2758
2766
|
**Two linter rules make the styling contract checkable, and `lintStyleWiring` joins the linter export (sc-6455).** Every visual value a widget writes reaches the app's owner through one of exactly two channels — a **theme token** (`useTheme()`), which is the app-wide default and follows a look change, or a **`styleSchema` field** read off `props.style`, which the Studio offers per instance in the widget editor *and* app-wide under **Design → Widget appearance**. A literal reaches neither: it outranks the theme permanently and no control on either surface can move it, so the owner finds a corner of their app they cannot restyle. Until now that rule was documentation only.
|
|
2759
2767
|
|
|
2760
2768
|
- **`no-hardcoded-design`** flags a colour literal (`#rgb` / `#rrggbb` / `#rrggbbaa`, `rgb()`, `rgba()`, `hsl()`, `hsla()`), a `fontFamily` string literal or (since 0.326.0) a family named as the fallback of a font read (`style.titleFont || "Lora"`), a numeric `fontSize`, or (since 0.165.0) a literal non-zero corner radius (`borderRadius: 12`, any per-corner spelling). A `fontSize` resolved off a theme token or a style field (`style.valueSize ?? 18`) is *not* flagged — a literal `default` beside a declared field is the contract working — and neither is a computed radius (`size / 2`) or `0`. Raw `padding` / `margin` numbers are deliberately out of scope: measured layout legitimately carries them, so a spacing rule would be noise.
|
|
2761
|
-
- **`style-field-unread`** flags a `styleSchema` field whose name appears nowhere in the widget's source — a dead control the author moves to no effect. It runs over the WHOLE bundle, not per file, so a split-impl widget that reads a field in `widget.web.jsx` and not in `widget.native.jsx` is correctly counted as wired.
|
|
2769
|
+
- **`style-field-unread`** flags a `styleSchema` field whose name appears nowhere in the widget's source — a dead control the author moves to no effect. It runs over the WHOLE bundle, not per file, so a split-impl widget that reads a field in `widget.web.jsx` and not in `widget.native.jsx` is correctly counted as wired. Since 0.343.2 a field is also read when the widget hands its own style (from `useWidgetStyle()` or `props.style`) whole to the SDK consumer that paints it: `<Card style={style}>` (less a field a `<Card>` prop overrides, `margin` under `withoutMargin` and `cardGradient` on a photo card), `cardOverlay`, `cardSurfaceStyle`, `cardGradientProps` or `marginStyle`, imported from the SDK.
|
|
2762
2770
|
|
|
2763
2771
|
A value that genuinely cannot be a token — a categorical series palette, a video letterbox, a scannable QR plate — is licensed with a preceding comment. **The reason is mandatory**; a bare marker licenses nothing. A marker on its own line covers the whole statement below it (bracket-balanced, so one marker covers a multi-line palette); a trailing marker covers only its own line.
|
|
2764
2772
|
|
package/dist/contract.cjs
CHANGED
|
@@ -3690,7 +3690,7 @@ const PRIMITIVES = [
|
|
|
3690
3690
|
{
|
|
3691
3691
|
name: "DateTimePicker",
|
|
3692
3692
|
description:
|
|
3693
|
-
'Cross-platform date / time / datetime field. `<DateTimePicker value={iso} onChange={iso => …} mode="date" | "time" | "datetime" accessibilityLabel="Due" />`. The value prop and the onChange callback both speak ISO 8601 strings (the datastore wire format): `YYYY-MM-DD` for date, `HH:mm` for time, a full UTC instant for datetime — authors never round-trip through `new Date()`. Clearing emits "". The field shows the value in the app user\'s language beside a calendar (or clock) icon, with a clear button once it holds a value. Web
|
|
3693
|
+
'Cross-platform date / time / datetime field. `<DateTimePicker value={iso} onChange={iso => …} mode="date" | "time" | "datetime" accessibilityLabel="Due" />`. The value prop and the onChange callback both speak ISO 8601 strings (the datastore wire format): `YYYY-MM-DD` for date, `HH:mm` for time, a full UTC instant for datetime — authors never round-trip through `new Date()`. Clearing emits "". The field shows the value in the app user\'s language beside a calendar (or clock) icon, with a clear button once it holds a value. Web and iOS open a themed calendar sheet in `<Overlay>`: a month grid (keyboard: arrows, Home/End, PageUp/PageDown), a month and year jump, hour and minute columns for time, and a Today / Now button. Android opens the operating system\'s own date and time dialogs (@react-native-community/datetimepicker). `minimumDate` / `maximumDate` (ISO, `HH:mm` in time mode) bound what can be picked; `disabled` locks the field. Optional copy: `placeholder`, `clearLabel` (default "Clear"), `doneLabel` (default "Done", closes the time sheet), `closeAccessibilityLabel`; `testID` names the field. Colours come from the workspace theme — the field from the text-field tokens, the sheet from the popover scope, the chosen day from `colors.primary`; never style it with raw CSS or `document`.',
|
|
3694
3694
|
rnComponent: "@react-native-community/datetimepicker",
|
|
3695
3695
|
docsUrl: "https://github.com/react-native-datetimepicker/datetimepicker",
|
|
3696
3696
|
},
|
package/dist/contract.js
CHANGED
|
@@ -3685,7 +3685,7 @@ const PRIMITIVES = [
|
|
|
3685
3685
|
{
|
|
3686
3686
|
name: "DateTimePicker",
|
|
3687
3687
|
description:
|
|
3688
|
-
'Cross-platform date / time / datetime field. `<DateTimePicker value={iso} onChange={iso => …} mode="date" | "time" | "datetime" accessibilityLabel="Due" />`. The value prop and the onChange callback both speak ISO 8601 strings (the datastore wire format): `YYYY-MM-DD` for date, `HH:mm` for time, a full UTC instant for datetime — authors never round-trip through `new Date()`. Clearing emits "". The field shows the value in the app user\'s language beside a calendar (or clock) icon, with a clear button once it holds a value. Web
|
|
3688
|
+
'Cross-platform date / time / datetime field. `<DateTimePicker value={iso} onChange={iso => …} mode="date" | "time" | "datetime" accessibilityLabel="Due" />`. The value prop and the onChange callback both speak ISO 8601 strings (the datastore wire format): `YYYY-MM-DD` for date, `HH:mm` for time, a full UTC instant for datetime — authors never round-trip through `new Date()`. Clearing emits "". The field shows the value in the app user\'s language beside a calendar (or clock) icon, with a clear button once it holds a value. Web and iOS open a themed calendar sheet in `<Overlay>`: a month grid (keyboard: arrows, Home/End, PageUp/PageDown), a month and year jump, hour and minute columns for time, and a Today / Now button. Android opens the operating system\'s own date and time dialogs (@react-native-community/datetimepicker). `minimumDate` / `maximumDate` (ISO, `HH:mm` in time mode) bound what can be picked; `disabled` locks the field. Optional copy: `placeholder`, `clearLabel` (default "Clear"), `doneLabel` (default "Done", closes the time sheet), `closeAccessibilityLabel`; `testID` names the field. Colours come from the workspace theme — the field from the text-field tokens, the sheet from the popover scope, the chosen day from `colors.primary`; never style it with raw CSS or `document`.',
|
|
3689
3689
|
rnComponent: "@react-native-community/datetimepicker",
|
|
3690
3690
|
docsUrl: "https://github.com/react-native-datetimepicker/datetimepicker",
|
|
3691
3691
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// REQ-WSDK-PLATFORM §6 — the names the
|
|
2
|
-
//
|
|
1
|
+
// REQ-WSDK-PLATFORM §6 — the names the `<DateTimePicker>` sheet shows, in the
|
|
2
|
+
// viewer's language through Intl, with the SDK's own texts when an engine refuses.
|
|
3
3
|
|
|
4
4
|
import { normaliseMode, partsToDate } from "./datetimepicker-format.js";
|
|
5
5
|
import { WEEK_LENGTH } from "./datetimepicker-calendar.js";
|
|
6
|
+
import { COMPONENT_TEXTS, textInLanguage } from "./sdk-texts.js";
|
|
6
7
|
|
|
7
8
|
const ENGLISH_MONTHS = [
|
|
8
9
|
"January", "February", "March", "April", "May", "June",
|
|
@@ -79,7 +80,7 @@ export function relativeNowLabel(locale, mode) {
|
|
|
79
80
|
const text = new Intl.RelativeTimeFormat(locale || undefined, { numeric: "auto" }).format(0, unit);
|
|
80
81
|
return capitalise(text, locale);
|
|
81
82
|
} catch {
|
|
82
|
-
return unit === "day" ? "
|
|
83
|
+
return textInLanguage(COMPONENT_TEXTS[unit === "day" ? "picker_today" : "picker_now"], locale);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -89,9 +90,9 @@ export function fieldName(locale, field) {
|
|
|
89
90
|
const name = new Intl.DisplayNames(locale || undefined, { type: "dateTimeField" }).of(field);
|
|
90
91
|
if (name) return capitalise(name, locale);
|
|
91
92
|
} catch {
|
|
92
|
-
// Older engines lack `dateTimeField
|
|
93
|
+
// Older engines and Hermes lack `dateTimeField`.
|
|
93
94
|
}
|
|
94
|
-
return field === "hour" ? "
|
|
95
|
+
return textInLanguage(COMPONENT_TEXTS[field === "hour" ? "picker_hour" : "picker_minute"], locale);
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export function twoDigits(value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// REQ-WSDK-PLATFORM §6 — the grids of the
|
|
2
|
-
// month's days, and the months or years of the jump. Bound
|
|
1
|
+
// REQ-WSDK-PLATFORM §6 — the grids of the `<DateTimePicker>` sheet: the
|
|
2
|
+
// month's days, and the months or years of the jump. Bound
|
|
3
3
|
// by ./datetimepicker-sheet.js.
|
|
4
4
|
|
|
5
5
|
import React from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// REQ-WSDK-PLATFORM §6 — the state of an open
|
|
1
|
+
// REQ-WSDK-PLATFORM §6 — the state of an open `<DateTimePicker>` sheet:
|
|
2
2
|
// the draft value, the month or period on show, the day holding keyboard
|
|
3
3
|
// focus, and every way the viewer changes them.
|
|
4
4
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// REQ-WSDK-PLATFORM §6 — the
|
|
2
|
-
// themed calendar and time sheet in `<Overlay>`. The browser's
|
|
3
|
-
// cannot be themed
|
|
4
|
-
//
|
|
1
|
+
// REQ-WSDK-PLATFORM §6 — the `<DateTimePicker>`'s picking surface on the web
|
|
2
|
+
// and iOS: a themed calendar and time sheet in `<Overlay>`. The browser's date
|
|
3
|
+
// popup cannot be themed, and iOS's opens as a chip needing a second tap;
|
|
4
|
+
// Android keeps its OS dialog (./datetimepicker.native.js).
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { GRID_ROWS, firstDayOfWeek, isHourAllowed, isTimeAllowed } from "./datetimepicker-calendar.js";
|
|
@@ -20,7 +20,7 @@ const SHEET_PADDING = 16;
|
|
|
20
20
|
|
|
21
21
|
/** @param {{View: any, Text: any, Pressable: any, ScrollView: any, Platform: any, Overlay: any}} rn */
|
|
22
22
|
export function makeDateTimeSheet(rn) {
|
|
23
|
-
const { View, Text, Overlay } = rn;
|
|
23
|
+
const { View, Text, ScrollView, Overlay } = rn;
|
|
24
24
|
const { DayGrid, PeriodGrid } = makeSheetParts(rn);
|
|
25
25
|
const TimeColumns = makeTimeColumns(rn);
|
|
26
26
|
const { Header, TextButton } = makeSheetControls(rn);
|
|
@@ -66,9 +66,10 @@ export function makeDateTimeSheet(rn) {
|
|
|
66
66
|
function SheetBody({ t, mode, parts, bounds, locale, heading, onPick, onClose, doneLabel, testID }) {
|
|
67
67
|
const state = useSheetState({ mode, parts, bounds, onPick, onClose });
|
|
68
68
|
const shared = { t, state, bounds, locale, testID };
|
|
69
|
+
// Scrolls where calendar and time stack taller than a small phone.
|
|
69
70
|
return h(
|
|
70
|
-
|
|
71
|
-
{ style: { gap: 16, alignItems: "center" } },
|
|
71
|
+
ScrollView,
|
|
72
|
+
{ style: { flexShrink: 1 }, contentContainerStyle: { gap: 16, alignItems: "center" } },
|
|
72
73
|
// The sheet covers its field, so it names the field it edits.
|
|
73
74
|
heading
|
|
74
75
|
? h(Text, { style: { alignSelf: "stretch", fontFamily: t.fontFamily, fontSize: t.labelSize, fontWeight: "500", color: t.helperColor } }, heading)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// REQ-WSDK-PLATFORM §6 — the hour and minute columns of the
|
|
2
|
-
// `<DateTimePicker>` sheet. Bound
|
|
1
|
+
// REQ-WSDK-PLATFORM §6 — the hour and minute columns of the
|
|
2
|
+
// `<DateTimePicker>` sheet. Bound by ./datetimepicker-sheet.js.
|
|
3
3
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { nextOptionIndex } from "./form-control-tokens.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// REQ-WSDK-PLATFORM §6 — the ONE `<DateTimePicker>` field both hosts render.
|
|
2
2
|
// The field (icon, value in the viewer's language, clear button) is shared;
|
|
3
3
|
// what opens when it is pressed is the host's `Surface`: a themed calendar
|
|
4
|
-
// sheet on the web, the operating system's own
|
|
4
|
+
// sheet on the web and iOS, the operating system's own dialog on Android.
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { useHostLocale, useHostTheme, useSdkTextDefaults } from "./hooks.js";
|
|
@@ -194,7 +194,6 @@ export function makeDateTimePicker(rn) {
|
|
|
194
194
|
: null,
|
|
195
195
|
);
|
|
196
196
|
|
|
197
|
-
// A sibling of the field: iOS draws its picker inline, below it.
|
|
198
197
|
return h(
|
|
199
198
|
React.Fragment,
|
|
200
199
|
null,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
// `<DateTimePicker>` (native). Binds ./datetimepicker-view.js to React Native
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// `<DateTimePicker>` (native). Binds ./datetimepicker-view.js to React Native.
|
|
2
|
+
// iOS opens the web's themed calendar sheet: its own picker opens as a compact
|
|
3
|
+
// chip that takes a second tap. Android keeps its OS dialog, via
|
|
4
|
+
// `@react-native-community/datetimepicker`, which is imperative there —
|
|
5
|
+
// rendering it opens the dialog — so it mounts only while open.
|
|
5
6
|
|
|
6
7
|
import React from "react";
|
|
7
8
|
// eslint-disable-next-line no-restricted-syntax
|
|
8
9
|
import RNDateTimePicker from "@react-native-community/datetimepicker";
|
|
9
|
-
import { View, Pressable, Platform } from "react-native";
|
|
10
|
+
import { View, Pressable, ScrollView, Platform, Keyboard } from "react-native";
|
|
10
11
|
import { Text } from "./bounded-text.native.js";
|
|
11
12
|
import { makeDateTimePicker } from "./datetimepicker-view.js";
|
|
13
|
+
import { makeDateTimeSheet } from "./datetimepicker-sheet.js";
|
|
14
|
+
import { Overlay } from "./overlay.native.js";
|
|
12
15
|
import { nowParts, partsToDate } from "./datetimepicker-format.js";
|
|
13
16
|
import { osDialogModes, applyDialogPick } from "./datetimepicker-os-steps.js";
|
|
14
17
|
import { clampToBounds } from "./datetimepicker-calendar.js";
|
|
@@ -62,4 +65,19 @@ function dropEmpty(parts) {
|
|
|
62
65
|
return Object.fromEntries(Object.entries(parts).filter(([, v]) => v != null));
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
const primitives = { View, Text, Pressable, ScrollView, Platform };
|
|
69
|
+
const Sheet = makeDateTimeSheet({ ...primitives, Overlay });
|
|
70
|
+
|
|
71
|
+
function IosSheet(props) {
|
|
72
|
+
// iOS keeps a focused input's keyboard up over the sheet, hiding its lower half.
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (props.open) Keyboard.dismiss();
|
|
75
|
+
}, [props.open]);
|
|
76
|
+
return React.createElement(Sheet, props);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function Surface(props) {
|
|
80
|
+
return React.createElement(Platform.OS === "ios" ? IosSheet : OsPicker, props);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const DateTimePicker = makeDateTimePicker({ ...primitives, Surface });
|