nitro-web 0.0.137 → 0.0.139
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/components/auth/reset.tsx +6 -5
- package/components/auth/signin.tsx +4 -3
- package/components/auth/signup.tsx +6 -5
- package/components/partials/styleguide.tsx +400 -338
- package/package.json +1 -1
- package/types/util.d.ts +18 -15
- package/types/util.d.ts.map +1 -1
- package/util.js +35 -33
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Topbar, Field, FormError, Button, request, onChange } from 'nitro-web'
|
|
2
2
|
import { Errors } from 'nitro-web/types'
|
|
3
|
+
import { Fragment } from 'react'
|
|
3
4
|
|
|
4
5
|
type resetInstructionsProps = {
|
|
5
6
|
className?: string,
|
|
@@ -29,12 +30,12 @@ export function ResetInstructions({ className, elements, redirectTo }: resetInst
|
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<div className={className}>
|
|
32
|
-
<Topbar title={
|
|
33
|
+
<Topbar title={<Fragment>Reset your Password</Fragment>} />
|
|
33
34
|
|
|
34
35
|
<form onSubmit={onSubmit} class="mb-0">
|
|
35
36
|
<div>
|
|
36
37
|
<label for="email">Email Address</label>
|
|
37
|
-
<Field name="email" type="email" state={state} onChange={(e) => onChange(
|
|
38
|
+
<Field name="email" type="email" state={state} onChange={(e) => onChange(e, setState)} placeholder="Your email address..." />
|
|
38
39
|
</div>
|
|
39
40
|
|
|
40
41
|
<div class="mb-14">
|
|
@@ -76,16 +77,16 @@ export function ResetPassword({ className, elements, redirectTo }: resetInstruct
|
|
|
76
77
|
|
|
77
78
|
return (
|
|
78
79
|
<div className={className}>
|
|
79
|
-
<Topbar title={
|
|
80
|
+
<Topbar title={<Fragment>Reset your Password</Fragment>} />
|
|
80
81
|
|
|
81
82
|
<form onSubmit={onSubmit} class="mb-0">
|
|
82
83
|
<div>
|
|
83
84
|
<label for="password">Your New Password</label>
|
|
84
|
-
<Field name="password" type="password" state={state} onChange={(e) => onChange(
|
|
85
|
+
<Field name="password" type="password" state={state} onChange={(e) => onChange(e, setState)} />
|
|
85
86
|
</div>
|
|
86
87
|
<div>
|
|
87
88
|
<label for="password2">Repeat Your New Password</label>
|
|
88
|
-
<Field name="password2" type="password" state={state} onChange={(e) => onChange(
|
|
89
|
+
<Field name="password2" type="password" state={state} onChange={(e) => onChange(e, setState)} />
|
|
89
90
|
</div>
|
|
90
91
|
|
|
91
92
|
<div class="mb-14">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Topbar, Field, Button, FormError, request, queryObject, injectedConfig, updateJwt, onChange } from 'nitro-web'
|
|
2
2
|
import { Errors } from 'nitro-web/types'
|
|
3
|
+
import { Fragment } from 'react'
|
|
3
4
|
|
|
4
5
|
type signinProps = {
|
|
5
6
|
className?: string,
|
|
@@ -58,12 +59,12 @@ export function Signin({ className, elements, redirectTo }: signinProps) {
|
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
61
|
<div className={className}>
|
|
61
|
-
<Topbar title={
|
|
62
|
+
<Topbar title={<Fragment>Sign in to your Account</Fragment>} />
|
|
62
63
|
|
|
63
64
|
<form onSubmit={onSubmit} class="mb-0">
|
|
64
65
|
<div>
|
|
65
66
|
<label for="email">Email Address</label>
|
|
66
|
-
<Field name="email" type="email" state={state} onChange={(e) => onChange(
|
|
67
|
+
<Field name="email" type="email" state={state} onChange={(e) => onChange(e, setState)}
|
|
67
68
|
placeholder="Your email address..." />
|
|
68
69
|
</div>
|
|
69
70
|
<div>
|
|
@@ -71,7 +72,7 @@ export function Signin({ className, elements, redirectTo }: signinProps) {
|
|
|
71
72
|
<label for="password">Password</label>
|
|
72
73
|
<Link to="/reset" class="label underline2">Forgot?</Link>
|
|
73
74
|
</div>
|
|
74
|
-
<Field name="password" type="password" state={state} onChange={(e) => onChange(
|
|
75
|
+
<Field name="password" type="password" state={state} onChange={(e) => onChange(e, setState)}/>
|
|
75
76
|
</div>
|
|
76
77
|
|
|
77
78
|
<div class="mb-14">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Button, Field, FormError, Topbar, request, injectedConfig, onChange } from 'nitro-web'
|
|
2
2
|
import { Errors } from 'nitro-web/types'
|
|
3
|
+
import { Fragment } from 'react'
|
|
3
4
|
|
|
4
5
|
type signupProps = {
|
|
5
6
|
className?: string,
|
|
@@ -35,29 +36,29 @@ export function Signup({ className, elements, redirectTo }: signupProps) {
|
|
|
35
36
|
|
|
36
37
|
return (
|
|
37
38
|
<div className={className}>
|
|
38
|
-
<Topbar title={
|
|
39
|
+
<Topbar title={<Fragment>Start your 21 day Free Trial</Fragment>} />
|
|
39
40
|
|
|
40
41
|
<form onSubmit={onSubmit} class="mb-0">
|
|
41
42
|
<div class="grid grid-cols-2 gap-6">
|
|
42
43
|
<div>
|
|
43
44
|
<label for="name">Your Name</label>
|
|
44
45
|
<Field name="name" placeholder="E.g. Bruce Wayne" state={state}
|
|
45
|
-
onChange={(e) => onChange(
|
|
46
|
+
onChange={(e) => onChange(e, setState)}
|
|
46
47
|
errorTitle={/^(name|firstName|lastName)$/} // if different from `name`
|
|
47
48
|
/>
|
|
48
49
|
</div>
|
|
49
50
|
<div>
|
|
50
51
|
<label for="business.name">Company Name</label>
|
|
51
|
-
<Field name="business.name" placeholder="E.g. Wayne Enterprises" state={state} onChange={(e) => onChange(
|
|
52
|
+
<Field name="business.name" placeholder="E.g. Wayne Enterprises" state={state} onChange={(e) => onChange(e, setState)} />
|
|
52
53
|
</div>
|
|
53
54
|
</div>
|
|
54
55
|
<div>
|
|
55
56
|
<label for="email">Email Address</label>
|
|
56
|
-
<Field name="email" type="email" state={state} onChange={(e) => onChange(
|
|
57
|
+
<Field name="email" type="email" state={state} onChange={(e) => onChange(e, setState)} placeholder="Your email address..." />
|
|
57
58
|
</div>
|
|
58
59
|
<div>
|
|
59
60
|
<label for="password">Password</label>
|
|
60
|
-
<Field name="password" type="password" state={state} onChange={(e) => onChange(
|
|
61
|
+
<Field name="password" type="password" state={state} onChange={(e) => onChange(e, setState)}/>
|
|
61
62
|
</div>
|
|
62
63
|
|
|
63
64
|
<div class="mb-14">
|
|
@@ -35,6 +35,21 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
35
35
|
const [, setStore] = useTracked()
|
|
36
36
|
const [customerSearch, setCustomerSearch] = useState('')
|
|
37
37
|
const [showModal1, setShowModal1] = useState(false)
|
|
38
|
+
// Tip: handy when developing or updating components, you can hide/show the groups you want to see
|
|
39
|
+
const groups = [
|
|
40
|
+
'Links',
|
|
41
|
+
'Dropdowns',
|
|
42
|
+
'Filters',
|
|
43
|
+
'Buttons',
|
|
44
|
+
'Varients',
|
|
45
|
+
'Selects',
|
|
46
|
+
'Inputs',
|
|
47
|
+
'Date Inputs',
|
|
48
|
+
'File Inputs & Calendar',
|
|
49
|
+
'Tables',
|
|
50
|
+
'Modals',
|
|
51
|
+
'Custom Components',
|
|
52
|
+
]
|
|
38
53
|
const [state, setState] = useState({
|
|
39
54
|
address: '',
|
|
40
55
|
amount: 100,
|
|
@@ -130,7 +145,7 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
130
145
|
e.target.value = null // clear the select's selected value
|
|
131
146
|
setTimeout(() => alert('Adding new customer...'), 0)
|
|
132
147
|
}
|
|
133
|
-
onChange(
|
|
148
|
+
onChange(e, setState)
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
const onCustomerSearch = (search: string) => {
|
|
@@ -180,378 +195,425 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
180
195
|
// }, [])
|
|
181
196
|
|
|
182
197
|
return (
|
|
183
|
-
<div class={`text-left max-w-[1100px] ${className}`}>
|
|
184
|
-
<
|
|
185
|
-
<h3 class="h3">Edit Profile</h3>
|
|
186
|
-
<p class="mb-5">An example modal containing a basic form for editing profiles.</p>
|
|
187
|
-
<form class="mb-8 text-left">
|
|
188
|
-
<div>
|
|
189
|
-
<label for="firstName2">First Name</label>
|
|
190
|
-
<Field name="firstName2" state={state} onChange={(e) => onChange(setState, e)} />
|
|
191
|
-
</div>
|
|
192
|
-
<div>
|
|
193
|
-
<label for="email2">Email Address</label>
|
|
194
|
-
<Field name="email2" type="email" placeholder="Your email address..."/>
|
|
195
|
-
</div>
|
|
196
|
-
</form>
|
|
197
|
-
<div class="flex justify-end">
|
|
198
|
-
<Button color="primary" onClick={() => setShowModal1(false)}>Save</Button>
|
|
199
|
-
</div>
|
|
200
|
-
</Modal>
|
|
201
|
-
|
|
202
|
-
<GithubLink filename={__filename} />
|
|
203
|
-
<div class="mb-7">
|
|
198
|
+
<div class={`text-left max-w-[1100px] flex flex-col gap-4 pb-2 ${className}`}>
|
|
199
|
+
<div>
|
|
204
200
|
<h1 class="h1">{injectedConfig.isDemo ? 'Design System' : 'Style Guide'}</h1>
|
|
205
|
-
<p>
|
|
201
|
+
<p class="mb-3">
|
|
206
202
|
Components are styled using
|
|
207
203
|
<a href="https://v3.tailwindcss.com/docs/configuration" class="underline" target="_blank" rel="noreferrer">TailwindCSS</a>.
|
|
208
204
|
</p>
|
|
209
205
|
</div>
|
|
210
206
|
|
|
211
|
-
|
|
212
|
-
<div class="mb-10">
|
|
213
|
-
<a class="mr-2" href="#">Default</a>
|
|
214
|
-
<a class="underline1 is-active mr-2" href="#">Underline1</a>
|
|
215
|
-
<a class="underline2 is-active mr-2" href="#">Underline2</a>
|
|
216
|
-
</div>
|
|
217
|
-
|
|
218
|
-
<h2 class="h3">Modals</h2>
|
|
219
|
-
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
|
|
220
|
-
<div><Button color="primary" onClick={() => setShowModal1(true)}>Modal (default)</Button></div>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<h2 class="h3">Dropdowns</h2>
|
|
224
|
-
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
|
|
207
|
+
{groups.includes('Links') && (
|
|
225
208
|
<div>
|
|
226
|
-
<
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// menuIsOpen={true}
|
|
233
|
-
dir="bottom-right"
|
|
234
|
-
minWidth="330px"
|
|
235
|
-
options={[{ label: <><b>New Customer</b> / Add <b>Bruce Lee</b></>, className: 'border-bottom-with-space' }, ...options]}
|
|
236
|
-
>
|
|
237
|
-
<Button color="white" IconRight="v" class="gap-x-3">Dropdown bottom-right</Button>
|
|
238
|
-
</Dropdown>
|
|
209
|
+
<h2 class="h3">Links</h2>
|
|
210
|
+
<div class="mb-6">
|
|
211
|
+
<a class="mr-2" href="#">Default</a>
|
|
212
|
+
<a class="underline1 is-active mr-2" href="#">Underline1</a>
|
|
213
|
+
<a class="underline2 is-active mr-2" href="#">Underline2</a>
|
|
214
|
+
</div>
|
|
239
215
|
</div>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{groups.includes('Dropdowns') && (
|
|
240
219
|
<div>
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
220
|
+
<h2 class="h3">Dropdowns</h2>
|
|
221
|
+
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-6">
|
|
222
|
+
<div>
|
|
223
|
+
<Dropdown options={options} minWidth="250px">
|
|
224
|
+
<Button IconRight="v" class="gap-x-3">Dropdown</Button>
|
|
225
|
+
</Dropdown>
|
|
226
|
+
</div>
|
|
227
|
+
<div>
|
|
228
|
+
<Dropdown
|
|
229
|
+
// menuIsOpen={true}
|
|
230
|
+
dir="bottom-right"
|
|
231
|
+
minWidth="330px"
|
|
232
|
+
options={[{ label: <><b>New Customer</b> / Add <b>Bruce Lee</b></>, className: 'border-bottom-with-space' }, ...options]}
|
|
233
|
+
>
|
|
234
|
+
<Button color="white" IconRight="v" class="gap-x-3">Dropdown bottom-right</Button>
|
|
235
|
+
</Dropdown>
|
|
236
|
+
</div>
|
|
237
|
+
<div>
|
|
238
|
+
<Dropdown options={options} dir="top-left" minWidth="250px">
|
|
239
|
+
<Button color="white" IconRight="v" class="gap-x-3">Dropdown top-left</Button>
|
|
240
|
+
</Dropdown>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
244
243
|
</div>
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<h2 class="h3">Filters</h2>
|
|
248
|
-
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
|
|
249
|
-
{/* Filter dropdown */}
|
|
250
|
-
<Filters
|
|
251
|
-
ref={filtersRef}
|
|
252
|
-
filters={filters}
|
|
253
|
-
state={filterState}
|
|
254
|
-
setState={setFilterState}
|
|
255
|
-
dropdownProps={{ dir: 'bottom-left' }}
|
|
256
|
-
elements={{ Button: Button }}
|
|
257
|
-
/>
|
|
258
|
-
{/* Search bar */}
|
|
259
|
-
<Field
|
|
260
|
-
class="!my-0 min-w-[242px]"
|
|
261
|
-
type="search"
|
|
262
|
-
name="search"
|
|
263
|
-
id="search2"
|
|
264
|
-
iconPos="left"
|
|
265
|
-
state={filterState}
|
|
266
|
-
onChange={(e) => {
|
|
267
|
-
onChange(setFilterState, e)
|
|
268
|
-
filtersRef.current?.submit()
|
|
269
|
-
}}
|
|
270
|
-
placeholder="Linked search bar..."
|
|
271
|
-
/>
|
|
272
|
-
</div>
|
|
273
|
-
|
|
274
|
-
<h2 class="h3">Buttons</h2>
|
|
275
|
-
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
|
|
276
|
-
<div><Button color="primary">primary (default)</Button></div>
|
|
277
|
-
<div><Button color="secondary">secondary button</Button></div>
|
|
278
|
-
<div><Button color="black">black button</Button></div>
|
|
279
|
-
<div><Button color="dark">dark button</Button></div>
|
|
280
|
-
<div><Button color="white">white button</Button></div>
|
|
281
|
-
<div><Button color="clear">clear button</Button></div>
|
|
282
|
-
<div><Button color="primary" size="xs">*-xs button</Button></div>
|
|
283
|
-
<div><Button color="primary" size="sm">*-sm button</Button></div>
|
|
284
|
-
<div><Button color="primary">*-md (default)</Button></div>
|
|
285
|
-
<div><Button color="primary" size="lg">*-lg button</Button></div>
|
|
286
|
-
<div><Button IconLeft={<Check size={19} className="-my-5" />}>IconLeft</Button></div>
|
|
287
|
-
<div><Button IconLeft={<Check size={19} className="-my-5" />}
|
|
288
|
-
className="w-[160px]">IconLeft 160px</Button></div>
|
|
289
|
-
<div><Button IconLeftEnd={<Check size={19} className="-my-5" />}
|
|
290
|
-
className="w-[190px]">IconLeftEnd 190px</Button></div>
|
|
291
|
-
<div><Button IconRight="v">IconRight</Button></div>
|
|
292
|
-
<div><Button IconRightEnd="v" className="w-[190px]">IconRightEnd 190px</Button></div>
|
|
293
|
-
<div><Button color="primary" IconRight="v" isLoading>primary isLoading</Button></div>
|
|
294
|
-
<div><Button IconCenter={<FileEditIcon size={18}/>}></Button></div>
|
|
295
|
-
<div><Button size="sm" IconCenter={<FileEditIcon size={16}/>}></Button></div>
|
|
296
|
-
<div><Button size="xs" IconCenter={<FileEditIcon size={14}/>}></Button></div>
|
|
297
|
-
</div>
|
|
244
|
+
)}
|
|
298
245
|
|
|
299
|
-
|
|
300
|
-
<div class="grid grid-cols-3 gap-x-6 mb-4">
|
|
246
|
+
{groups.includes('Filters') && (
|
|
301
247
|
<div>
|
|
302
|
-
<
|
|
303
|
-
<
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
248
|
+
<h2 class="h3">Filters</h2>
|
|
249
|
+
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-6">
|
|
250
|
+
{/* Filter dropdown */}
|
|
251
|
+
<Filters
|
|
252
|
+
ref={filtersRef}
|
|
253
|
+
filters={filters}
|
|
254
|
+
state={filterState}
|
|
255
|
+
setState={setFilterState}
|
|
256
|
+
dropdownProps={{ dir: 'bottom-left' }}
|
|
257
|
+
elements={{ Button: Button }}
|
|
258
|
+
/>
|
|
259
|
+
{/* Search bar */}
|
|
260
|
+
<Field
|
|
261
|
+
class="!my-0 min-w-[242px]"
|
|
262
|
+
type="search"
|
|
263
|
+
name="search"
|
|
264
|
+
id="search2"
|
|
265
|
+
iconPos="left"
|
|
266
|
+
state={filterState}
|
|
267
|
+
onChange={(e) => {
|
|
268
|
+
onChange(e, setFilterState)
|
|
269
|
+
filtersRef.current?.submit()
|
|
270
|
+
}}
|
|
271
|
+
placeholder="Linked search bar..."
|
|
272
|
+
/>
|
|
273
|
+
</div>
|
|
318
274
|
</div>
|
|
319
|
-
|
|
275
|
+
)}
|
|
320
276
|
|
|
321
|
-
|
|
322
|
-
<div class="grid grid-cols-3 lg:grid-cols-3 gap-x-6 mb-4">
|
|
323
|
-
<div>
|
|
324
|
-
<label for="action">Default</label>
|
|
325
|
-
<Select
|
|
326
|
-
// menuIsOpen={true}
|
|
327
|
-
name="action"
|
|
328
|
-
isSearchable={false}
|
|
329
|
-
options={useMemo(() => [
|
|
330
|
-
{ value: 'edit', label: 'Edit' },
|
|
331
|
-
{ value: 'delete', label: 'Delete' },
|
|
332
|
-
], [])}
|
|
333
|
-
/>
|
|
334
|
-
</div>
|
|
335
|
-
<div>
|
|
336
|
-
<label for="colorsMulti">Mutli Select</label>
|
|
337
|
-
<Select
|
|
338
|
-
name="colorsMulti"
|
|
339
|
-
isMulti={true}
|
|
340
|
-
state={state}
|
|
341
|
-
options={useMemo(() => [
|
|
342
|
-
{ value: 'blue', label: 'Blue' },
|
|
343
|
-
{ value: 'green', label: 'Green' },
|
|
344
|
-
{ value: 'yellow', label: 'Yellow' },
|
|
345
|
-
{ value: 'red', label: 'Red' },
|
|
346
|
-
{ value: 'orange', label: 'Orange' },
|
|
347
|
-
{ value: 'purple', label: 'Purple' },
|
|
348
|
-
{ value: 'pink', label: 'Pink' },
|
|
349
|
-
{ value: 'gray', label: 'Gray' },
|
|
350
|
-
{ value: 'black', label: 'Black' },
|
|
351
|
-
{ value: 'white', label: 'White' },
|
|
352
|
-
], [])}
|
|
353
|
-
onChange={(e) => onChange(setState, e)}
|
|
354
|
-
/>
|
|
355
|
-
</div>
|
|
277
|
+
{groups.includes('Buttons') && (
|
|
356
278
|
<div>
|
|
357
|
-
<
|
|
358
|
-
<
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
value: '0',
|
|
382
|
-
label: (
|
|
383
|
-
<>
|
|
384
|
-
<b>New Customer</b> (and clear select)
|
|
385
|
-
{customerSearch ? <> / Add <b>{ucFirst(customerSearch)}</b></> : ''}
|
|
386
|
-
</>
|
|
387
|
-
),
|
|
388
|
-
},
|
|
389
|
-
{ value: '1', label: 'Iron Man Industries' },
|
|
390
|
-
{ value: '2', label: 'Captain America' },
|
|
391
|
-
{ value: '3', label: 'Thor Limited' },
|
|
392
|
-
], [customerSearch])}
|
|
393
|
-
/>
|
|
394
|
-
</div>
|
|
395
|
-
<div>
|
|
396
|
-
<label for="currency">Currencies</label>
|
|
397
|
-
<Select
|
|
398
|
-
name="currency"
|
|
399
|
-
state={state}
|
|
400
|
-
options={useMemo(() => (currencies ? getCurrencyOptions(currencies) : [{ value: 'nzd', label: 'New Zealand Dollar' }, { value: 'aud', label: 'Australian Dollar' }]), [])}
|
|
401
|
-
onChange={(e) => onChange(setState, e)}
|
|
402
|
-
/>
|
|
279
|
+
<h2 class="h3">Buttons</h2>
|
|
280
|
+
<div class="flex flex-wrap gap-x-6 gap-y-4 mb-6">
|
|
281
|
+
<div><Button color="primary">primary (default)</Button></div>
|
|
282
|
+
<div><Button color="secondary">secondary button</Button></div>
|
|
283
|
+
<div><Button color="black">black button</Button></div>
|
|
284
|
+
<div><Button color="dark">dark button</Button></div>
|
|
285
|
+
<div><Button color="white">white button</Button></div>
|
|
286
|
+
<div><Button color="clear">clear button</Button></div>
|
|
287
|
+
<div><Button color="primary" size="xs">*-xs button</Button></div>
|
|
288
|
+
<div><Button color="primary" size="sm">*-sm button</Button></div>
|
|
289
|
+
<div><Button color="primary">*-md (default)</Button></div>
|
|
290
|
+
<div><Button color="primary" size="lg">*-lg button</Button></div>
|
|
291
|
+
<div><Button IconLeft={<Check size={19} className="-my-5" />}>IconLeft</Button></div>
|
|
292
|
+
<div><Button IconLeft={<Check size={19} className="-my-5" />}
|
|
293
|
+
className="w-[160px]">IconLeft 160px</Button></div>
|
|
294
|
+
<div><Button IconLeftEnd={<Check size={19} className="-my-5" />}
|
|
295
|
+
className="w-[190px]">IconLeftEnd 190px</Button></div>
|
|
296
|
+
<div><Button IconRight="v">IconRight</Button></div>
|
|
297
|
+
<div><Button IconRightEnd="v" className="w-[190px]">IconRightEnd 190px</Button></div>
|
|
298
|
+
<div><Button color="primary" IconRight="v" isLoading>primary isLoading</Button></div>
|
|
299
|
+
<div><Button IconCenter={<FileEditIcon size={18}/>}></Button></div>
|
|
300
|
+
<div><Button size="sm" IconCenter={<FileEditIcon size={16}/>}></Button></div>
|
|
301
|
+
<div><Button size="xs" IconCenter={<FileEditIcon size={14}/>}></Button></div>
|
|
302
|
+
</div>
|
|
403
303
|
</div>
|
|
404
|
-
|
|
304
|
+
)}
|
|
405
305
|
|
|
406
|
-
|
|
407
|
-
<div class="grid grid-cols-3 gap-x-6 mb-4">
|
|
408
|
-
<div>
|
|
409
|
-
<label for="firstName">First Name</label>
|
|
410
|
-
<Field name="firstName" state={state} onChange={(e) => onChange(setState, e)} />
|
|
411
|
-
</div>
|
|
412
|
-
<div>
|
|
413
|
-
<label for="email">Email Address</label>
|
|
414
|
-
<Field name="email" type="email" placeholder="Your email address..."/>
|
|
415
|
-
</div>
|
|
306
|
+
{groups.includes('Varients') && (
|
|
416
307
|
<div>
|
|
417
|
-
<
|
|
418
|
-
|
|
419
|
-
<
|
|
308
|
+
<h2 class="h3">Varients</h2>
|
|
309
|
+
<div class="grid grid-cols-3 gap-x-6">
|
|
310
|
+
<div>
|
|
311
|
+
<label for="input2">Toggles</label>
|
|
312
|
+
<Checkbox name="input2" type="toggle" text="Toggle sm" subtext="some additional text here." class="!mb-0"
|
|
313
|
+
state={state} onChange={(e) => onChange(e, setState)} />
|
|
314
|
+
<Checkbox name="input3" type="toggle" text="Toggle 22px" subtext="some additional text here." size={22} />
|
|
315
|
+
</div>
|
|
316
|
+
<div>
|
|
317
|
+
<label for="input1">Radios</label>
|
|
318
|
+
<Checkbox name="input1" type="radio" text="Radio" subtext="some additional text here 1." id="input1-1" class="!mb-0"
|
|
319
|
+
defaultChecked />
|
|
320
|
+
<Checkbox name="input1" type="radio" text="Radio 16px" subtext="some additional text here 2." id="input1-2" size={16} />
|
|
321
|
+
</div>
|
|
322
|
+
<div>
|
|
323
|
+
<label for="input0">Checkboxes</label>
|
|
324
|
+
<Checkbox name="input0" type="checkbox" text="Checkbox" subtext="some additional text here." class="!mb-0" defaultChecked />
|
|
325
|
+
<Checkbox name="input0.1" type="checkbox" text="Checkbox 16px" size={16}
|
|
326
|
+
subtext="some additional text here which is a bit longer that will be line-wrap to the next line." />
|
|
327
|
+
</div>
|
|
420
328
|
</div>
|
|
421
|
-
<Field name="password" type="password"/>
|
|
422
|
-
</div>
|
|
423
|
-
<div>
|
|
424
|
-
<label for="search3number">Number</label>
|
|
425
|
-
<Field name="number" id="search3number" type="number" placeholder="Number..." />
|
|
426
|
-
</div>
|
|
427
|
-
<div>
|
|
428
|
-
<label for="search3">Search</label>
|
|
429
|
-
<Field name="search" id="search3" type="search" placeholder="Search..." />
|
|
430
|
-
</div>
|
|
431
|
-
<div>
|
|
432
|
-
<label for="filter">Filter by Code</label>
|
|
433
|
-
<Field name="filter" type="filter" iconPos="left" />
|
|
434
|
-
</div>
|
|
435
|
-
<div>
|
|
436
|
-
<label for="address">Input Error</label>
|
|
437
|
-
<Field name="address" placeholder="Address..." state={state} onChange={(e) => onChange(setState, e)} />
|
|
438
329
|
</div>
|
|
439
|
-
|
|
440
|
-
<label for="description">Description</label>
|
|
441
|
-
<Field name="description" type="textarea" rows={2} />
|
|
442
|
-
</div>
|
|
443
|
-
<div>
|
|
444
|
-
<label for="brandColor">Brand Color</label>
|
|
445
|
-
<Field name="brandColor" type="color" iconPos="left" state={state} onChange={(e) => onChange(setState, e)} />
|
|
446
|
-
</div>
|
|
447
|
-
<div>
|
|
448
|
-
<label for="amount">Amount ({state.amount})</label>
|
|
449
|
-
<Field
|
|
450
|
-
name="amount" type="currency" state={state} currency={state.currency || 'nzd'} onChange={(e) => onChange(setState, e)}
|
|
451
|
-
// Example of using a custom format and currencies, e.g.
|
|
452
|
-
format={'¤#,##0.00'}
|
|
453
|
-
currencies={currencies}
|
|
454
|
-
/>
|
|
455
|
-
</div>
|
|
456
|
-
</div>
|
|
330
|
+
)}
|
|
457
331
|
|
|
458
|
-
|
|
459
|
-
<div class="grid grid-cols-1 gap-x-6 mb-4 sm:grid-cols-3">
|
|
332
|
+
{groups.includes('Selects') && (
|
|
460
333
|
<div>
|
|
461
|
-
<
|
|
462
|
-
<
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
334
|
+
<h2 class="h3">Selects</h2>
|
|
335
|
+
<div class="grid grid-cols-3 lg:grid-cols-3 gap-x-6">
|
|
336
|
+
<div>
|
|
337
|
+
<label for="action">Default</label>
|
|
338
|
+
<Select
|
|
339
|
+
// menuIsOpen={true}
|
|
340
|
+
name="action"
|
|
341
|
+
isSearchable={false}
|
|
342
|
+
options={useMemo(() => [
|
|
343
|
+
{ value: 'edit', label: 'Edit' },
|
|
344
|
+
{ value: 'delete', label: 'Delete' },
|
|
345
|
+
], [])}
|
|
346
|
+
/>
|
|
347
|
+
</div>
|
|
348
|
+
<div>
|
|
349
|
+
<label for="colorsMulti">Mutli Select</label>
|
|
350
|
+
<Select
|
|
351
|
+
name="colorsMulti"
|
|
352
|
+
isMulti={true}
|
|
353
|
+
state={state}
|
|
354
|
+
options={useMemo(() => [
|
|
355
|
+
{ value: 'blue', label: 'Blue' },
|
|
356
|
+
{ value: 'green', label: 'Green' },
|
|
357
|
+
{ value: 'yellow', label: 'Yellow' },
|
|
358
|
+
{ value: 'red', label: 'Red' },
|
|
359
|
+
{ value: 'orange', label: 'Orange' },
|
|
360
|
+
{ value: 'purple', label: 'Purple' },
|
|
361
|
+
{ value: 'pink', label: 'Pink' },
|
|
362
|
+
{ value: 'gray', label: 'Gray' },
|
|
363
|
+
{ value: 'black', label: 'Black' },
|
|
364
|
+
{ value: 'white', label: 'White' },
|
|
365
|
+
], [])}
|
|
366
|
+
onChange={(e) => onChange(e, setState)}
|
|
367
|
+
/>
|
|
368
|
+
</div>
|
|
369
|
+
<div>
|
|
370
|
+
<label for="country">Countries</label>
|
|
371
|
+
<Select
|
|
372
|
+
// https://github.com/lipis/flag-icons
|
|
373
|
+
name="country"
|
|
374
|
+
mode="country"
|
|
375
|
+
state={state}
|
|
376
|
+
options={useMemo(() => [{ value: 'nz', label: 'New Zealand' }, { value: 'au', label: 'Australia' }], [])}
|
|
377
|
+
onChange={(e) => onChange(e, setState)}
|
|
378
|
+
/>
|
|
379
|
+
</div>
|
|
380
|
+
<div>
|
|
381
|
+
<label for="customer">List Item with Action</label>
|
|
382
|
+
<Select
|
|
383
|
+
// menuIsOpen={true}
|
|
384
|
+
placeholder="Select or add customer..."
|
|
385
|
+
name="customer"
|
|
386
|
+
mode="customer"
|
|
387
|
+
state={state}
|
|
388
|
+
onChange={onCustomerInputChange}
|
|
389
|
+
onInputChange={onCustomerSearch}
|
|
390
|
+
options={useMemo(() => [
|
|
391
|
+
{
|
|
392
|
+
className: 'bb',
|
|
393
|
+
fixed: true,
|
|
394
|
+
value: '0',
|
|
395
|
+
label: (
|
|
396
|
+
<>
|
|
397
|
+
<b>New Customer</b> (and clear select)
|
|
398
|
+
{customerSearch ? <> / Add <b>{ucFirst(customerSearch)}</b></> : ''}
|
|
399
|
+
</>
|
|
400
|
+
),
|
|
401
|
+
},
|
|
402
|
+
{ value: '1', label: 'Iron Man Industries' },
|
|
403
|
+
{ value: '2', label: 'Captain America' },
|
|
404
|
+
{ value: '3', label: 'Thor Limited' },
|
|
405
|
+
], [customerSearch])}
|
|
406
|
+
/>
|
|
407
|
+
</div>
|
|
408
|
+
<div>
|
|
409
|
+
<label for="currency">Currencies</label>
|
|
410
|
+
<Select
|
|
411
|
+
name="currency"
|
|
412
|
+
state={state}
|
|
413
|
+
options={useMemo(() => (currencies ? getCurrencyOptions(currencies) : [{ value: 'nzd', label: 'New Zealand Dollar' }, { value: 'aud', label: 'Australian Dollar' }]), [])}
|
|
414
|
+
onChange={(e) => onChange(e, setState)}
|
|
415
|
+
/>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
477
418
|
</div>
|
|
419
|
+
)}
|
|
420
|
+
|
|
421
|
+
{groups.includes('Inputs') && (
|
|
478
422
|
<div>
|
|
479
|
-
<
|
|
480
|
-
<
|
|
423
|
+
<h2 class="h3">Inputs</h2>
|
|
424
|
+
<div class="grid grid-cols-3 gap-x-6">
|
|
425
|
+
<div>
|
|
426
|
+
<label for="firstName">First Name</label>
|
|
427
|
+
<Field name="firstName" state={state} onChange={(e) => onChange(e, setState)} />
|
|
428
|
+
</div>
|
|
429
|
+
<div>
|
|
430
|
+
<label for="email">Email Address</label>
|
|
431
|
+
<Field name="email" type="email" placeholder="Your email address..."/>
|
|
432
|
+
</div>
|
|
433
|
+
<div>
|
|
434
|
+
<div class="flex justify-between">
|
|
435
|
+
<label for="password">Password</label>
|
|
436
|
+
<a href="#" class="label">Forgot?</a>
|
|
437
|
+
</div>
|
|
438
|
+
<Field name="password" type="password"/>
|
|
439
|
+
</div>
|
|
440
|
+
<div>
|
|
441
|
+
<label for="search3number">Number</label>
|
|
442
|
+
<Field name="number" id="search3number" type="number" placeholder="Number..." />
|
|
443
|
+
</div>
|
|
444
|
+
<div>
|
|
445
|
+
<label for="search3">Search</label>
|
|
446
|
+
<Field name="search" id="search3" type="search" placeholder="Search..." />
|
|
447
|
+
</div>
|
|
448
|
+
<div>
|
|
449
|
+
<label for="filter">Filter by Code</label>
|
|
450
|
+
<Field name="filter" type="filter" iconPos="left" />
|
|
451
|
+
</div>
|
|
452
|
+
<div>
|
|
453
|
+
<label for="address">Input Error</label>
|
|
454
|
+
<Field name="address" placeholder="Address..." state={state} onChange={(e) => onChange(e, setState)} />
|
|
455
|
+
</div>
|
|
456
|
+
<div>
|
|
457
|
+
<label for="description">Description</label>
|
|
458
|
+
<Field name="description" type="textarea" rows={2} />
|
|
459
|
+
</div>
|
|
460
|
+
<div>
|
|
461
|
+
<label for="brandColor">Brand Color</label>
|
|
462
|
+
<Field name="brandColor" type="color" iconPos="left" state={state} onChange={(e) => onChange(e, setState)} />
|
|
463
|
+
</div>
|
|
464
|
+
<div>
|
|
465
|
+
<label for="amount">Amount ({state.amount})</label>
|
|
466
|
+
<Field
|
|
467
|
+
name="amount" type="currency" state={state} currency={state.currency || 'nzd'} onChange={(e) => onChange(e, setState)}
|
|
468
|
+
// Example of using a custom format and currencies, e.g.
|
|
469
|
+
format={'¤#,##0.00'}
|
|
470
|
+
currencies={currencies}
|
|
471
|
+
/>
|
|
472
|
+
</div>
|
|
473
|
+
</div>
|
|
481
474
|
</div>
|
|
475
|
+
)}
|
|
476
|
+
|
|
477
|
+
{groups.includes('Date Inputs') && (
|
|
482
478
|
<div>
|
|
483
|
-
<
|
|
484
|
-
<
|
|
479
|
+
<h2 class="h3">Date Inputs</h2>
|
|
480
|
+
<div class="grid grid-cols-1 gap-x-6 sm:grid-cols-3">
|
|
481
|
+
<div>
|
|
482
|
+
<label for="date">Date with time</label>
|
|
483
|
+
<Field name="date-time" type="date" mode="single" showTime={true} state={state} onChange={(e) => onChange(e, setState)} />
|
|
484
|
+
</div>
|
|
485
|
+
<div>
|
|
486
|
+
<label for="date-range">Date range (with prefix & disabled days)</label>
|
|
487
|
+
<Field
|
|
488
|
+
name="date-range"
|
|
489
|
+
type="date"
|
|
490
|
+
mode="range"
|
|
491
|
+
prefix="Date:"
|
|
492
|
+
state={state}
|
|
493
|
+
onChange={(e) => onChange(e, setState)}
|
|
494
|
+
DayPickerProps={{
|
|
495
|
+
disabled: { after: new Date(Date.now() + 1000 * 60 * 60 * 24 * 45) }
|
|
496
|
+
}}
|
|
497
|
+
/>
|
|
498
|
+
</div>
|
|
499
|
+
<div>
|
|
500
|
+
<label for="date">Date multi-select (right aligned)</label>
|
|
501
|
+
<Field name="date" type="date" mode="multiple" state={state} onChange={(e) => onChange(e, setState)} dir="bottom-right" />
|
|
502
|
+
</div>
|
|
503
|
+
<div>
|
|
504
|
+
<label for="time">Time</label>
|
|
505
|
+
<Field name="time" type="time" state={state} onChange={(e) => onChange(e, setState)} />
|
|
506
|
+
</div>
|
|
507
|
+
</div>
|
|
485
508
|
</div>
|
|
486
|
-
|
|
509
|
+
)}
|
|
487
510
|
|
|
488
|
-
|
|
489
|
-
<div class="grid grid-cols-3 gap-x-6 mb-4">
|
|
511
|
+
{groups.includes('File Inputs & Calendar') && (
|
|
490
512
|
<div>
|
|
491
|
-
<
|
|
492
|
-
<
|
|
513
|
+
<h2 class="h3">File Inputs & Calendar</h2>
|
|
514
|
+
<div class="grid grid-cols-3 gap-x-6">
|
|
515
|
+
<div>
|
|
516
|
+
<label for="avatar">Avatar</label>
|
|
517
|
+
<Drop class="is-small" name="avatar" state={state} onChange={(e) => onChange(e, setState)} awsUrl={injectedConfig.awsUrl} />
|
|
518
|
+
</div>
|
|
519
|
+
<div>
|
|
520
|
+
<label for="calendar">Calendar</label>
|
|
521
|
+
<Calendar mode="range" value={state.calendar} numberOfMonths={1}
|
|
522
|
+
onChange={(value) => {
|
|
523
|
+
onChange({ target: { name: 'calendar', value: value } }, setState)
|
|
524
|
+
}}
|
|
525
|
+
/>
|
|
526
|
+
</div>
|
|
527
|
+
</div>
|
|
493
528
|
</div>
|
|
529
|
+
)}
|
|
530
|
+
|
|
531
|
+
{groups.includes('Tables') && (
|
|
494
532
|
<div>
|
|
495
|
-
<
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
533
|
+
<div class="flex justify-between items-start">
|
|
534
|
+
<h2 class="h3">Tables</h2>
|
|
535
|
+
<Field
|
|
536
|
+
name="tableFilter"
|
|
537
|
+
type="search"
|
|
538
|
+
state={state}
|
|
539
|
+
placeholder="Basic table filter..."
|
|
540
|
+
onChange={(e) => onChange(e, setState)}
|
|
541
|
+
className="!my-0 [&>input]:font-normal [&>input]:text-xs [&>input]:py-1.5" /////todo: need to allow twmerge here
|
|
542
|
+
/>
|
|
543
|
+
</div>
|
|
544
|
+
<Table
|
|
545
|
+
rows={rows.slice(0, perPage)}
|
|
546
|
+
columns={thead}
|
|
547
|
+
rowSideColor={(row) => ({ className: row?.status == 'pending' ? 'bg-yellow-400' : '', width: 5 })}
|
|
548
|
+
generateCheckboxActions={generateCheckboxActions}
|
|
549
|
+
generateTd={generateTd}
|
|
550
|
+
className="mb-6"
|
|
551
|
+
/>
|
|
552
|
+
<Table
|
|
553
|
+
rows={[]}
|
|
554
|
+
columns={thead}
|
|
555
|
+
rowSideColor={(row) => ({ className: row?.status == 'pending' ? 'bg-yellow-400' : '', width: 5 })}
|
|
556
|
+
generateCheckboxActions={generateCheckboxActions}
|
|
557
|
+
generateTd={generateTd}
|
|
558
|
+
className="mb-6"
|
|
559
|
+
isLoading={true}
|
|
560
|
+
/>
|
|
561
|
+
<Table
|
|
562
|
+
rows={rows.slice(0, 2).map(row => ({ ...row, _id: row._id + '1' }))}
|
|
563
|
+
columns={thead}
|
|
564
|
+
rowLinesMax={1}
|
|
565
|
+
headerHeightMin={35}
|
|
566
|
+
rowGap={8}
|
|
567
|
+
rowHeightMin={42}
|
|
568
|
+
rowSideColor={(row) => ({ className: `rounded-l-xl ${statusColors(row?.status as string)}`, width: 10 })}
|
|
569
|
+
rowOnClick={useCallback((row: QuoteExample) => {setStore((s) => ({ ...s, message: `Row ${row?._id} clicked` }))}, [setStore])}
|
|
570
|
+
generateCheckboxActions={generateCheckboxActions}
|
|
571
|
+
generateTd={generateTd}
|
|
572
|
+
className="mb-5"
|
|
573
|
+
tableClassName="rounded-3px"
|
|
574
|
+
rowClassName="[&:hover>div]:bg-gray-50"
|
|
575
|
+
columnClassName="border-t-1 first:rounded-l-xl last:rounded-r-xl"
|
|
576
|
+
columnSelectedClassName="bg-gray-50 border-indigo-300"
|
|
577
|
+
columnHeaderClassName="text-gray-500 text-2xs uppercase border-none"
|
|
578
|
+
checkboxClassName="rounded-[2px] shadow-none"
|
|
500
579
|
/>
|
|
501
580
|
</div>
|
|
502
|
-
|
|
581
|
+
)}
|
|
503
582
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
className="mb-6"
|
|
531
|
-
isLoading={true}
|
|
532
|
-
/>
|
|
533
|
-
<Table
|
|
534
|
-
rows={rows.slice(0, 2).map(row => ({ ...row, _id: row._id + '1' }))}
|
|
535
|
-
columns={thead}
|
|
536
|
-
rowLinesMax={1}
|
|
537
|
-
headerHeightMin={35}
|
|
538
|
-
rowGap={8}
|
|
539
|
-
rowHeightMin={42}
|
|
540
|
-
rowSideColor={(row) => ({ className: `rounded-l-xl ${statusColors(row?.status as string)}`, width: 10 })}
|
|
541
|
-
rowOnClick={useCallback((row: QuoteExample) => {setStore(s => ({ ...s, message: `Row ${row?._id} clicked` }))}, [setStore])}
|
|
542
|
-
generateCheckboxActions={generateCheckboxActions}
|
|
543
|
-
generateTd={generateTd}
|
|
544
|
-
className="mb-5"
|
|
545
|
-
tableClassName="rounded-3px"
|
|
546
|
-
rowClassName="[&:hover>div]:bg-gray-50"
|
|
547
|
-
columnClassName="border-t-1 first:rounded-l-xl last:rounded-r-xl"
|
|
548
|
-
columnSelectedClassName="bg-gray-50 border-indigo-300"
|
|
549
|
-
columnHeaderClassName="text-gray-500 text-2xs uppercase border-none"
|
|
550
|
-
checkboxClassName="rounded-[2px] shadow-none"
|
|
551
|
-
/>
|
|
552
|
-
</div>
|
|
583
|
+
{groups.includes('Modals') && (
|
|
584
|
+
<>
|
|
585
|
+
<div>
|
|
586
|
+
<h2 class="h3">Modals</h2>
|
|
587
|
+
<div class="mb-6"><Button color="primary" onClick={() => setShowModal1(true)}>Modal (default)</Button></div>
|
|
588
|
+
</div>
|
|
589
|
+
|
|
590
|
+
<Modal show={showModal1} setShow={setShowModal1}>
|
|
591
|
+
<h3 class="h3">Edit Profile</h3>
|
|
592
|
+
<p class="mb-5">An example modal containing a basic form for editing profiles.</p>
|
|
593
|
+
<form class="mb-8 text-left">
|
|
594
|
+
<div>
|
|
595
|
+
<label for="firstName2">First Name</label>
|
|
596
|
+
<Field name="firstName2" state={state} onChange={(e) => onChange(e, setState)} />
|
|
597
|
+
</div>
|
|
598
|
+
<div>
|
|
599
|
+
<label for="email2">Email Address</label>
|
|
600
|
+
<Field name="email2" type="email" placeholder="Your email address..."/>
|
|
601
|
+
</div>
|
|
602
|
+
</form>
|
|
603
|
+
<div class="flex justify-end">
|
|
604
|
+
<Button color="primary" onClick={() => setShowModal1(false)}>Save</Button>
|
|
605
|
+
</div>
|
|
606
|
+
</Modal>
|
|
607
|
+
</>
|
|
608
|
+
)}
|
|
553
609
|
|
|
554
|
-
{
|
|
610
|
+
{groups.includes('Custom Components') && (
|
|
611
|
+
<>
|
|
612
|
+
{children}
|
|
613
|
+
</>
|
|
614
|
+
)}
|
|
615
|
+
|
|
616
|
+
<GithubLink filename={__filename} />
|
|
555
617
|
</div>
|
|
556
618
|
)
|
|
557
619
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.139",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|
package/types/util.d.ts
CHANGED
|
@@ -497,26 +497,23 @@ export function omit(obj: {
|
|
|
497
497
|
[key: string]: unknown;
|
|
498
498
|
};
|
|
499
499
|
/**
|
|
500
|
-
*
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
* @typedef {({target: {name: string, value: unknown}} | [string, unknown])} EventOrPathValue
|
|
501
|
+
*/
|
|
502
|
+
/**
|
|
503
|
+
* Automatically updates a state object from a field event by using the input name/value (deep paths supported)
|
|
504
|
+
* E.g. setState(s => ({ ...s, [e.target.name]: e.target.value }))
|
|
503
505
|
* @template T
|
|
506
|
+
* @param {EventOrPathValue} eventOrPathValue - The input/select change event or [path, value] to update the state with
|
|
504
507
|
* @param {React.Dispatch<React.SetStateAction<T>>} setState
|
|
505
|
-
* @param {
|
|
506
|
-
* - The input/select change event or path/value pair to update the state with
|
|
508
|
+
* @param {(value: unknown) => unknown} [beforeSetValue] - optional function to change the value before setting the state
|
|
507
509
|
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
508
510
|
* @returns {Promise<T>}
|
|
509
511
|
*
|
|
510
|
-
* @example
|
|
511
|
-
* - <input onChange={(e) => onChange(
|
|
512
|
-
* - <input onChange={() => onChange(
|
|
512
|
+
* @example usage:
|
|
513
|
+
* - <input onChange={(e) => onChange(e, setState)} />
|
|
514
|
+
* - <input onChange={() => onChange(['address.name', 'Joe'], setState)} />
|
|
513
515
|
*/
|
|
514
|
-
export function onChange<T>(setState: React.Dispatch<React.SetStateAction<T>>,
|
|
515
|
-
target: {
|
|
516
|
-
name: string;
|
|
517
|
-
value: unknown;
|
|
518
|
-
};
|
|
519
|
-
} | [string, Function | unknown], beforeSetState?: Function): Promise<T>;
|
|
516
|
+
export function onChange<T>(eventOrPathValue: EventOrPathValue, setState: React.Dispatch<React.SetStateAction<T>>, beforeSetValue?: (value: unknown) => unknown, beforeSetState?: Function): Promise<T>;
|
|
520
517
|
/**
|
|
521
518
|
* Pads a number
|
|
522
519
|
* @param {number} [num=0]
|
|
@@ -594,7 +591,7 @@ export function parseFilters(query: {
|
|
|
594
591
|
* sortBy: 'createdAt'
|
|
595
592
|
* }
|
|
596
593
|
* @param {{ fieldsFlattened: object, name: string }} model - The Monastery model
|
|
597
|
-
* @param {number} [limit=10] -
|
|
594
|
+
* @param {number} [limit=10] - pass 0 to exclude limit/skip, regardless of pagination
|
|
598
595
|
* @param {boolean} [hasMore] - hasMore parameter on parseSortOptions has been deprecated.
|
|
599
596
|
* @example returned object (using the examples above):
|
|
600
597
|
* E.g. {
|
|
@@ -812,6 +809,12 @@ export type Box = {
|
|
|
812
809
|
bottomLeft: Point;
|
|
813
810
|
topRight: Point;
|
|
814
811
|
};
|
|
812
|
+
export type EventOrPathValue = ({
|
|
813
|
+
target: {
|
|
814
|
+
name: string;
|
|
815
|
+
value: unknown;
|
|
816
|
+
};
|
|
817
|
+
} | [string, unknown]);
|
|
815
818
|
/**
|
|
816
819
|
* Build image URL from image array or object
|
|
817
820
|
*/
|
package/types/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"AA2CA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BC;AAED;;;;;;;;;GASG;AAC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,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACzG;uBAGW,MAAM;sBACN,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ;;;;wBAC3B,CAAC,MAAM,GAAC,MAAM,GAAC,OAAO,CAAC,EAAE;yBACzB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;yBACjC;IAAE,MAAM,EAAE,MAAM;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE;8BACrC;IAAE,QAAQ,EAAE;QAAE,IAAI,EAAE;YAAE,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE"}
|
package/util.js
CHANGED
|
@@ -1166,60 +1166,62 @@ export function omit (obj, fields) {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
1168
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
|
|
1171
|
-
|
|
1169
|
+
* @typedef {({target: {name: string, value: unknown}} | [string, unknown])} EventOrPathValue
|
|
1170
|
+
*/
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Automatically updates a state object from a field event by using the input name/value (deep paths supported)
|
|
1174
|
+
* E.g. setState(s => ({ ...s, [e.target.name]: e.target.value }))
|
|
1172
1175
|
* @template T
|
|
1176
|
+
* @param {EventOrPathValue} eventOrPathValue - The input/select change event or [path, value] to update the state with
|
|
1173
1177
|
* @param {React.Dispatch<React.SetStateAction<T>>} setState
|
|
1174
|
-
* @param {
|
|
1175
|
-
* - The input/select change event or path/value pair to update the state with
|
|
1178
|
+
* @param {(value: unknown) => unknown} [beforeSetValue] - optional function to change the value before setting the state
|
|
1176
1179
|
* @param {Function} [beforeSetState] - optional function to run before setting the state
|
|
1177
1180
|
* @returns {Promise<T>}
|
|
1178
1181
|
*
|
|
1179
|
-
* @example
|
|
1180
|
-
* - <input onChange={(e) => onChange(
|
|
1181
|
-
* - <input onChange={() => onChange(
|
|
1182
|
+
* @example usage:
|
|
1183
|
+
* - <input onChange={(e) => onChange(e, setState)} />
|
|
1184
|
+
* - <input onChange={() => onChange(['address.name', 'Joe'], setState)} />
|
|
1182
1185
|
*/
|
|
1183
|
-
export function onChange (setState,
|
|
1184
|
-
/** @type {unknown
|
|
1186
|
+
export function onChange (eventOrPathValue, setState, beforeSetValue, beforeSetState) {
|
|
1187
|
+
/** @type {unknown} */
|
|
1185
1188
|
let value
|
|
1186
1189
|
/** @type {string} */
|
|
1187
1190
|
let path = ''
|
|
1188
|
-
/** @type {boolean} */
|
|
1191
|
+
/** @type {boolean | undefined} */
|
|
1189
1192
|
let hasFiles
|
|
1190
1193
|
|
|
1191
1194
|
if (typeof eventOrPathValue === 'object' && 'target' in eventOrPathValue) {
|
|
1192
|
-
const element = /** @type {HTMLInputElement & {_value?: unknown}} */(eventOrPathValue.target)
|
|
1193
|
-
path =
|
|
1195
|
+
const element = /** @type {HTMLInputElement & {_value?: unknown}} */(eventOrPathValue.target)
|
|
1196
|
+
path = element.name || element.id || ''
|
|
1194
1197
|
hasFiles = !!element.files
|
|
1195
|
-
value =
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1198
|
+
value = (
|
|
1199
|
+
element.files
|
|
1200
|
+
? element.files[0]
|
|
1201
|
+
: typeof element._value !== 'undefined'
|
|
1202
|
+
? element._value
|
|
1203
|
+
: element.type === 'checkbox'
|
|
1204
|
+
? element.checked
|
|
1205
|
+
: element.value
|
|
1206
|
+
)
|
|
1203
1207
|
} else if (Array.isArray(eventOrPathValue)) {
|
|
1204
1208
|
path = eventOrPathValue[0]
|
|
1205
1209
|
value = eventOrPathValue[1]
|
|
1206
1210
|
}
|
|
1207
|
-
|
|
1208
|
-
// Removing leading zero(s) on number fields
|
|
1209
|
-
// if (element.type == 'number' && !isFunction(value) && (value||'').match(/^0+([1-9])/)) {
|
|
1210
|
-
// value = value.replace(/^0+([1-9])/, '$1')
|
|
1211
|
-
// }
|
|
1212
1211
|
|
|
1213
1212
|
// Update state
|
|
1214
1213
|
return new Promise((resolve) => {
|
|
1215
1214
|
setState((state) => {
|
|
1215
|
+
const newValue = beforeSetValue ? beforeSetValue(value) : value
|
|
1216
|
+
const baseState = { ...state, ...(hasFiles ? { hasFiles } : {}) }
|
|
1217
|
+
|
|
1216
1218
|
/** @type {{[key: string]: any}} */
|
|
1217
|
-
const { obj
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
resolve(
|
|
1222
|
-
return
|
|
1219
|
+
const { obj, parent, fieldName } = deepSetWithInfo(baseState, path, newValue)
|
|
1220
|
+
|
|
1221
|
+
const newState = beforeSetState ? beforeSetState({ state: obj, parent: parent, key: fieldName }) : obj
|
|
1222
|
+
|
|
1223
|
+
resolve(newState)
|
|
1224
|
+
return newState
|
|
1223
1225
|
})
|
|
1224
1226
|
})
|
|
1225
1227
|
}
|
|
@@ -1377,7 +1379,7 @@ export function parseFilters(query, config) {
|
|
|
1377
1379
|
* sortBy: 'createdAt'
|
|
1378
1380
|
* }
|
|
1379
1381
|
* @param {{ fieldsFlattened: object, name: string }} model - The Monastery model
|
|
1380
|
-
* @param {number} [limit=10] -
|
|
1382
|
+
* @param {number} [limit=10] - pass 0 to exclude limit/skip, regardless of pagination
|
|
1381
1383
|
* @param {boolean} [hasMore] - hasMore parameter on parseSortOptions has been deprecated.
|
|
1382
1384
|
* @example returned object (using the examples above):
|
|
1383
1385
|
* E.g. {
|