@astryxdesign/cli 0.7.13-canary.a5ad1f2 → 0.7.13-canary.fd5cf0d
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/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.doc.mjs +21 -0
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider04Calendar.tsx +46 -0
- package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.doc.mjs +18 -0
- package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +101 -0
- package/package.json +14 -14
|
@@ -257,7 +257,7 @@ useChatPasteAsToken useChatPasteAsToken Chat/Chat.doc.mjs Chat/useChatPasteAsTok
|
|
|
257
257
|
useChatStreamScroll useChatStreamScroll Chat/Chat.doc.mjs Chat/useChatStreamScroll.ts
|
|
258
258
|
useCloseMobileDrawerOnActivate useCloseMobileDrawerOnActivate AppShell/AppShell.doc.mjs AppShell/useCloseMobileDrawerOnActivate.ts
|
|
259
259
|
useComponentTranslator useComponentTranslator i18n/InternationalizationProvider.doc.mjs i18n/useComponentTranslator.ts
|
|
260
|
-
useDirection useDirection i18n/
|
|
260
|
+
useDirection useDirection i18n/useDirection.doc.mjs i18n/useDirection.ts
|
|
261
261
|
useDrawerDialogPresence useDrawerDialogPresence Drawer/Drawer.doc.mjs Drawer/useDrawerDialogPresence.ts
|
|
262
262
|
useEndLaneReserve useEndLaneReserve Tokenizer/Tokenizer.doc.mjs Tokenizer/useEndLaneReserve.ts
|
|
263
263
|
useFieldStatusAnnouncement useFieldStatusAnnouncement FieldStatus/FieldStatus.doc.mjs FieldStatus/useFieldStatusAnnouncement.ts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'InternationalizationProvider',
|
|
7
|
+
name: 'InternationalizationProvider — Calendar',
|
|
8
|
+
displayName: 'Internationalization Provider — Calendar',
|
|
9
|
+
description:
|
|
10
|
+
'Set the `calendar` prop and the `Calendar` and `DateInput` inside the provider show that calendar system. The value stays a Gregorian ISO date. Japanese and Buddhist dates work in every browser; calendars such as Persian or Hebrew also need `Temporal` or a polyfill.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 16 / 9,
|
|
13
|
+
componentsUsed: [
|
|
14
|
+
'InternationalizationProvider',
|
|
15
|
+
'Calendar',
|
|
16
|
+
'DateInput',
|
|
17
|
+
'SegmentedControl',
|
|
18
|
+
'Layout',
|
|
19
|
+
'Text',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import {InternationalizationProvider} from '@astryxdesign/core/i18n';
|
|
7
|
+
import {Calendar, type ISODateString} from '@astryxdesign/core/Calendar';
|
|
8
|
+
import {DateInput} from '@astryxdesign/core/DateInput';
|
|
9
|
+
import {VStack} from '@astryxdesign/core/Layout';
|
|
10
|
+
import {
|
|
11
|
+
SegmentedControl,
|
|
12
|
+
SegmentedControlItem,
|
|
13
|
+
} from '@astryxdesign/core/SegmentedControl';
|
|
14
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
15
|
+
|
|
16
|
+
type CalendarSystem = 'gregory' | 'japanese' | 'buddhist';
|
|
17
|
+
|
|
18
|
+
export default function InternationalizationProviderCalendar() {
|
|
19
|
+
const [calendar, setCalendar] = useState<CalendarSystem>('japanese');
|
|
20
|
+
const [value, setValue] = useState<ISODateString | undefined>('2026-10-30');
|
|
21
|
+
return (
|
|
22
|
+
<InternationalizationProvider locale="en" calendar={calendar}>
|
|
23
|
+
<VStack gap={4} hAlign="center">
|
|
24
|
+
<SegmentedControl
|
|
25
|
+
label="Calendar"
|
|
26
|
+
value={calendar}
|
|
27
|
+
onChange={next => setCalendar(next as CalendarSystem)}
|
|
28
|
+
size="sm">
|
|
29
|
+
<SegmentedControlItem value="gregory" label="Gregorian" />
|
|
30
|
+
<SegmentedControlItem value="japanese" label="Japanese" />
|
|
31
|
+
<SegmentedControlItem value="buddhist" label="Buddhist" />
|
|
32
|
+
</SegmentedControl>
|
|
33
|
+
<DateInput
|
|
34
|
+
label="Start date"
|
|
35
|
+
value={value}
|
|
36
|
+
onChange={setValue}
|
|
37
|
+
controlStyle={{width: 300}}
|
|
38
|
+
/>
|
|
39
|
+
<Calendar value={value ?? null} onChange={next => setValue(next)} />
|
|
40
|
+
<Text type="supporting" color="secondary">
|
|
41
|
+
{value ? `Value: ${value}` : 'No date'}
|
|
42
|
+
</Text>
|
|
43
|
+
</VStack>
|
|
44
|
+
</InternationalizationProvider>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'useDirection',
|
|
7
|
+
name: 'useDirection — Hook Usage',
|
|
8
|
+
displayName: 'useDirection — Hook Usage',
|
|
9
|
+
description:
|
|
10
|
+
'Demonstrates reading ambient text direction during render to draw a direction-aware canvas sparkline whose time axis runs from the logical inline start edge.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 16 / 9,
|
|
13
|
+
componentsUsed: [
|
|
14
|
+
'InternationalizationProvider',
|
|
15
|
+
'SegmentedControl',
|
|
16
|
+
'Layout',
|
|
17
|
+
],
|
|
18
|
+
};
|
package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useEffect, useRef, useState} from 'react';
|
|
6
|
+
import {InternationalizationProvider, useDirection} from '@astryxdesign/core';
|
|
7
|
+
import {VStack} from '@astryxdesign/core/Layout';
|
|
8
|
+
import {
|
|
9
|
+
SegmentedControl,
|
|
10
|
+
SegmentedControlItem,
|
|
11
|
+
} from '@astryxdesign/core/SegmentedControl';
|
|
12
|
+
|
|
13
|
+
const DATA_POINTS = [10, 25, 18, 40, 32, 60, 48, 75];
|
|
14
|
+
|
|
15
|
+
function Sparkline() {
|
|
16
|
+
const direction = useDirection();
|
|
17
|
+
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const canvas = canvasRef.current;
|
|
21
|
+
if (!canvas) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const ctx = canvas.getContext('2d');
|
|
25
|
+
if (!ctx) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const width = canvas.width;
|
|
30
|
+
const height = canvas.height;
|
|
31
|
+
ctx.clearRect(0, 0, width, height);
|
|
32
|
+
|
|
33
|
+
const step = width / (DATA_POINTS.length - 1);
|
|
34
|
+
const maxVal = Math.max(...DATA_POINTS);
|
|
35
|
+
const minVal = Math.min(...DATA_POINTS);
|
|
36
|
+
const range = maxVal - minVal || 1;
|
|
37
|
+
|
|
38
|
+
ctx.beginPath();
|
|
39
|
+
ctx.strokeStyle = '#0064e0';
|
|
40
|
+
ctx.lineWidth = 2;
|
|
41
|
+
|
|
42
|
+
DATA_POINTS.forEach((val, i) => {
|
|
43
|
+
// In LTR: oldest data starts at 0 (left), newest at right.
|
|
44
|
+
// In RTL: oldest data starts at right (width), newest at left.
|
|
45
|
+
const x = direction === 'rtl' ? width - i * step : i * step;
|
|
46
|
+
const y = height - ((val - minVal) / range) * (height - 10) - 5;
|
|
47
|
+
if (i === 0) {
|
|
48
|
+
ctx.moveTo(x, y);
|
|
49
|
+
} else {
|
|
50
|
+
ctx.lineTo(x, y);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
ctx.stroke();
|
|
54
|
+
|
|
55
|
+
// Draw point at latest value
|
|
56
|
+
const lastIndex = DATA_POINTS.length - 1;
|
|
57
|
+
const lastX = direction === 'rtl' ? 0 : width;
|
|
58
|
+
const lastY =
|
|
59
|
+
height - ((DATA_POINTS[lastIndex] - minVal) / range) * (height - 10) - 5;
|
|
60
|
+
ctx.beginPath();
|
|
61
|
+
ctx.arc(lastX, lastY, 4, 0, Math.PI * 2);
|
|
62
|
+
ctx.fillStyle = '#0064e0';
|
|
63
|
+
ctx.fill();
|
|
64
|
+
}, [direction]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<canvas
|
|
68
|
+
ref={canvasRef}
|
|
69
|
+
width={200}
|
|
70
|
+
height={60}
|
|
71
|
+
data-testid="sparkline-canvas"
|
|
72
|
+
data-direction={direction}
|
|
73
|
+
style={{border: '1px solid #e1e4e8', borderRadius: 4}}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default function UseDirectionHookUsage() {
|
|
79
|
+
const [lang, setLang] = useState<'en' | 'ar'>('en');
|
|
80
|
+
const isRtl = lang === 'ar';
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<InternationalizationProvider locale={lang} dir={isRtl ? 'rtl' : 'ltr'}>
|
|
84
|
+
<VStack
|
|
85
|
+
gap={4}
|
|
86
|
+
hAlign="center"
|
|
87
|
+
dir={isRtl ? 'rtl' : 'ltr'}
|
|
88
|
+
style={{width: '100%'}}>
|
|
89
|
+
<SegmentedControl
|
|
90
|
+
label="Locale"
|
|
91
|
+
value={lang}
|
|
92
|
+
onChange={next => setLang(next as 'en' | 'ar')}
|
|
93
|
+
size="sm">
|
|
94
|
+
<SegmentedControlItem value="en" label="English (LTR)" />
|
|
95
|
+
<SegmentedControlItem value="ar" label="العربية (RTL)" />
|
|
96
|
+
</SegmentedControl>
|
|
97
|
+
<Sparkline />
|
|
98
|
+
</VStack>
|
|
99
|
+
</InternationalizationProvider>
|
|
100
|
+
);
|
|
101
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.13-canary.
|
|
3
|
+
"version": "0.7.13-canary.fd5cf0d",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -111,21 +111,21 @@
|
|
|
111
111
|
"@babel/parser": "7.29.8",
|
|
112
112
|
"@babel/plugin-transform-typescript": "7.29.7",
|
|
113
113
|
"@babel/types": "7.29.8",
|
|
114
|
-
"@stylexjs/babel-plugin": "^0.19.
|
|
114
|
+
"@stylexjs/babel-plugin": "^0.19.1",
|
|
115
115
|
"ast-types": "0.16.3",
|
|
116
116
|
"commander": "^12.1.0",
|
|
117
|
-
"ignore": "^7.0.
|
|
117
|
+
"ignore": "^7.0.14",
|
|
118
118
|
"jiti": "^2.7.0",
|
|
119
|
-
"jscodeshift": "^17.
|
|
120
|
-
"linkedom": "^0.18.
|
|
119
|
+
"jscodeshift": "^17.4.0",
|
|
120
|
+
"linkedom": "^0.18.15",
|
|
121
121
|
"node-diff3": "3.2.1",
|
|
122
122
|
"postcss": "^8.5.23",
|
|
123
123
|
"postcss-selector-parser": "^7.1.6",
|
|
124
124
|
"recast": "0.23.21",
|
|
125
|
-
"zod": "^4.
|
|
125
|
+
"zod": "^4.6.7"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
|
-
"@astryxdesign/core": "0.7.13-canary.
|
|
128
|
+
"@astryxdesign/core": "0.7.13-canary.fd5cf0d"
|
|
129
129
|
},
|
|
130
130
|
"peerDependenciesMeta": {
|
|
131
131
|
"@astryxdesign/core": {
|
|
@@ -133,15 +133,15 @@
|
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
|
-
"@astryxdesign/charts": "0.7.13-canary.
|
|
137
|
-
"@astryxdesign/core": "0.7.13-canary.
|
|
138
|
-
"@astryxdesign/lab": "0.7.13-canary.
|
|
139
|
-
"@astryxdesign/theme-neutral": "0.7.13-canary.
|
|
136
|
+
"@astryxdesign/charts": "0.7.13-canary.fd5cf0d",
|
|
137
|
+
"@astryxdesign/core": "0.7.13-canary.fd5cf0d",
|
|
138
|
+
"@astryxdesign/lab": "0.7.13-canary.fd5cf0d",
|
|
139
|
+
"@astryxdesign/theme-neutral": "0.7.13-canary.fd5cf0d",
|
|
140
140
|
"@heroicons/react": "^2.2.0",
|
|
141
|
-
"@stylexjs/stylex": "^0.19.
|
|
141
|
+
"@stylexjs/stylex": "^0.19.1",
|
|
142
142
|
"@types/babel__core": "^7.20.5",
|
|
143
|
-
"lucide-react": "^1.
|
|
144
|
-
"recharts": "^3.
|
|
143
|
+
"lucide-react": "^1.66.0",
|
|
144
|
+
"recharts": "^3.10.1"
|
|
145
145
|
},
|
|
146
146
|
"scripts": {
|
|
147
147
|
"api:report": "node ../../scripts/api-report/cli.mjs --package .",
|