nitro-web 0.0.16 → 0.0.17

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.
@@ -1,134 +1,165 @@
1
- // @ts-nocheck
2
1
  import { css } from 'twin.macro'
3
- import { InputColor, InputCurrency, util } from 'nitro-web' // InputDate
4
-
2
+ import { twMerge } from 'tailwind-merge'
3
+ import { util, FieldCurrency, FieldCurrencyProps, FieldColor, FieldColorProps, FieldDate, FieldDateProps } from 'nitro-web'
4
+ import { Errors, type Error } from 'types'
5
5
  import {
6
6
  EnvelopeIcon,
7
- // CalendarIcon,
7
+ CalendarIcon,
8
8
  FunnelIcon,
9
9
  MagnifyingGlassIcon,
10
10
  EyeIcon,
11
11
  EyeSlashIcon,
12
12
  } from '@heroicons/react/20/solid'
13
13
 
14
- interface InputProps {
14
+ type InputProps = React.InputHTMLAttributes<HTMLInputElement>
15
+ type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>
16
+ type FieldExtraProps = {
17
+ // field name or path on state (used to match errors), e.g. 'date', 'company.email'
15
18
  name: string
16
- state?: any
17
19
  id?: string
18
- type?: string
19
- [key: string]: any
20
+ // state object to get the value, and check errors against
21
+ state?: { errors: Errors, [key: string]: unknown }
22
+ type?: 'text' | 'password' | 'email' | 'filter' | 'search' | 'textarea' | 'currency' | 'date' | 'color'
23
+ icon?: React.ReactNode
24
+ iconPos?: 'left' | 'right'
25
+ }
26
+ type IconWrapperProps = {
27
+ iconPos: string
28
+ icon?: React.ReactNode
29
+ [key: string]: unknown
20
30
  }
31
+ // Discriminated union (https://stackoverflow.com/a/77351290/1900648)
32
+ export type FieldProps = (
33
+ | ({ type?: 'text' | 'password' | 'email' | 'filter' | 'search' } & InputProps & FieldExtraProps)
34
+ | ({ type: 'textarea' } & TextareaProps & FieldExtraProps)
35
+ | ({ type: 'currency' } & FieldCurrencyProps & FieldExtraProps)
36
+ | ({ type: 'color' } & FieldColorProps & FieldExtraProps)
37
+ | ({ type: 'date' } & FieldDateProps & FieldExtraProps)
38
+ )
39
+
40
+ export function Field({ state, icon, iconPos: ip, ...props }: FieldProps) {
41
+ // type must be kept as props.type for TS to be happy and follow the conditions below
42
+ let error!: Error
43
+ let value!: string
44
+ let Icon!: React.ReactNode
45
+ const type = props.type
46
+ const iconPos = ip == 'left' || (type == 'color' && !ip) ? 'left' : 'right'
21
47
 
22
- export function Input({ name='', state, id, type='text', ...props }: InputProps) {
23
- /**
24
- * Input
25
- * @param {string} name - field name or path on state (used to match errors), e.g. 'date', 'company.email'
26
- * @param {object} state - State object to get the value, and check errors against
27
- * @param {string} [id] - not required, name used if not provided
28
- * @param {('password'|'email'|'text'|'date'|'filter'|'search'|'color'|'textarea'|'currency')} [type='text']
29
- */
30
- let IconSvg: React.ReactNode
31
- let onClick: () => void
32
- let iconDir = 'right'
33
- let InputEl = 'input'
48
+ if (!props.name) {
49
+ throw new Error('Input component requires a `name` prop')
50
+ }
51
+
52
+ // Input type
34
53
  const [inputType, setInputType] = useState(() => { // eslint-disable-line
35
- return type == 'password' ? 'password' : (type == 'textarea' ? type : 'text')
54
+ return type == 'password' ? 'password' : (type == 'textarea' ? 'textarea' : 'text')
36
55
  })
37
-
38
- if (!name) throw new Error('Input component requires a `name` prop')
39
56
 
40
- // Input is always controlled if state is passed in
41
- if (props.value) {
42
- var value = props.value
43
- } else if (typeof state == 'object') {
44
- value = util.deepFind(state, name)
45
- if (typeof value == 'undefined') value = ''
46
- }
57
+ // Value: Input is always controlled if state is passed in
58
+ if (props.value) value = props.value as string
59
+ else if (typeof state == 'object') value = util.deepFind(state, props.name) ?? ''
47
60
 
48
- // Find any errors that match this input path
61
+ // Errors: find any that match this input path
49
62
  for (const item of (state?.errors || [])) {
50
- if (util.isRegex(name) && (item.title||'').match(name)) var error = item
51
- else if (item.title == name) error = item
63
+ if (util.isRegex(props.name) && (item.title || '').match(props.name)) error = item
64
+ else if (item.title == props.name) error = item
52
65
  }
53
66
 
54
- // Special input types
67
+ // Icon
55
68
  if (type == 'password') {
56
- onClick = () => setInputType(o => o == 'password' ? 'text' : 'password')
57
- IconSvg = inputType == 'password' ? <EyeSlashIcon /> : <EyeIcon />
58
- } else if (type == 'email') {
59
- IconSvg = <EnvelopeIcon />
60
- // } else if (type == 'date') {
61
- // IconSvg = <CalendarIcon />
62
- // InputEl = InputDate
63
- } else if (type == 'filter') {
64
- IconSvg = <FunnelIcon />
65
- } else if (type == 'search') {
66
- IconSvg = <MagnifyingGlassIcon />
69
+ Icon = <IconWrapper
70
+ iconPos={iconPos}
71
+ icon={icon || inputType == 'password' ? <EyeSlashIcon /> : <EyeIcon />}
72
+ onClick={() => setInputType(o => o == 'password' ? 'text' : 'password')}
73
+ className="pointer-events-auto"
74
+ />
75
+ } else if (type == 'email') {
76
+ Icon = <IconWrapper iconPos={iconPos} icon={icon || <EnvelopeIcon />} />
77
+ } else if (type == 'filter') {
78
+ Icon = <IconWrapper iconPos={iconPos} icon={icon || <FunnelIcon />} className="size-3" />
79
+ } else if (type == 'search') {
80
+ Icon = <IconWrapper iconPos={iconPos} icon={icon || <MagnifyingGlassIcon />} className="size-4" />
67
81
  } else if (type == 'color') {
68
- iconDir = 'left'
69
- IconSvg = <ColorIcon hex={value}/>
70
- InputEl = InputColor
71
- } else if (type == 'textarea') {
72
- InputEl = 'textarea'
73
- } else if (type == 'currency') {
74
- if (!props.config) throw new Error('Input: `config` is required when type=currency')
75
- InputEl = InputCurrency
82
+ Icon = <IconWrapper iconPos={iconPos} icon={icon || <ColorSvg hex={value}/>} className="size-[17px]" />
83
+ } else if (type == 'date') {
84
+ Icon = <IconWrapper iconPos={iconPos} icon={icon || <CalendarIcon />} className="size-4" />
85
+ } else {
86
+ Icon = <IconWrapper iconPos={iconPos} icon={icon} />
76
87
  }
77
88
 
78
- // Icon
79
- const iconEl = <IconEl iconDir={iconDir} IconSvg={IconSvg} onClick={onClick} type={type} />
89
+ // Classname
90
+ const inputClassName = getInputClasses({ error, Icon, iconPos, type })
91
+ const commonProps = { id: props.name || props.id, value: value, className: inputClassName }
80
92
 
81
- // Create base props object
82
- const inputProps = {
83
- ...props,
84
- // autoComplete: props.autoComplete || 'off',
85
- id: id || name,
86
- type: inputType,
87
- value: value,
88
- iconEl: iconEl,
89
- className:
90
- 'col-start-1 row-start-1 block w-full rounded-md bg-white py-2 text-sm outline outline-1 -outline-offset-1 ' +
91
- 'placeholder:text-input-placeholder focus:outline focus:outline-2 focus:-outline-offset-2 sm:text-sm/6 ' +
92
- (iconDir == 'right' && IconSvg ? 'sm:pr-9 pl-3 pr-10 ' : IconSvg ? 'sm:pl-9 pl-10 pr-3 ' : 'px-3 ') +
93
- (error ? 'text-red-900 outline-danger focus:outline-danger ' : 'text-input outline-input-border focus:outline-primary ') +
94
- (iconDir == 'right' ? 'justify-self-start ' : 'justify-self-end '),
93
+ // Type has to be referenced as props.type for TS to be happy
94
+ if (!type || type == 'text' || type == 'password' || type == 'email' || type == 'filter' || type == 'search') {
95
+ return (
96
+ <FieldContainer error={error} className={props.className}>
97
+ {Icon}<input {...props} {...commonProps} type={inputType} />
98
+ </FieldContainer>
99
+ )
100
+ } else if (type == 'textarea') {
101
+ return (
102
+ <FieldContainer error={error} className={props.className}>
103
+ {Icon}<textarea {...props} {...commonProps} />
104
+ </FieldContainer>
105
+ )
106
+ } else if (type == 'currency') {
107
+ return (
108
+ <FieldContainer error={error} className={props.className}>
109
+ {Icon}<FieldCurrency {...props} {...commonProps} />
110
+ </FieldContainer>
111
+ )
112
+ } else if (type == 'color') {
113
+ return (
114
+ <FieldContainer error={error} className={props.className}>
115
+ <FieldColor {...props} {...commonProps} Icon={Icon} />
116
+ </FieldContainer>
117
+ )
118
+ } else if (type == 'date') {
119
+ return (
120
+ <FieldContainer error={error} className={props.className}>
121
+ <FieldDate {...props} {...commonProps} Icon={Icon} />
122
+ </FieldContainer>
123
+ )
95
124
  }
125
+ }
96
126
 
97
- // Only add iconEl prop for custom components
98
- if (!['color', 'date'].includes(type)) delete inputProps.iconEl
99
-
127
+ function FieldContainer({ children, className, error }: { children: React.ReactNode, className?: string, error?: Error }) {
100
128
  return (
101
- // https://tailwindui.com/components/application-ui/forms/input-groups#component-474bd025b849b44eb3c46df09a496b7a
102
- <div css={style} className={`mt-input-before mb-input-after grid grid-cols-1 ${props?.className || ''}`}>
103
- { !inputProps.iconEl && iconEl }
104
- <InputEl {...inputProps} />
129
+ <div css={style} className={`mt-input-before mb-input-after grid grid-cols-1 ${className || ''}`}>
130
+ {children}
105
131
  {error && <div class="mt-1.5 text-xs text-danger">{error.detail}</div>}
106
132
  </div>
107
133
  )
108
134
  }
109
135
 
110
- type IconElProps = {
111
- iconDir: string
112
- IconSvg: React.ReactNode
113
- onClick: () => void
114
- type: string
136
+ function getInputClasses({ error, Icon, iconPos, type }: { error: Error, Icon?: React.ReactNode, iconPos: string, type?: string }) {
137
+ const paddingLeft = type == 'color' ? 'sm:pl-9 pl-9' : 'sm:pl-8 pl-8'
138
+ const paddingRight = type == 'color' ? 'sm:pr-9 pr-9' : 'sm:pr-8 pr-8'
139
+ return (
140
+ 'col-start-1 row-start-1 block w-full rounded-md bg-white py-2 text-sm leading-[1.65] outline outline-1 -outline-offset-1 ' +
141
+ 'placeholder:text-input-placeholder focus:outline focus:outline-2 focus:-outline-offset-2 ' +
142
+ (iconPos == 'right' && Icon ? `${paddingRight} pl-3 ` : (Icon ? `${paddingLeft} pr-3 ` : 'px-3 ')) +
143
+ (error ? 'text-red-900 outline-danger focus:outline-danger ' : 'text-input outline-input-border focus:outline-primary ') +
144
+ (iconPos == 'right' ? 'justify-self-start ' : 'justify-self-end ')
145
+ )
115
146
  }
116
147
 
117
- function IconEl({ iconDir, IconSvg, onClick, type }: IconElProps) {
118
- const iconSize = type == 'color' ? 'size-[18px]' : 'size-4'
148
+ function IconWrapper({ icon, iconPos, ...props }: IconWrapperProps) {
119
149
  return (
120
- !!IconSvg &&
121
- <div
122
- className={`col-start-1 row-start-1 ${iconSize} self-center text-[#c6c8ce] select-none relative z-[1] ` +
123
- `pointer-events-${type == 'password' ? 'auto' : 'none'} ` +
124
- (iconDir == 'right' ? 'justify-self-end mr-3' : 'justify-self-start ml-3')
125
- }
126
- onClick={onClick}
127
- >{IconSvg}</div>
150
+ !!icon &&
151
+ <div
152
+ {...props}
153
+ className={twMerge(
154
+ 'relative size-[14px] col-start-1 row-start-1 self-center text-[#c6c8ce] select-none z-[1] ' +
155
+ (iconPos == 'right' ? 'justify-self-end mr-3 ' : 'justify-self-start ml-3 ') +
156
+ props.className || ''
157
+ )}
158
+ >{icon}</div>
128
159
  )
129
160
  }
130
161
 
131
- function ColorIcon({ hex }: { hex: string }) {
162
+ function ColorSvg({ hex }: { hex?: string }) {
132
163
  return (
133
164
  <span class="block size-full rounded-md" style={{ backgroundColor: hex ? hex : '#f1f1f1' }}></span>
134
165
  )
@@ -2,7 +2,7 @@ import { css } from 'twin.macro'
2
2
  import { twMerge } from 'tailwind-merge'
3
3
  import ReactSelect, { components, ControlProps, createFilter, OptionProps, SingleValueProps } from 'react-select'
4
4
  import { ClearIndicatorProps, DropdownIndicatorProps, MultiValueRemoveProps } from 'react-select'
5
- import { ChevronDownIcon, CheckCircleIcon, XMarkIcon } from '@heroicons/react/20/solid'
5
+ import { ChevronUpDownIcon, CheckCircleIcon, XMarkIcon } from '@heroicons/react/20/solid'
6
6
  import { util } from 'nitro-web'
7
7
  import { Errors } from 'types'
8
8
 
@@ -203,7 +203,7 @@ function Option(props: OptionProps) {
203
203
  const DropdownIndicator = (props: DropdownIndicatorProps) => {
204
204
  return (
205
205
  <components.DropdownIndicator {...props}>
206
- <ChevronDownIcon className="size-6 -my-0.5 -mx-1" />
206
+ <ChevronUpDownIcon className="text-gray-400 size-[17px] -my-0.5 -mx-0.5" />
207
207
  </components.DropdownIndicator>
208
208
  )
209
209
  }
@@ -237,7 +237,7 @@ const selectStyles = {
237
237
  // Based off https://www.jussivirtanen.fi/writing/styling-react-select-with-tailwind
238
238
  // Input container
239
239
  control: {
240
- base: 'rounded-md bg-white hover:cursor-pointer text-sm sm:text-sm/6 outline outline-1 -outline-offset-1 outline-input-border',
240
+ base: 'rounded-md bg-white hover:cursor-pointer text-sm leading-[1.65] outline outline-1 -outline-offset-1 outline-input-border',
241
241
  focus: 'outline-2 -outline-offset-2 outline-primary',
242
242
  error: 'outline-danger',
243
243
  },
@@ -249,7 +249,7 @@ const selectStyles = {
249
249
  },
250
250
  multiValue: 'bg-primary text-white rounded items-center pl-2 pr-1.5 gap-1.5',
251
251
  multiValueLabel: '',
252
- multiValueRemove: 'border border-primary-dark bg-white rounded-md text-dark hover:bg-red-50',
252
+ multiValueRemove: 'border border-black/10 bg-clip-content bg-white rounded-md text-dark hover:bg-red-50',
253
253
  placeholder: 'text-input-placeholder',
254
254
  singleValue: {
255
255
  base: 'text-input',
@@ -1,21 +1,23 @@
1
- import { Drop, Dropdown, Input, Select, Button, Checkbox, GithubLink, isDemo } from 'nitro-web'
1
+ import { Drop, Dropdown, Field, Select, Button, Checkbox, GithubLink, isDemo, Modal, Calendar } from 'nitro-web'
2
2
  import { getCountryOptions, getCurrencyOptions, ucFirst } from 'nitro-web/util'
3
3
  import { CheckIcon } from '@heroicons/react/20/solid'
4
4
  import { Config } from 'types'
5
5
 
6
6
  export function Styleguide({ config }: { config: Config }) {
7
7
  const [customerSearch, setCustomerSearch] = useState('')
8
+ const [showModal1, setShowModal1] = useState(false)
8
9
  const [state, setState] = useState({
9
10
  address: '',
10
- country: 'us',
11
- currency: 'nzd', // can be commented too
12
11
  amount: 100,
13
12
  brandColor: '#F3CA5F',
14
- firstName: 'Bruce',
13
+ country: 'us',
14
+ currency: 'nzd', // can be commented too
15
15
  date: Date.now(),
16
+ 'date-range': [Date.now(), Date.now() + 1000 * 60 * 60 * 24 * 33],
17
+ calendar: [Date.now(), Date.now() + 1000 * 60 * 60 * 24 * 8],
18
+ firstName: 'Bruce',
16
19
  errors: [
17
20
  { title: 'address', detail: 'Address is required' },
18
- { title: 'currency', detail: 'Currency is required' },
19
21
  ],
20
22
  })
21
23
 
@@ -60,33 +62,19 @@ export function Styleguide({ config }: { config: Config }) {
60
62
  </div>
61
63
 
62
64
  <h2 class="h3">Links</h2>
63
- <div class="mb-8">
65
+ <div class="mb-10">
64
66
  <a class="mr-2" href="#">Default</a>
65
67
  <a class="underline1 is-active mr-2" href="#">Underline1</a>
66
68
  <a class="underline2 is-active mr-2" href="#">Underline2</a>
67
69
  </div>
68
70
 
69
- <h2 class="h3">Checkboxes</h2>
70
- <div class="grid grid-cols-3 gap-x-6">
71
- <div>
72
- <label for="input0">Label</label>
73
- <Checkbox name="input0" type="checkbox" text="Checkbox" subtext="some additional text here." defaultChecked />
74
- </div>
75
- <div>
76
- <label for="input1">Label</label>
77
- <Checkbox name="input1" type="radio" text="Radio 1" subtext="some additional text here 1." id="input1-1" class="!mb-0"
78
- defaultChecked />
79
- <Checkbox name="input1" type="radio" text="Radio 2" subtext="some additional text here 2." id="input1-2" class="!mt-0" />
80
- </div>
81
- <div>
82
- <label for="input2">Label</label>
83
- <Checkbox name="input2" type="toggle" text="Toggle sm" subtext="some additional text here." class="!mb-0" defaultChecked />
84
- <Checkbox name="input3" type="toggle" text="Toggle md" size="md" subtext="some additional text here." />
85
- </div>
71
+ <h2 class="h3">Modals</h2>
72
+ <div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
73
+ <div><Button color="primary" onClick={() => setShowModal1(true)}>Modal (default)</Button></div>
86
74
  </div>
87
75
 
88
76
  <h2 class="h3">Dropdowns</h2>
89
- <div class="flex flex-wrap gap-x-6 gap-y-4 mb-8">
77
+ <div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
90
78
  <div>
91
79
  <Dropdown options={options} minWidth="250px">
92
80
  <Button IconRight="v" class="gap-x-3">Dropdown</Button>
@@ -110,7 +98,7 @@ export function Styleguide({ config }: { config: Config }) {
110
98
  </div>
111
99
 
112
100
  <h2 class="h3">Buttons</h2>
113
- <div class="flex flex-wrap gap-x-6 gap-y-4 mb-8">
101
+ <div class="flex flex-wrap gap-x-6 gap-y-4 mb-10">
114
102
  <div><Button color="primary">primary (default)</Button></div>
115
103
  <div><Button color="secondary">secondary button</Button></div>
116
104
  <div><Button color="white">white button</Button></div>
@@ -124,8 +112,27 @@ export function Styleguide({ config }: { config: Config }) {
124
112
  <div><Button color="primary" IconRight="v" isLoading>primary isLoading</Button></div>
125
113
  </div>
126
114
 
115
+ <h2 class="h3">Checkboxes</h2>
116
+ <div class="grid grid-cols-3 gap-x-6 mb-4">
117
+ <div>
118
+ <label for="input2">Label</label>
119
+ <Checkbox name="input2" type="toggle" text="Toggle sm" subtext="some additional text here." class="!mb-0" defaultChecked />
120
+ <Checkbox name="input3" type="toggle" text="Toggle md" size="md" subtext="some additional text here." />
121
+ </div>
122
+ <div>
123
+ <label for="input1">Label</label>
124
+ <Checkbox name="input1" type="radio" text="Radio 1" subtext="some additional text here 1." id="input1-1" class="!mb-0"
125
+ defaultChecked />
126
+ <Checkbox name="input1" type="radio" text="Radio 2" subtext="some additional text here 2." id="input1-2" class="!mt-0" />
127
+ </div>
128
+ <div>
129
+ <label for="input0">Label</label>
130
+ <Checkbox name="input0" type="checkbox" text="Checkbox" subtext="some additional text here." defaultChecked />
131
+ </div>
132
+ </div>
133
+
127
134
  <h2 class="h3">Selects</h2>
128
- <div class="grid grid-cols-3 lg:grid-cols-3 gap-x-6">
135
+ <div class="grid grid-cols-3 lg:grid-cols-3 gap-x-6 mb-4">
129
136
  <div>
130
137
  <label for="action">Default</label>
131
138
  <Select
@@ -204,53 +211,88 @@ export function Styleguide({ config }: { config: Config }) {
204
211
  <div class="grid grid-cols-3 gap-x-6 mb-4">
205
212
  <div>
206
213
  <label for="firstName">First Name</label>
207
- <Input name="firstName" state={state} onChange={onInputChange} />
214
+ <Field name="firstName" state={state} onChange={onInputChange} />
208
215
  </div>
209
216
  <div>
210
217
  <label for="email">Email Address</label>
211
- <Input name="email" type="email" placeholder="Your email address..."/>
218
+ <Field name="email" type="email" placeholder="Your email address..."/>
212
219
  </div>
213
220
  <div>
214
221
  <div class="flex justify-between">
215
222
  <label for="password">Password</label>
216
223
  <a href="#" class="label">Forgot?</a>
217
224
  </div>
218
- <Input name="password" type="password"/>
225
+ <Field name="password" type="password"/>
219
226
  </div>
220
227
  <div>
221
228
  <label for="search">Search</label>
222
- <Input name="search" type="search" placeholder="Search..."/>
229
+ <Field name="search" type="search" placeholder="Search..." />
223
230
  </div>
224
231
  <div>
225
- <label for="filter">Filter</label>
226
- <Input name="filter" type="filter" />
232
+ <label for="filter">Filter by Code</label>
233
+ <Field name="filter" type="filter" iconPos="left" />
227
234
  </div>
228
235
  <div>
229
236
  <label for="address">Input Error</label>
230
- <Input name="address" type="address" placeholder="Address..." state={state} onChange={onInputChange} />
237
+ <Field name="address" placeholder="Address..." state={state} onChange={onInputChange} />
231
238
  </div>
232
- {/* <div>
233
- <label for="date">Date</label>
234
- <Input name="date" type="date" prefix="Date:" state={state} onChange={onInputChange} />
235
- </div> */}
236
239
  <div>
237
- <label for="brandColor">Brand Color</label>
238
- <Input name="brandColor" type="color" state={state} onChange={onInputChange} />
240
+ <label for="description">Description</label>
241
+ <Field name="description" type="textarea" rows={2} />
239
242
  </div>
240
243
  <div>
241
- <label for="description">Description</label>
242
- <Input name="description" type="textarea" />
244
+ <label for="brandColor">Brand Color</label>
245
+ <Field name="brandColor" type="color" state={state} iconPos="left" onChange={onInputChange} />
243
246
  </div>
244
247
  <div>
245
248
  <label for="amount">Amount ({state.amount})</label>
246
- <Input name="amount" type="currency" state={state} currency={state.currency || 'nzd'} onChange={onInputChange} config={config} />
249
+ <Field name="amount" type="currency" state={state} currency={state.currency || 'nzd'} onChange={onInputChange} config={config} />
250
+ </div>
251
+ </div>
252
+
253
+ <h2 class="h3">Date Inputs</h2>
254
+ <div class="grid grid-cols-3 gap-x-6 mb-4">
255
+ <div>
256
+ <label for="date">Date</label>
257
+ <Field name="date" type="date" state={state} onChange={onInputChange} />
247
258
  </div>
259
+ <div>
260
+ <label for="date-range">Date range with prefix</label>
261
+ <Field name="date-range" type="date" mode="range" prefix="Date:" state={state} onChange={onInputChange} />
262
+ </div>
263
+ </div>
264
+
265
+ <h2 class="h3">File Inputs & Calendar</h2>
266
+ <div class="grid grid-cols-3 gap-x-6 mb-4">
248
267
  <div>
249
268
  <label for="avatar">Avatar</label>
250
269
  <Drop class="is-small" name="avatar" state={state} onChange={onInputChange} awsUrl={config.awsUrl} />
251
270
  </div>
271
+ <div>
272
+ <label for="calendar">Calendar</label>
273
+ <Calendar mode="range" value={state.calendar} numberOfMonths={1} onChange={(mode, value) => {
274
+ onInputChange({ target: { id: 'calendar', value: value } })
275
+ }} />
276
+ </div>
252
277
  </div>
253
278
 
279
+ <Modal show={showModal1} setShow={setShowModal1} class="p-9">
280
+ <h3 class="h3">Edit Profile</h3>
281
+ <p class="mb-5">An example modal containing a basic form for editing profiles.</p>
282
+ <form class="mb-8 text-left">
283
+ <div>
284
+ <label for="firstName2">First Name</label>
285
+ <Field name="firstName2" state={state} onChange={onInputChange} />
286
+ </div>
287
+ <div>
288
+ <label for="email2">Email Address</label>
289
+ <Field name="email2" type="email" placeholder="Your email address..."/>
290
+ </div>
291
+ </form>
292
+ <div class="flex justify-end">
293
+ <Button color="primary" onClick={() => setShowModal1(false)}>Save</Button>
294
+ </div>
295
+ </Modal>
254
296
  </div>
255
297
  )
256
298
  }
@@ -2,7 +2,7 @@
2
2
  // todo: finish tailwind conversion
3
3
  import * as util from 'nitro-web/util'
4
4
  import SvgTick from 'nitro-web/client/imgs/icons/tick.svg'
5
- import { Button, FormError, Input, Modal, Topbar, Tabbar } from 'nitro-web'
5
+ import { Button, FormError, Field, Modal, Topbar, Tabbar } from 'nitro-web'
6
6
 
7
7
  export function SettingsAccount() {
8
8
  const isLoading = useState('')
@@ -48,21 +48,21 @@ export function SettingsAccount() {
48
48
  <div class="cols cols-6 cols-gap-3">
49
49
  <div class="col">
50
50
  <label for="firstName">First Name(s)</label>
51
- <Input name="firstName" placeholder="E.g. Bruce" state={state} onChange={onChange(setState)} />
51
+ <Field name="firstName" placeholder="E.g. Bruce" state={state} onChange={onChange.bind(setState)} />
52
52
  </div>
53
53
  <div class="col">
54
54
  <label for="lastName">Last Name</label>
55
- <Input name="lastName" placeholder="E.g. Wayne" state={state} onChange={onChange(setState)} />
55
+ <Field name="lastName" placeholder="E.g. Wayne" state={state} onChange={onChange.bind(setState)} />
56
56
  </div>
57
57
  <div class="col">
58
58
  <label for="email">Email Address</label>
59
- <Input name="email" type="email" placeholder="Your email address..." state={state}
60
- onChange={onChange(setState)} />
59
+ <Field name="email" type="email" placeholder="Your email address..." state={state}
60
+ onChange={onChange.bind(setState)} />
61
61
  </div>
62
62
  <div class="col">
63
63
  <Link to="/reset" class="label-right link2 underline2 is-active">Reset Password?</Link>
64
64
  <label for="password">Password</label>
65
- <Input name="password" placeholder="•••••••••••" disabled={true} />
65
+ <Field name="password" placeholder="•••••••••••" disabled={true} />
66
66
  </div>
67
67
  </div>
68
68
 
@@ -1,10 +1,10 @@
1
- // @ts-nocheck
1
+ //@ts-nocheck
2
2
  // todo: finish tailwind conversio
3
3
 
4
4
  ////// look at the select type error below
5
5
  import * as util from 'nitro-web/util'
6
6
  import SvgTick from 'nitro-web/client/imgs/icons/tick.svg'
7
- import { Button, Input, Select, Topbar, Tabbar } from 'nitro-web'
7
+ import { Button, Field, Select, Topbar, Tabbar } from 'nitro-web'
8
8
 
9
9
  export function SettingsBusiness({ config }) {
10
10
  const isLoading = useState('')
@@ -65,7 +65,7 @@ export function SettingsBusiness({ config }) {
65
65
  type="country"
66
66
  state={state}
67
67
  options={useMemo(() => util.getCountryOptions(config.countries), [])}
68
- onChange={onChange(setState)}
68
+ onChange={onChange.bind(setState)}
69
69
  />
70
70
  </div>
71
71
  <div class="col">
@@ -75,37 +75,37 @@ export function SettingsBusiness({ config }) {
75
75
  type="country"
76
76
  state={state}
77
77
  options={useMemo(() => util.getCurrencyOptions(config.currencies), [])}
78
- onChange={onChange(setState)}
78
+ onChange={onChange.bind(setState)}
79
79
  />
80
80
  </div>
81
81
  <div class="col">
82
82
  <label for="business.name">Trading Name</label>
83
- <Input name="business.name" placeholder="E.g. Wayne Enterprises" state={state} onChange={onChange(setState)} />
83
+ <Field name="business.name" placeholder="E.g. Wayne Enterprises" state={state} onChange={onChange.bind(setState)} />
84
84
  </div>
85
85
  <div class="col">
86
86
  <Link to="#" class="label-right link2 underline2 is-active">Custom Address</Link>
87
87
  <label for="business.address">Address (Start Typing...)</label>
88
- <Input name="business.address.full" placeholder="" state={state} onChange={onChange(setState)} />
88
+ <Field name="business.address.full" placeholder="" state={state} onChange={onChange.bind(setState)} />
89
89
  </div>
90
90
  <div class="col">
91
91
  <label for="business.website">Website</label>
92
- <Input name="business.website" placeholder="https://" state={state} onChange={onChange(setState)} />
92
+ <Field name="business.website" placeholder="https://" state={state} onChange={onChange.bind(setState)} />
93
93
  </div>
94
94
  <div class="col">
95
95
  <label for="business.phone">Mobile Number</label>
96
- <Input name="business.phone" placeholder="" state={state} onChange={onChange(setState)} />
96
+ <Field name="business.phone" placeholder="" state={state} onChange={onChange.bind(setState)} />
97
97
  </div>
98
98
  <div class="col">
99
99
  <Link to="#" class="label-right link2 underline2 is-active">What&apos;s this for?</Link>
100
100
  <label for="tax.number">GST Number</label>
101
- <Input class="mb-0" name="tax.number" placeholder="Appears on your documents" state={state}
102
- onChange={onChange(setState)} />
101
+ <Field class="mb-0" name="tax.number" placeholder="Appears on your documents" state={state}
102
+ onChange={onChange.bind(setState)} />
103
103
  </div>
104
104
  <div class="col">
105
105
  <Link to="#" class="label-right link2 underline2 is-active">What&apos;s this for?</Link>
106
106
  <label for="business.number">NZBN</label>
107
- <Input class="mb-0" name="business.number" placeholder="Appears on your documents" state={state}
108
- onChange={onChange(setState)} />
107
+ <Field class="mb-0" name="business.number" type="text" rows="23" placeholder="Appears on your documents" state={state}
108
+ onChange={onChange.bind(setState)} />
109
109
  </div>
110
110
  </div>
111
111
  </form>