nitro-web 0.3.16 → 0.3.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.
package/.eslintrc.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "ignorePatterns": ["resources/*", "!resources/migrations"],
2
3
  "extends": [
3
4
  "eslint:recommended",
4
5
  "plugin:react/recommended",
@@ -192,8 +192,12 @@ export const Dropdown = forwardRef(function Dropdown({
192
192
  e.stopPropagation()
193
193
  // Cancel parent <a> row navigation, unless a link INSIDE the menu was clicked
194
194
  // (closest() doesn't stop at the ul, so check the matched link is contained within it)
195
- const link = (e.target as HTMLElement).closest('a[href]')
196
- if (!link || !e.currentTarget.contains(link)) e.preventDefault()
195
+ // Only when there is a parent link, and never for form controls, whose default click toggles e.g. a checkbox
196
+ const target = e.target as HTMLElement
197
+ const link = target.closest('a[href]')
198
+ const hasParentLink = !!e.currentTarget.parentElement?.closest('a[href]')
199
+ const isControl = !!target.closest('input, label, select, textarea')
200
+ if (hasParentLink && !isControl && (!link || !e.currentTarget.contains(link))) e.preventDefault()
197
201
  }}
198
202
  style={{
199
203
  minWidth: minWidth,
@@ -201,7 +205,9 @@ export const Dropdown = forwardRef(function Dropdown({
201
205
  ...(maxHeight ? { overflow: 'auto' } : {}),
202
206
  }}
203
207
  class={twMerge(
204
- `${menuStyle} ${ready ? 'is-ready' : ''} absolute invisible opacity-0 select-none outline-none min-w-full z-[1] ${menuClassName||''}`
208
+ // cursor-default: the menu shouldn't inherit the pointer from a clickable row it happens to sit in
209
+ `${menuStyle} ${ready ? 'is-ready' : ''} absolute invisible opacity-0 select-none outline-none cursor-default `
210
+ + `min-w-full z-[1] ${menuClassName||''}`
205
211
  )}
206
212
  >
207
213
  {menuContent}
@@ -37,7 +37,7 @@ export type TableProps<T> = {
37
37
  rowLinesMax?: number
38
38
  rowSideColor?: (row: T|undefined, type: TableRowType) => { className: string, width: number }
39
39
  rowGap?: number
40
- rowOnClick?: (row: T) => void
40
+ rowOnClick?: (row: T, e: React.MouseEvent) => void // the event lets a caller tell a field click from a row click
41
41
  rowSelectable?: (row: T) => boolean // rows returning false get no checkbox and are skipped by select all
42
42
  rowLink?: (row: T) => string
43
43
  columnGap?: number
@@ -260,7 +260,9 @@ export function Table<T extends TableRow>({
260
260
  rowsToRender.map((row: T, i: number) => {
261
261
  const isSelected = selectedRowIds.includes(row._id || '')
262
262
  const Element = (rowLink ? Link : 'div') as React.ElementType
263
- const extraProps = rowLink ? { to: rowLink(row) } : { onClick: rowOnClick ? () => rowOnClick(row) : undefined }
263
+ const extraProps = rowLink
264
+ ? { to: rowLink(row) }
265
+ : { onClick: rowOnClick ? (e: React.MouseEvent) => rowOnClick(row, e) : undefined }
264
266
  return (
265
267
  <Element
266
268
  {...extraProps}
@@ -75,7 +75,7 @@ export function Checkbox({
75
75
  checked={value}
76
76
  className={
77
77
  twMerge(
78
- `${type === 'radio' ? 'rounded-full' : 'rounded'} appearance-none border border-input-border bg-input-bg forced-colors:appearance-auto disabled:border-input-border disabled:bg-input-disabled-bg disabled:checked:bg-input-disabled-bg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ` +
78
+ `${type === 'radio' ? 'rounded-full' : 'rounded'} appearance-none border border-input-border bg-checkbox-bg forced-colors:appearance-auto disabled:border-input-border disabled:bg-input-disabled-bg disabled:checked:bg-input-disabled-bg focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ` +
79
79
  // Variable-selected theme colors (was .*-blue-600)
80
80
  'checked:border-variable-selected checked:bg-variable-selected indeterminate:border-variable-selected indeterminate:bg-variable-selected focus-visible:outline-variable-selected ' +
81
81
  // Dark mode not used yet... dark:focus-visible:outline-blue-800
@@ -343,7 +343,7 @@ function SelectBase<IsMulti extends boolean = false>({
343
343
  },
344
344
  } : {})}
345
345
  />
346
- {error && <div class="mt-1.5 text-xs text-danger-foreground">{error.detail}</div>}
346
+ {error && <div class="mt-1.5 text-xs text-danger-foreground nitro-error">{error.detail}</div>}
347
347
  </div>
348
348
  )
349
349
  }
@@ -563,10 +563,10 @@ const selectClassNames = {
563
563
  disabled: 'text-input-disabled',
564
564
  },
565
565
  // Icon indicators
566
- clearIndicator: 'text-muted-foreground p-1 rounded-md hover:bg-red-50 hover:text-danger-foreground ml-[-0.8em]',
566
+ clearIndicator: 'text-muted-foreground p-1 rounded-md hover:bg-danger/10 hover:text-danger-foreground ml-[-0.8em]',
567
567
  dropdownIndicator: 'p-1 hover:bg-accent text-muted-foreground rounded-md hover:text-foreground',
568
568
  indicatorsContainer: 'p-1 pl-0 pr-2 gap-1 relative', // relative so the hitbox goes over the control
569
- indicatorSeparator: 'py-0.5 before:content-[""] before:block before:bg-accent before:w-px before:h-full',
569
+ indicatorSeparator: 'py-0.5 before:content-[""] before:block before:bg-input-separator before:w-px before:h-full',
570
570
  // Dropdown menu
571
571
  menu: 'mt-1.5 border border-dropdown-ul-border bg-surface rounded-md text-input-base overflow-hidden shadow-dropdown-ul',
572
572
  groupHeading: 'ml-3 mt-2 mb-1 text-muted-foreground text-input-base',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
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/tailwind.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import plugin from 'tailwindcss/plugin'
2
2
 
3
3
  /**
4
- * Nitro theme plugin. Every key in light/dark becomes a CSS variable (:root / .dark) and a tailwind colour,
4
+ * Nitro theme plugin. Every key in light/dark becomes a CSS variable (:root and .light / .dark) and a tailwind colour,
5
5
  * e.g. 'surface' -> --surface, bg-surface, text-surface/50. Anything omitted uses the defaults below, and you
6
6
  * can add your own keys.
7
7
  * plugins: [nitroTheme({ dark: { 'primary-text': '#818cf8' } })]
@@ -19,7 +19,9 @@ export const themeDefaults = {
19
19
  'input-placeholder': '#9ca3af', // gray-400
20
20
  'input-disabled': '#9ca3af',
21
21
  'input-bg': '#ffffff',
22
+ 'input-separator': '#f3f4f6', // select divider before the arrow (gray-100)
22
23
  'input-disabled-bg': '#f3f4f6', // gray-100
24
+ 'checkbox-bg': '#ffffff',
23
25
  'overlay': '#6b7280', // used with opacity, e.g. bg-overlay/70
24
26
  'primary-text': undefined, // primary used as text, defaults to colors.primary
25
27
  'initials': ['#067306', '#aa33ff', '#ff54af', '#f44336', '#c03c3c', '#5451e0', '#d88c1b'], // <Initials /> palette
@@ -36,7 +38,9 @@ export const themeDefaults = {
36
38
  'input-placeholder': '#71717a', // zinc-500
37
39
  'input-disabled': '#71717a',
38
40
  'input-bg': '#1c1c1f',
41
+ 'input-separator': '#303035',
39
42
  'input-disabled-bg': '#27272a',
43
+ 'checkbox-bg': '#1c1c1f',
40
44
  'overlay': '#000000',
41
45
  'primary-text': undefined,
42
46
  'initials': ['#4ade80', '#c084fc', '#f472b6', '#f87171', '#fb923c', '#818cf8', '#facc15'],
@@ -74,7 +78,8 @@ export default function nitroTheme(options = {}) {
74
78
  }
75
79
  return out
76
80
  }
77
- addBase({ ':root': vars('light'), '.dark': vars('dark') })
81
+ // .light lets a light area sit inside a dark one, e.g. a white menu in a dark row
82
+ addBase({ ':root, .light': vars('light'), '.dark': vars('dark') })
78
83
  }, {
79
84
  theme: { extend: { colors } },
80
85
  })