@lynx-example/lynx-ui-form 0.0.1 → 0.0.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/Basic/data.ts ADDED
@@ -0,0 +1,35 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ export interface FormPageProps {
6
+ title: string
7
+ subtitle: string
8
+ workspaceTypeOptions: RadioOption[]
9
+ initialFormData: FormData
10
+ }
11
+
12
+ export interface RadioOption {
13
+ label: string
14
+ value: string
15
+ }
16
+
17
+ export interface FormData {
18
+ workspaceType: string
19
+ workspaceName: string
20
+ description: string
21
+ }
22
+
23
+ export const formPageData: FormPageProps = {
24
+ title: 'Create a workspace',
25
+ subtitle: 'Set up your workspace to get started.',
26
+ workspaceTypeOptions: [
27
+ { label: 'Personal', value: 'personal' },
28
+ { label: 'Team', value: 'team' },
29
+ ],
30
+ initialFormData: {
31
+ workspaceType: '',
32
+ workspaceName: '',
33
+ description: '',
34
+ },
35
+ }
@@ -0,0 +1,241 @@
1
+ @import "@lynx-js/luna-styles/index.css";
2
+
3
+ /* =========================
4
+ * Container
5
+ * ========================= */
6
+
7
+ .demo-container {
8
+ width: 100%;
9
+ height: 100%;
10
+ display: flex;
11
+ flex-direction: column;
12
+ align-items: center;
13
+ justify-content: center;
14
+ padding-top: 96px;
15
+ padding-bottom: 48px;
16
+ padding-left: 16px;
17
+ padding-right: 16px;
18
+ }
19
+
20
+ .demo-canvas {
21
+ height: 100%;
22
+ width: 100%;
23
+ padding: 64px;
24
+ padding-left: 40px;
25
+ padding-right: 40px;
26
+ border-radius: 16px;
27
+ display: flex;
28
+ flex-direction: column;
29
+ color: var(--content);
30
+ background-color: var(--canvas);
31
+ }
32
+
33
+ .luna-gradient-berry {
34
+ background: linear-gradient(
35
+ 0deg,
36
+ var(--gradient-b),
37
+ var(--gradient-c)
38
+ );
39
+ }
40
+
41
+ /* =========================
42
+ * Form & Typography
43
+ * ========================= */
44
+
45
+ .form-container {
46
+ width: 100%;
47
+ display: flex;
48
+ flex-direction: column;
49
+ }
50
+
51
+ .form-title {
52
+ font-size: 20px;
53
+ font-weight: 700;
54
+ color: var(--content);
55
+ margin-bottom: 6px;
56
+ }
57
+
58
+ .form-subtitle {
59
+ font-size: 14px;
60
+ color: var(--content-muted);
61
+ }
62
+
63
+ .form-divider {
64
+ width: 100%;
65
+ height: 1px;
66
+ background-color: var(--line);
67
+ margin: 16px 0;
68
+ }
69
+
70
+ .form-section-title {
71
+ font-size: 16px;
72
+ font-weight: 600;
73
+ color: var(--content-2);
74
+ margin-bottom: 8px;
75
+ }
76
+
77
+ .form-field-description {
78
+ font-size: 14px;
79
+ color: var(--content-muted);
80
+ margin-bottom: 8px;
81
+ }
82
+
83
+ .form-label {
84
+ font-size: 14px;
85
+ color: var(--content);
86
+ }
87
+
88
+ /* =========================
89
+ * Radio group
90
+ * ========================= */
91
+
92
+ .radio-group-container {
93
+ width: 100%;
94
+ display: flex;
95
+ flex-direction: column;
96
+ gap: 10px;
97
+ }
98
+
99
+ .radio-item {
100
+ display: flex;
101
+ flex-direction: row;
102
+ align-items: center;
103
+ column-gap: 12px;
104
+ padding: 10px;
105
+ border-radius: 12px;
106
+ border-width: 1px;
107
+ border-style: solid;
108
+ border-color: var(--line);
109
+ }
110
+
111
+ /* Indicator */
112
+ .radio-indicator {
113
+ display: flex;
114
+ justify-content: center;
115
+ align-items: center;
116
+ width: 22px;
117
+ height: 22px;
118
+ border-radius: 999px;
119
+ border-width: 1px;
120
+ border-style: solid;
121
+ border-color: var(--line);
122
+ }
123
+
124
+ .radio-indicator.ui-checked {
125
+ border-color: var(--primary);
126
+ }
127
+
128
+ .radio-indicator-checked-item {
129
+ width: 10px;
130
+ height: 10px;
131
+ border-radius: 999px;
132
+ background-color: var(--primary);
133
+ }
134
+
135
+ /* =========================
136
+ * Inputs
137
+ * ========================= */
138
+
139
+ .input-container {
140
+ width: 100%;
141
+ border-radius: 12px;
142
+ border-width: 1px;
143
+ border-style: solid;
144
+ border-color: var(--line);
145
+ margin-bottom: 16px;
146
+ }
147
+
148
+ .form-input {
149
+ font-size: 14px;
150
+ padding: 12px;
151
+ color: var(--content);
152
+ caret-color: var(--primary);
153
+ }
154
+
155
+ .form-input::placeholder {
156
+ color: var(--content-faint);
157
+ }
158
+
159
+ /* =========================
160
+ * Checkbox
161
+ * ========================= */
162
+
163
+ .checkbox-item {
164
+ display: flex;
165
+ flex-direction: row;
166
+ column-gap: 10px;
167
+ align-items: center;
168
+ padding: 4px 0;
169
+ }
170
+
171
+ .checkbox-indicator {
172
+ display: flex;
173
+ justify-content: center;
174
+ align-items: center;
175
+ width: 20px;
176
+ height: 20px;
177
+ border-radius: 4px;
178
+ border-width: 1px;
179
+ border-style: solid;
180
+ border-color: var(--line);
181
+ }
182
+
183
+ .checkbox-indicator.ui-checked {
184
+ border-color: var(--primary);
185
+ background-color: var(--primary);
186
+ }
187
+
188
+ .checkbox-indicator-checked-item {
189
+ width: 11px;
190
+ height: 6px;
191
+ border-left: 2px solid var(--primary-content);
192
+ border-bottom: 2px solid var(--primary-content);
193
+ transform: rotate(-45deg) translate(1px, -0.5px);
194
+ }
195
+
196
+ /* =========================
197
+ * Submit
198
+ * ========================= */
199
+
200
+ .submit-button {
201
+ width: 100%;
202
+ height: 48px;
203
+ border-radius: 9999px;
204
+ background-color: var(--primary);
205
+ display: flex;
206
+ justify-content: center;
207
+ align-items: center;
208
+ margin: 12px 0;
209
+ }
210
+
211
+ .submit-button.ui-active {
212
+ background-color: var(--primary-2);
213
+ }
214
+
215
+ .submit-button-text {
216
+ font-size: 14px;
217
+ color: var(--primary-content);
218
+ }
219
+
220
+ /* =========================
221
+ * Values display
222
+ * ========================= */
223
+
224
+ .form-values-display {
225
+ margin-top: 8px;
226
+ padding: 12px;
227
+ border-radius: 12px;
228
+ border-width: 1px;
229
+ border-style: dashed;
230
+ border-color: var(--line);
231
+ font-family: monospace;
232
+ font-size: 12px;
233
+ color: var(--content-subtle);
234
+ white-space: pre-wrap;
235
+ word-break: break-all;
236
+ }
237
+
238
+ .form-submitted-hint {
239
+ font-size: 14px;
240
+ color: var(--content);
241
+ }
@@ -0,0 +1,113 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { root, useState } from '@lynx-js/react'
6
+
7
+ import {
8
+ CheckboxIndicator,
9
+ FormField,
10
+ FormRoot,
11
+ FormSubmitButton,
12
+ Radio,
13
+ RadioIndicator,
14
+ ScrollView,
15
+ } from '@lynx-js/lynx-ui'
16
+
17
+ import { formPageData } from './data'
18
+
19
+ import './index.css'
20
+
21
+ function App() {
22
+ const [formValues, setFormValues] = useState<Record<string, unknown>>({})
23
+ const [submitted, setSubmitted] = useState(false)
24
+
25
+ return (
26
+ <view className='demo-container lunaris-dark luna-gradient-berry'>
27
+ <ScrollView scrollOrientation='vertical' className='demo-canvas'>
28
+ <FormRoot
29
+ onChanged={(values: Record<string, unknown>) => {
30
+ setFormValues(values)
31
+ setSubmitted(false)
32
+ }}
33
+ initialValues={{
34
+ workspaceType: formPageData.workspaceTypeOptions[0]?.value ?? '',
35
+ workspaceName: 'My Workspace',
36
+ description: 'A place for collaboration',
37
+ }}
38
+ >
39
+ <view className='form-container'>
40
+ <text className='form-title'>{formPageData.title}</text>
41
+ <text className='form-subtitle'>{formPageData.subtitle}</text>
42
+
43
+ <view className='form-divider' />
44
+
45
+ <text className='form-section-title'>Workspace type</text>
46
+ <FormField as='RadioGroupRoot' name='workspaceType'>
47
+ <view className='radio-group-container'>
48
+ {formPageData.workspaceTypeOptions.map(({ label, value }) => (
49
+ <Radio className='radio-item' key={value} value={value}>
50
+ <RadioIndicator className='radio-indicator'>
51
+ <view className='radio-indicator-checked-item' />
52
+ </RadioIndicator>
53
+ <text className='form-label'>{label}</text>
54
+ </Radio>
55
+ ))}
56
+ </view>
57
+ </FormField>
58
+
59
+ <view className='form-divider' />
60
+
61
+ <text className='form-section-title'>Workspace name</text>
62
+ <view className='input-container'>
63
+ <FormField
64
+ as='Input'
65
+ name='workspaceName'
66
+ className='form-input'
67
+ />
68
+ </view>
69
+
70
+ <text className='form-section-title'>Description</text>
71
+ <view className='input-container'>
72
+ <FormField as='Input' name='description' className='form-input' />
73
+ </view>
74
+
75
+ <view className='form-divider' />
76
+
77
+ <FormField as='Checkbox' name='agreement' className='checkbox-item'>
78
+ <CheckboxIndicator className='checkbox-indicator'>
79
+ <view className='checkbox-indicator-checked-item' />
80
+ </CheckboxIndicator>
81
+ <text className='form-label'>
82
+ I agree to the terms and conditions
83
+ </text>
84
+ </FormField>
85
+
86
+ <FormSubmitButton
87
+ onSubmit={(e) => {
88
+ console.info(e)
89
+ setSubmitted(true)
90
+ }}
91
+ className='submit-button'
92
+ >
93
+ <text className='submit-button-text'>Submit</text>
94
+ </FormSubmitButton>
95
+
96
+ <view className='form-divider' />
97
+
98
+ {submitted && (
99
+ <text className='form-submitted-hint'>Submitted ✓</text>
100
+ )}
101
+ <text className='form-values-display'>
102
+ {JSON.stringify(formValues, null, 2)}
103
+ </text>
104
+ </view>
105
+ </FormRoot>
106
+ </ScrollView>
107
+ </view>
108
+ )
109
+ }
110
+
111
+ root.render(<App />)
112
+
113
+ export default App
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lynx-example/lynx-ui-form
2
2
 
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Include variant source files and shared directories in published packages ([#101](https://github.com/lynx-family/lynx-ui/pull/101))
8
+
9
+ - Adjust example styles to improve clarity in screen recordings. ([#102](https://github.com/lynx-family/lynx-ui/pull/102))
10
+
3
11
  ## 0.0.1
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,103 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ export type DemoItemType = 'block' | 'input' | 'textarea'
6
+
7
+ interface DemoItemBase {
8
+ key: string
9
+ type: DemoItemType
10
+ }
11
+
12
+ export interface BlockItem extends DemoItemBase {
13
+ type: 'block'
14
+ }
15
+
16
+ export interface InputItem extends DemoItemBase {
17
+ type: 'input'
18
+ name: string
19
+ label: string
20
+ placeholder: string
21
+ }
22
+
23
+ export interface TextAreaItem extends DemoItemBase {
24
+ type: 'textarea'
25
+ name: string
26
+ label: string
27
+ placeholder: string
28
+ }
29
+
30
+ export type DemoItem = BlockItem | InputItem | TextAreaItem
31
+
32
+ export const demoItems = [
33
+ { type: 'block', key: 'spacer-intro' },
34
+ {
35
+ type: 'input',
36
+ key: 'field-title',
37
+ name: 'title',
38
+ label: 'Title',
39
+ placeholder: 'Type here',
40
+ },
41
+
42
+ { type: 'block', key: 'spacer-1' },
43
+
44
+ {
45
+ type: 'input',
46
+ key: 'field-subtitle',
47
+ name: 'subtitle',
48
+ label: 'Subtitle',
49
+ placeholder: 'Type here',
50
+ },
51
+
52
+ { type: 'block', key: 'spacer-2' },
53
+
54
+ {
55
+ type: 'input',
56
+ key: 'field-email',
57
+ name: 'email',
58
+ label: 'Email',
59
+ placeholder: 'name@example.com',
60
+ },
61
+
62
+ { type: 'block', key: 'spacer-3' },
63
+
64
+ {
65
+ type: 'input',
66
+ key: 'field-phone',
67
+ name: 'phone',
68
+ label: 'Phone',
69
+ placeholder: '+1 234 567 890',
70
+ },
71
+
72
+ { type: 'block', key: 'spacer-4' },
73
+
74
+ {
75
+ type: 'input',
76
+ key: 'field-website',
77
+ name: 'website',
78
+ label: 'Website',
79
+ placeholder: 'https://',
80
+ },
81
+
82
+ { type: 'block', key: 'spacer-5' },
83
+
84
+ {
85
+ type: 'textarea',
86
+ key: 'field-description',
87
+ name: 'description',
88
+ label: 'Description(TextArea)',
89
+ placeholder: 'Write something...',
90
+ },
91
+
92
+ { type: 'block', key: 'spacer-outro' },
93
+
94
+ {
95
+ type: 'input',
96
+ key: 'field-tag',
97
+ name: 'tag',
98
+ label: 'Tag',
99
+ placeholder: 'e.g. demo',
100
+ },
101
+
102
+ { type: 'block', key: 'spacer-tail' },
103
+ ] as const satisfies readonly DemoItem[]
@@ -0,0 +1,205 @@
1
+ @import "@lynx-js/luna-styles/index.css";
2
+
3
+ /* =========================
4
+ * Container
5
+ * ========================= */
6
+
7
+ .demo-container {
8
+ width: 100%;
9
+ height: 100%;
10
+ display: flex;
11
+ flex-direction: column;
12
+ align-items: center;
13
+ justify-content: center;
14
+ padding: 48px;
15
+ padding-left: 16px;
16
+ padding-right: 16px;
17
+ }
18
+
19
+ .demo-canvas {
20
+ width: 100%;
21
+ height: 100%;
22
+ padding: 64px;
23
+ padding-left: 40px;
24
+ padding-right: 40px;
25
+ border-radius: 16px;
26
+ display: flex;
27
+ flex-direction: column;
28
+ color: var(--content);
29
+ background-color: var(--canvas);
30
+ gap: 16px;
31
+ }
32
+
33
+ .luna-gradient-berry {
34
+ background: linear-gradient(
35
+ 0deg,
36
+ var(--gradient-b),
37
+ var(--gradient-c)
38
+ );
39
+ }
40
+
41
+ /* =========================
42
+ * Form & Typography
43
+ * ========================= */
44
+
45
+ .form-container {
46
+ width: 100%;
47
+ display: flex;
48
+ flex-direction: column;
49
+ }
50
+
51
+ .form-title {
52
+ font-size: 20px;
53
+ font-weight: 700;
54
+ color: var(--content);
55
+ margin-bottom: 6px;
56
+ }
57
+
58
+ .form-subtitle {
59
+ font-size: 14px;
60
+ color: var(--content-muted);
61
+ }
62
+
63
+ .form-divider {
64
+ width: 100%;
65
+ height: 1px;
66
+ background-color: var(--line);
67
+ margin: 16px 0;
68
+ }
69
+
70
+ /* =========================
71
+ * Solid blocks
72
+ * ========================= */
73
+
74
+ .block {
75
+ width: 100%;
76
+ height: 84px;
77
+ border-radius: 14px;
78
+ margin-top: 12px;
79
+ margin-bottom: 12px;
80
+ background: linear-gradient(
81
+ 150deg,
82
+ var(--primary) 8.42%,
83
+ var(--primary-2) 81.71%
84
+ );
85
+ }
86
+
87
+ /* =========================
88
+ * Card
89
+ * ========================= */
90
+
91
+ .form-card {
92
+ width: 100%;
93
+ padding: 14px;
94
+ border-radius: 12px;
95
+ border-width: 1px;
96
+ border-style: solid;
97
+ border-color: var(--line);
98
+ display: flex;
99
+ flex-direction: column;
100
+ gap: 8px;
101
+ }
102
+
103
+ .form-label {
104
+ font-size: 14px;
105
+ font-weight: 600;
106
+ color: var(--content-2);
107
+ }
108
+
109
+ /* =========================
110
+ * Inputs (match Form/Basic)
111
+ * ========================= */
112
+
113
+ .input-container {
114
+ width: 100%;
115
+ border-radius: 12px;
116
+ background-color: var(--canvas);
117
+ border-width: 1px;
118
+ border-style: solid;
119
+ border-color: var(--line);
120
+ }
121
+
122
+ .form-input {
123
+ width: 100%;
124
+ font-size: 14px;
125
+ padding: 12px;
126
+ color: var(--content);
127
+ caret-color: var(--primary);
128
+ }
129
+
130
+ .form-input::placeholder {
131
+ color: var(--content-faint);
132
+ }
133
+
134
+ /* =========================
135
+ * TextArea
136
+ * ========================= */
137
+
138
+ .form-textarea-wrap {
139
+ width: 100%;
140
+ padding: 12px;
141
+ border-radius: 12px;
142
+ background-color: var(--canvas);
143
+ border-width: 1px;
144
+ border-style: solid;
145
+ border-color: var(--line);
146
+ }
147
+
148
+ .form-textarea {
149
+ height: 160px;
150
+ width: 100%;
151
+ color: var(--content);
152
+ caret-color: var(--primary);
153
+ }
154
+
155
+ .form-textarea::placeholder {
156
+ color: var(--content-faint);
157
+ }
158
+
159
+ /* =========================
160
+ * Submit + Values
161
+ * ========================= */
162
+
163
+ .submit-button {
164
+ width: 100%;
165
+ height: 48px;
166
+ border-radius: 9999px;
167
+ background-color: var(--primary);
168
+ display: flex;
169
+ justify-content: center;
170
+ align-items: center;
171
+ margin: 12px 0;
172
+ }
173
+
174
+ .submit-button.ui-active {
175
+ background-color: var(--primary-2);
176
+ }
177
+
178
+ .submit-button-text {
179
+ font-size: 14px;
180
+ color: var(--primary-content);
181
+ }
182
+
183
+ .form-values-display {
184
+ margin-top: 8px;
185
+ padding: 12px;
186
+ border-radius: 12px;
187
+ background-color: var(--canvas);
188
+ border-width: 1px;
189
+ border-style: dashed;
190
+ border-color: var(--line);
191
+
192
+ opacity: 0.9;
193
+ }
194
+
195
+ .form-values-text {
196
+ font-family: monospace;
197
+ font-size: 12px;
198
+ color: var(--content);
199
+ white-space: pre-wrap;
200
+ word-break: break-all;
201
+ }
202
+
203
+ .bottom-spacer {
204
+ height: 24px;
205
+ }