nitro-web 0.0.188 โ 0.0.190
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.
|
@@ -20,6 +20,8 @@ type PreFieldDateProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onCh
|
|
|
20
20
|
mode: 'single' | 'multiple' | 'range' | 'time'
|
|
21
21
|
/** show the time picker for single mode*/
|
|
22
22
|
showTime?: boolean
|
|
23
|
+
/** pattern to use for the date picker */
|
|
24
|
+
pattern?: string
|
|
23
25
|
/** prefix to add to the input */
|
|
24
26
|
prefix?: string
|
|
25
27
|
/** number of months to show in the dropdown */
|
|
@@ -61,6 +63,7 @@ export function FieldDate({
|
|
|
61
63
|
Icon,
|
|
62
64
|
numberOfMonths,
|
|
63
65
|
onChange: onChangeProp,
|
|
66
|
+
pattern: patternProp,
|
|
64
67
|
prefix = '',
|
|
65
68
|
showTime,
|
|
66
69
|
DayPickerProps,
|
|
@@ -73,8 +76,10 @@ export function FieldDate({
|
|
|
73
76
|
const [preventInputValueUpdates, setPreventInputValueUpdates] = useState(false)
|
|
74
77
|
const [prefixWidth, setPrefixWidth] = useState(0)
|
|
75
78
|
const dropdownRef = useRef<DropdownRef>(null)
|
|
76
|
-
const pattern = props.mode == 'time' ? 'hh:mmaa' : `d MMM yyyy${showTime && props.mode == 'single' ? ' hh:mmaa' : ''}`
|
|
77
79
|
const id = props.id || props.name
|
|
80
|
+
const pattern = patternProp || (
|
|
81
|
+
props.mode == 'time' ? 'hh:mmaa' : `d MMM yyyy${showTime && props.mode == 'single' ? ' hh:mmaa' : ''}`
|
|
82
|
+
)
|
|
78
83
|
|
|
79
84
|
// Since value and onChange are optional, we need need to create an internal value state
|
|
80
85
|
const [internalValue, setInternalValue] = useState<Timestamp[]>(() => preInternalValue(props))
|
|
@@ -159,14 +159,14 @@ function getInputClasses({ error, Icon, iconPos, type }: { error?: Error, Icon?:
|
|
|
159
159
|
const px = 'px-[12px]'
|
|
160
160
|
const py = 'py-[9px] py-input-y'
|
|
161
161
|
return (
|
|
162
|
-
'block col-start-1 row-start-1 w-full rounded-md bg-white text-input-base outline outline-1 -outline-offset-1 ' +
|
|
162
|
+
'block col-start-1 row-start-1 w-full rounded-md bg-white disabled:bg-input-disabled-bg text-input-base outline outline-1 -outline-offset-1 ' +
|
|
163
163
|
'placeholder:text-input-placeholder focus:outline focus:outline-2 focus:-outline-offset-2 ' + `${py} ${px} ` +
|
|
164
164
|
(iconPos == 'right' && Icon ? 'pr-[32px] pr-input-x-icon pl-input-x ' : '') +
|
|
165
165
|
(iconPos == 'left' && Icon ? 'pl-[32px] pl-input-x-icon pr-input-x ' : 'px-input-x ') +
|
|
166
166
|
(iconPos == 'left' && Icon && type == 'color' ? 'indent-[5px] ' : '') +
|
|
167
|
-
(error
|
|
168
|
-
? 'text-danger-foreground outline-danger focus:outline-danger '
|
|
169
|
-
: 'text-input outline-input-border focus:outline-input-border-focus ') +
|
|
167
|
+
(error
|
|
168
|
+
? 'text-danger-foreground outline-danger focus:outline-danger '
|
|
169
|
+
: 'text-input outline-input-border focus:outline-input-border-focus disabled:text-input-disabled ') +
|
|
170
170
|
(iconPos == 'right' ? 'justify-self-start ' : 'justify-self-end ') +
|
|
171
171
|
'nitro-input'
|
|
172
172
|
)
|
|
@@ -17,6 +17,7 @@ type GetSelectStyle = {
|
|
|
17
17
|
name: string
|
|
18
18
|
isFocused?: boolean
|
|
19
19
|
isSelected?: boolean
|
|
20
|
+
isDisabled?: boolean
|
|
20
21
|
hasError?: boolean
|
|
21
22
|
usePrefixes?: boolean
|
|
22
23
|
}
|
|
@@ -122,7 +123,7 @@ function SelectBase({
|
|
|
122
123
|
multiValueLabel: () => '',
|
|
123
124
|
multiValueRemove: () => getSelectStyle({ name: 'multiValueRemove' }),
|
|
124
125
|
placeholder: () => getSelectStyle({ name: 'placeholder' }),
|
|
125
|
-
singleValue: () => getSelectStyle({ name: 'singleValue', hasError: !!error }),
|
|
126
|
+
singleValue: (p) => getSelectStyle({ name: 'singleValue', hasError: !!error, isDisabled: p.isDisabled }),
|
|
126
127
|
// Indicators
|
|
127
128
|
clearIndicator: () => getSelectStyle({ name: 'clearIndicator' }),
|
|
128
129
|
dropdownIndicator: () => getSelectStyle({ name: 'dropdownIndicator' }),
|
|
@@ -267,6 +268,7 @@ const selectStyles = {
|
|
|
267
268
|
+ '!min-h-0 outline-input-border',
|
|
268
269
|
focus: 'outline-2 -outline-offset-2 outline-input-border-focus',
|
|
269
270
|
error: 'outline-danger',
|
|
271
|
+
disabled: 'cursor-not-allowed bg-input-disabled-bg',
|
|
270
272
|
},
|
|
271
273
|
valueContainer: 'py-[9px] px-[12px] py-input-y px-input-x gap-1', // dont twMerge (input-x is optional)
|
|
272
274
|
// Input container objects
|
|
@@ -281,6 +283,7 @@ const selectStyles = {
|
|
|
281
283
|
singleValue: {
|
|
282
284
|
base: 'text-input',
|
|
283
285
|
error: 'text-danger-foreground',
|
|
286
|
+
disabled: 'text-input-disabled',
|
|
284
287
|
},
|
|
285
288
|
// Icon indicators
|
|
286
289
|
clearIndicator: 'text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-danger-foreground',
|
|
@@ -298,7 +301,7 @@ const selectStyles = {
|
|
|
298
301
|
},
|
|
299
302
|
}
|
|
300
303
|
|
|
301
|
-
export function getSelectStyle({ name, isFocused, isSelected, hasError, usePrefixes }: GetSelectStyle) {
|
|
304
|
+
export function getSelectStyle({ name, isFocused, isSelected, isDisabled, hasError, usePrefixes }: GetSelectStyle) {
|
|
302
305
|
// Returns a class list that conditionally includes hover/focus modifier classes, or uses CSS modifiers, e.g. hover:, focus:
|
|
303
306
|
// @ts-expect-error
|
|
304
307
|
const obj = selectStyles[name]
|
|
@@ -314,7 +317,8 @@ export function getSelectStyle({ name, isFocused, isSelected, hasError, usePrefi
|
|
|
314
317
|
}
|
|
315
318
|
if (obj.error && hasError) output += ` ${obj.error}`
|
|
316
319
|
if (obj.selected && isSelected) output += ` ${obj.selected}`
|
|
317
|
-
|
|
320
|
+
if (obj.disabled && isDisabled) output += ` ${obj.disabled}`
|
|
321
|
+
|
|
318
322
|
return twMerge(output)
|
|
319
323
|
}
|
|
320
324
|
|
|
@@ -494,6 +494,17 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
494
494
|
onChange={(e) => onChange(e, setState)}
|
|
495
495
|
/>
|
|
496
496
|
</div>
|
|
497
|
+
<div>
|
|
498
|
+
<label for="action">Disabled</label>
|
|
499
|
+
<Select
|
|
500
|
+
name="action"
|
|
501
|
+
isDisabled={true}
|
|
502
|
+
options={useMemo(() => [
|
|
503
|
+
{ value: 'edit', label: 'Edit' },
|
|
504
|
+
{ value: 'delete', label: 'Delete' },
|
|
505
|
+
], [])}
|
|
506
|
+
/>
|
|
507
|
+
</div>
|
|
497
508
|
</div>
|
|
498
509
|
</div>
|
|
499
510
|
)}
|
|
@@ -547,9 +558,14 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
547
558
|
name="amount" type="currency" state={state} currency={state.currency || 'nzd'}
|
|
548
559
|
// Example of using a custom format and currencies, e.g.
|
|
549
560
|
format={'ยค#,##0.00'}
|
|
550
|
-
currencies={currencies}
|
|
561
|
+
currencies={currencies}
|
|
562
|
+
onChange={(e) => onChange(e, setState)}
|
|
551
563
|
/>
|
|
552
564
|
</div>
|
|
565
|
+
<div>
|
|
566
|
+
<label for="firstName">First Name (disabled)</label>
|
|
567
|
+
<Field name="firstName" state={state} onChange={(e) => onChange(e, setState)} disabled />
|
|
568
|
+
</div>
|
|
553
569
|
</div>
|
|
554
570
|
</div>
|
|
555
571
|
)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.190",
|
|
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 ๐",
|