nitro-web 0.0.109 → 0.0.111

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.
@@ -81,4 +81,18 @@
81
81
 
82
82
  .__PrivateStripeElementLoader {
83
83
  display: none !important;
84
+ }
85
+
86
+ /* ---- Animation ------------------------- */
87
+
88
+ @keyframes dots {
89
+ 0%, 20% { content: ""; }
90
+ 40% { content: "."; }
91
+ 60% { content: ".."; }
92
+ 80%, 100% { content: "..."; }
93
+ }
94
+
95
+ .loading-dots::after {
96
+ content: "";
97
+ animation: dots 2s steps(1, end) infinite;
84
98
  }
@@ -42,6 +42,7 @@ export type TableProps<T> = {
42
42
  columnHeaderClassName?: string
43
43
  checkboxClassName?: string
44
44
  checkboxSize?: number
45
+ isLoading?:boolean
45
46
  }
46
47
 
47
48
  export function Table<T extends TableRow>({
@@ -67,6 +68,7 @@ export function Table<T extends TableRow>({
67
68
  columnHeaderClassName,
68
69
  checkboxClassName,
69
70
  checkboxSize=16,
71
+ isLoading=false,
70
72
  }: TableProps<T>) {
71
73
  const location = useLocation()
72
74
  const [selectedRowIds, setSelectedRowIds] = useState<string[]>([])
@@ -87,7 +89,7 @@ export function Table<T extends TableRow>({
87
89
 
88
90
  const onSelect = useCallback((idOrAll: string, checked: boolean) => {
89
91
  setSelectedRowIds((o) => {
90
- if (idOrAll == 'all' && checked) return rows.map(row => row?._id||'')
92
+ if (idOrAll == 'all' && checked) return (rows ?? []).map(row => row?._id||'')
91
93
  else if (idOrAll == 'all' && !checked) return []
92
94
  else if (o.includes(idOrAll) && !checked) return o.filter(id => id != idOrAll)
93
95
  else if (!o.includes(idOrAll) && checked) return [...o, idOrAll]
@@ -101,7 +103,7 @@ export function Table<T extends TableRow>({
101
103
  }, [])
102
104
 
103
105
  // Reset selected rows when the location changes, or the number of rows changed (e.g. when a row is removed)
104
- useEffect(() => setSelectedRowIds([]), [location.key, rows.map(row => row?._id||'').join(',')])
106
+ useEffect(() => setSelectedRowIds([]), [location.key, (rows ?? []).map(row => row?._id||'').join(',')])
105
107
 
106
108
  // --- Sorting ---
107
109
 
@@ -287,11 +289,12 @@ export function Table<T extends TableRow>({
287
289
  >
288
290
  <div
289
291
  className={twMerge(
290
- 'absolute top-0 h-full flex items-center justify-center text-sm text-gray-500',
292
+ 'absolute top-0 h-full flex items-center justify-center text-sm',
293
+ isLoading ? '' : 'text-gray-500',
291
294
  col.innerClassName
292
295
  )}
293
296
  >
294
- { j == 0 && 'No records found.' }
297
+ { j == 0 && (isLoading ? <>Loading<span className="relative ml-[2px] loading-dots" /></> : 'No records found.') }
295
298
  </div>
296
299
  </div>
297
300
  )
@@ -98,6 +98,16 @@ export function FieldCurrency({ currency='nzd', currencies, format, onChange, va
98
98
  let _format = format || defaultFormat
99
99
  const _currencies = currencies ?? defaultCurrencies
100
100
  const currencyObject = _currencies[currency as keyof typeof _currencies]
101
+ if (!currencyObject && currencies) {
102
+ console.error(
103
+ `The currency field "${props.name}" is using the currency "${currency}" which is not found in your currencies object`
104
+ )
105
+ } else if (!currencyObject && !currencies) {
106
+ console.error(
107
+ `The currency field "${props.name}" is using the currency "${currency}" which is not found in the
108
+ default currencies, please provide a currencies object.`
109
+ )
110
+ }
101
111
  const symbol = currencyObject ? currencyObject.symbol : ''
102
112
  const digits = currencyObject ? currencyObject.digits : 2
103
113
 
@@ -160,13 +170,59 @@ export function FieldCurrency({ currency='nzd', currencies, format, onChange, va
160
170
  )
161
171
  }
162
172
 
163
- const defaultCurrencies = {
164
- nzd: { symbol: '$', digits: 2 },
165
- aud: { symbol: '$', digits: 2 },
166
- usd: { symbol: '$', digits: 2 },
167
- eur: { symbol: '', digits: 2 },
168
- gbp: { symbol: '£', digits: 2 },
169
- btc: { symbol: '', digits: 8 },
173
+ export const defaultCurrencies: { [key: string]: { name: string, symbol: string, digits: number } } = {
174
+ nzd: { name: 'New Zealand Dollar', symbol: '$', digits: 2 },
175
+ aud: { name: 'Australian Dollar', symbol: '$', digits: 2 },
176
+ usd: { name: 'US Dollar', symbol: '$', digits: 2 },
177
+ btc: { name: 'Bitcoin', symbol: '', digits: 8 },
178
+ aed: { name: 'UAE Dirham', symbol: 'د.إ', digits: 2 },
179
+ ars: { name: 'Argentine Peso', symbol: '$', digits: 2 },
180
+ bdt: { name: 'Bangladeshi Taka', symbol: '৳', digits: 2 },
181
+ bhd: { name: 'Bahraini Dinar', symbol: '.د.ب', digits: 3 },
182
+ brl: { name: 'Brazilian Real', symbol: 'R$', digits: 2 },
183
+ cad: { name: 'Canadian Dollar', symbol: '$', digits: 2 },
184
+ chf: { name: 'Swiss Franc', symbol: 'Fr', digits: 2 },
185
+ clp: { name: 'Chilean Peso', symbol: '$', digits: 0 },
186
+ cny: { name: 'Chinese Yuan', symbol: '¥', digits: 2 },
187
+ cop: { name: 'Colombian Peso', symbol: '$', digits: 2 },
188
+ czk: { name: 'Czech Koruna', symbol: 'Kč', digits: 2 },
189
+ dkk: { name: 'Danish Krone', symbol: 'kr', digits: 2 },
190
+ egp: { name: 'Egyptian Pound', symbol: '£', digits: 2 },
191
+ eur: { name: 'Euro', symbol: '€', digits: 2 },
192
+ gbp: { name: 'Great Britain Pound', symbol: '£', digits: 2 },
193
+ hkd: { name: 'Hong Kong Dollar', symbol: '$', digits: 2 },
194
+ huf: { name: 'Hungarian Forint', symbol: 'Ft', digits: 0 },
195
+ idr: { name: 'Indonesian Rupiah', symbol: 'Rp', digits: 0 },
196
+ ils: { name: 'Israeli Shekel', symbol: '₪', digits: 2 },
197
+ inr: { name: 'Indian Rupee', symbol: '₹', digits: 2 },
198
+ jod: { name: 'Jordanian Dinar', symbol: 'د.ا', digits: 3 },
199
+ jpy: { name: 'Japanese Yen', symbol: '¥', digits: 0 },
200
+ kes: { name: 'Kenyan Shilling', symbol: 'Sh', digits: 2 },
201
+ krw: { name: 'South Korean Won', symbol: '₩', digits: 0 },
202
+ kwd: { name: 'Kuwaiti Dinar', symbol: 'د.ك', digits: 3 },
203
+ lkr: { name: 'Sri Lankan Rupee', symbol: 'Rs', digits: 2 },
204
+ mad: { name: 'Moroccan Dirham', symbol: 'د.م.', digits: 2 },
205
+ mxn: { name: 'Mexican Peso', symbol: '$', digits: 2 },
206
+ myr: { name: 'Malaysian Ringgit', symbol: 'RM', digits: 2 },
207
+ ngn: { name: 'Nigerian Naira', symbol: '₦', digits: 2 },
208
+ nok: { name: 'Norwegian Krone', symbol: 'kr', digits: 2 },
209
+ omr: { name: 'Omani Rial', symbol: '﷼', digits: 3 },
210
+ pen: { name: 'Peruvian Sol', symbol: 'S/', digits: 2 },
211
+ php: { name: 'Philippine Peso', symbol: '₱', digits: 2 },
212
+ pkt: { name: 'Pakistani Rupee', symbol: '₨', digits: 2 },
213
+ pln: { name: 'Polish Zloty', symbol: 'zł', digits: 2 },
214
+ qar: { name: 'Qatari Riyal', symbol: '﷼', digits: 2 },
215
+ ron: { name: 'Romanian Leu', symbol: 'lei', digits: 2 },
216
+ rub: { name: 'Russian Ruble', symbol: '₽', digits: 2 },
217
+ sar: { name: 'Saudi Riyal', symbol: '﷼', digits: 2 },
218
+ sek: { name: 'Swedish Krona', symbol: 'kr', digits: 2 },
219
+ sgd: { name: 'Singapore Dollar', symbol: '$', digits: 2 },
220
+ thb: { name: 'Thai Baht', symbol: '฿', digits: 2 },
221
+ try: { name: 'Turkish Lira', symbol: '₺', digits: 2 },
222
+ twd: { name: 'New Taiwan Dollar', symbol: 'NT$', digits: 2 },
223
+ uah: { name: 'Ukrainian Hryvnia', symbol: '₴', digits: 2 },
224
+ vnd: { name: 'Vietnamese Dong', symbol: '₫', digits: 0 },
225
+ zar: { name: 'South African Rand', symbol: 'R', digits: 2 },
170
226
  }
171
227
 
172
228
  const defaultFormat = '¤#,##0.00'
@@ -505,6 +505,15 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
505
505
  generateTd={generateTd}
506
506
  className="mb-6"
507
507
  />
508
+ <Table
509
+ rows={[]}
510
+ columns={thead}
511
+ rowSideColor={(row) => ({ className: row?.status == 'pending' ? 'bg-yellow-400' : '', width: 5 })}
512
+ generateCheckboxActions={generateCheckboxActions}
513
+ generateTd={generateTd}
514
+ className="mb-6"
515
+ isLoading={true}
516
+ />
508
517
  <Table
509
518
  rows={rows.slice(0, 2).map(row => ({ ...row, _id: row._id + '1' }))}
510
519
  columns={thead}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.109",
3
+ "version": "0.0.111",
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 🚀",