@xeplr/ui-utils 1.1.7 → 1.1.9

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/README.md CHANGED
@@ -95,7 +95,7 @@ export default function SelectCompany() {
95
95
  | `RangeFieldPage` | [see below](#rangefieldpage) | A From and a To date input drawn as one field, each bounded by the other |
96
96
  | `DateFieldPage` | [see below](#datefieldpage) | Date, datetime, or date of birth with the age computed |
97
97
  | `NumberFieldPage` | [see below](#numberfieldpage) | Float, currency or units input with an affix picker |
98
- | `TextFieldPage` | [see below](#textfieldpage) | Text, multiline or search input, themed by `--xeplr-input-text-*` |
98
+ | `TextFieldPage` | [see below](#textfieldpage) | Text, multiline, search or password input, themed by `--xeplr-input-text-*` |
99
99
  | `FileUploadPage` | [see below](#fileuploadpage) | Drag-and-drop upload with type and size checks and a progress bar |
100
100
  | `ImportsPage` | [see below](#importspage) | The whole import screen against `@xeplr/imports`: database picker, import, progress, history |
101
101
  | `DataImportPage` | [see below](#dataimportpage) | Upload a file, map its parts to targets, commit |
@@ -128,7 +128,8 @@ export default function SelectCompany() {
128
128
  | `useColorPickerController(props)` | ColorPickerPage props | `label, value, hex, opacity, swatches [{color, selected}], custom, allowNone, allowOpacity, previewText, pick(hex), setOpacity(0–100), clear` |
129
129
  | `useExpandersController(props)` | ExpandersPage props | `items` (each with `open`), `toggle(key)` |
130
130
  | `useSettingsTreeController(props)` | SettingsTreePage props | `nodes` (each with `open`, `depth`, `parentKey`, `children`), `toggle(parentKey, key)` |
131
- | `useDesignValidator(name, rules)` | page name, rule list | a ref for the design's container |
131
+ | `useDesignValidator(name, rules)` | page name, rule list | a ref for the design's container (reports, lets it load) |
132
+ | `useDesignCheck(rules, state)` | rule list (with `when`), the state `when` reads | `{ ref, missing }`: render an error instead of the design while `missing` is not empty |
132
133
 
133
134
  ### Model functions (no React)
134
135
 
@@ -144,7 +145,7 @@ export default function SelectCompany() {
144
145
  | `RANGE_TYPES`, `emptyRange`, `normalizeRange`, `rangeIsSet` | `['date','datetime']`, `() → {from:'',to:''}`, `(r) → {from,to}`, `(r) → boolean` | From/to helpers. A range with one side set counts as set. |
145
146
  | `DATE_TYPES`, `isValidISODate`, `calculateAge`, `inputTypeFor`, `toInputValue`, `validateBounds` | `['date','datetime','age']`, `(s)`, `(dob, now?)`, `(type)`, `(value, type)`, `(value, min, max) → { valid, error? }` | Date field helpers |
146
147
  | `NUMBER_TYPES`, `sanitizeNumberInput`, `toNumeric`, `formatDisplay`, `validateRange`, `resolveAffixState` | `['float','currency','units']`, `(raw)`, `(raw) → number \| null`, `(value, decimals?)`, `(value, min, max) → { valid, error? }`, `(type, options)` | Number field helpers. `sanitizeNumberInput` keeps digits, the first `.`, and a leading `-`. |
147
- | `TEXT_TYPES`, `toValue`, `normalise`, `validate`, `remaining` | `['text','multiline','search']`, `(raw) → string`, `(raw, { trim, maxLength })`, `(raw, { required, requiredMessage, minLength, maxLength, pattern, patternMessage }) → string \| null`, `(raw, maxLength) → number \| null` | Text field helpers |
148
+ | `TEXT_TYPES`, `toValue`, `normalise`, `validate`, `remaining` | `['text','multiline','search','password']`, `(raw) → string`, `(raw, { trim, maxLength })`, `(raw, { required, requiredMessage, minLength, maxLength, pattern, patternMessage }) → string \| null`, `(raw, maxLength) → number \| null` | Text field helpers |
148
149
  | `DROPDOWN_MODES`, `normalizeKeys`, `sortByKey`, `filterByQuery`, `pickSelected` | `['single','multi']`, `(keys) → { id, name, extras }`, `(items, key)`, `(items, query, searchKeys)`, `(items, ids, idKey)` | Dropdown helpers |
149
150
  | `DEFAULT_SWATCHES`, `parseColor`, `formatColor`, `sameHue` | `[hex]`, `(css) → { hex, opacity } \| null`, `(hex, opacity) → css \| null`, `(a, b) → boolean` | Colour helpers. Opacity 100 writes `#RRGGBB`; anything less writes `#RRGGBBAA`. |
150
151
  | `toggleOpen`, `initialOpen` | `(open, key, multiple?) → keys`, `(items, initial?, multiple?) → keys` | Which expanders are open |
@@ -226,6 +227,7 @@ url.set({ widget: id, drawer: null })
226
227
  | `onClose` | `() => void` | — | Called after a choice that ends the interaction: a preset, a suggestion, Apply (or Enter) in Range or Single, or Clear |
227
228
  | `presets` | `[{ key, label }]` | `QUICK_PRESETS` | The Quick list. Only keys that `resolveQuickPreset` knows will resolve. |
228
229
  | `allowClear` | `boolean` | `true` | `false` removes the Clear button, and `clear()` refuses too |
230
+ | `withTime` | `boolean` | `false` | The Range tab's From and To take a time too (`datetime-local`, `"2026-11-12T09:30"`), for what is read by the minute, such as a log. The label reads `2026-11-12 09:30 → …`; From after To is caught to the minute. Presets and Single still name whole days |
229
231
  | `inheritedLabel` | `string` | — | Shows "Using …" when `value` is empty |
230
232
 
231
233
  **Every selection resolves to `{ from, to }`, including a single date.** "May 2022" becomes 1–31 May and "2022" becomes the whole year, so a consumer never has to ask which comparison was meant. **The Range tab is applied, not taken as you type.** A browser date input holds a complete date while a year is half typed (`2` is `0002-01-01`), so committing each edit ran the host's query for the year 2. The inputs edit a draft, and `onChange` fires once, on **Apply** or Enter. Apply is disabled until the draft is valid (`rangeProblem`: something chosen, From not after To) and differs from what is applied. One open side is allowed. The Single tab commits only once the text parses ("Not a date yet" otherwise), on blur, Enter or Apply. While you type, it suggests months and years, putting the committed year first. The financial-year presets use `fiscalStartMonth` (default April). The page itself does not pass that option, so change it by calling `resolveDateValue(value, now, { fiscalStartMonth })` where you consume the value.
@@ -275,7 +277,7 @@ The input is `type="text" inputMode="decimal"`. Typing is sanitised. An affix li
275
277
 
276
278
  | prop | type | default | meaning |
277
279
  |---|---|---|---|
278
- | `type` | `'text' \| 'multiline' \| 'search'` | `'text'` | Any other value throws |
280
+ | `type` | `'text' \| 'multiline' \| 'search' \| 'password'` | `'text'` | `'password'` is masked. Any other value throws |
279
281
  | `value` / `defaultValue` | `string` | — | Controlled / uncontrolled. `null` and `undefined` become `''`. |
280
282
  | `onChange` | `(value) => void` | — | Every keystroke |
281
283
  | `onCommit` | `(value) => void` | — | On blur, or Enter in a single-line field, after `trim` / `maxLength` are applied |
@@ -326,6 +328,8 @@ configureUpload({ url: API_BASE + '/imports/files', getHeaders }) // once, at
326
328
  |---|---|---|
327
329
  | `basePath` | `string` | Where the app mounted the router, as the browser sees it (default `'/imports'`) |
328
330
  | `pollMs` | `number` | How often a running import is asked how far it has got (default 1000) |
331
+ | `upload` | `(file, onProgress(percent), { standard }) => Promise<{ filePath }>` | Optional: the app's own way to send a file. It decides per file — `standard(file, onProgress)` is the usual one request to `/files`; a file too big for one request can be sent another way (in pieces, say) into the tenant's `uploads/` folder, and the answer's `filePath` is imported like any other. Xeplr BI sends files over 200 MB in chunks this way, on Pro and up (`importsApi.js` `uploaderFor`) |
332
+ | `accept` | `string` | The file input's `accept` (default `ACCEPT`: `.csv,.json,.xlsx,.xls,.parquet`) |
329
333
 
330
334
  It shows three things:
331
335
 
@@ -336,7 +340,7 @@ It shows three things:
336
340
  Requests carry the headers `configureUpload` was given (`uploadHeaders()`), so sign-in and tenancy need no second setup. The model is `importsApi.js`:
337
341
 
338
342
  - `createImportsApi(basePath)` makes every route call.
339
- - Pure helpers: `importProgressText`, `runResults`, `historyJob`, `databasesOf`, `fileNameOf`.
343
+ - Pure helpers: `importProgressText`, `runResults`, `historyJob`, `databasesOf`, `fileNameOf`, `uploaderFor(api, upload)` (how a picked file is sent), `ACCEPT` (exported as `IMPORT_ACCEPT`: the files it reads, Parquet among them).
340
344
 
341
345
  A custom design receives the controller's values plus `importSection` and `historySection` as elements.
342
346
 
@@ -552,6 +556,22 @@ These create their own DOM nodes with inline styles, so they need no provider, m
552
556
 
553
557
  `useDesignValidator(name, rules)` returns a ref. After mount it checks, **once**, that the container has each required element. A rule is `{ id | role | selector | anyOf: [selectors], label }`. For every rule that fails it logs `[xeplr-ui-utils] <name> design is missing required elements: …` with `console.error`, and it sets `data-xeplr-design-invalid="<name>"` and a `title` on the container.
554
558
 
559
+ ### A design that must not load without its controls: `useDesignCheck`
560
+
561
+ `useDesignValidator` reports and lets the design load. For a page whose design must **not** load without its controls (a sign-in without a password box, a monitor without its Restart button), use `useDesignCheck(rules, state)`:
562
+
563
+ ```jsx
564
+ import { useDesignCheck } from '@xeplr/ui-utils'
565
+
566
+ const check = useDesignCheck(LOGIN_RULES, controller)
567
+ if (check.missing.length) return <Broken missing={check.missing} /> // your own error view
568
+ return <div ref={check.ref}><Design {...controller} /></div>
569
+ ```
570
+
571
+ - Rules are the same shapes as above, plus **`when(state)`**: checked only while it holds (`{ selector: '#code', label: 'Code input', when: (c) => c.needsCode }`).
572
+ - Checked after **every** render, since `when` depends on what is open. Once something is missing it stays missing, and the page shows the error rather than a design that half works.
573
+ - `missingFrom(root, rules, state)` is the same check with no React: the labels of the broken rules.
574
+
555
575
  | rules | require |
556
576
  |---|---|
557
577
  | `DROPDOWN_RULES` | `.xeplr-dropdown-trigger` or `[role="combobox"]`; `.xeplr-dropdown-panel` or `[role="listbox"]` |
@@ -559,7 +579,7 @@ These create their own DOM nodes with inline styles, so they need no provider, m
559
579
  | `RANGE_FIELD_RULES` | `.xeplr-rangefield-field` |
560
580
  | `DATE_FIELD_RULES` | `input[type="date"]`, `input[type="datetime-local"]` or `.xeplr-datefield-input` |
561
581
  | `NUMBER_FIELD_RULES` | `input[inputmode="decimal"]` or `input.xeplr-numberfield-input` |
562
- | `TEXT_FIELD_RULES` | a text or search input, a `textarea`, or `.xeplr-textfield-input` |
582
+ | `TEXT_FIELD_RULES` | a text, search or password input, a `textarea`, or `.xeplr-textfield-input` |
563
583
  | `FILE_UPLOAD_RULES` | `input[type="file"]`; `.xeplr-upload-dropzone` or `[role="dropzone"]`; a `button` |
564
584
  | `IMPORTS_RULES` | `#xeplr-imports-connection`, `#xeplr-imports-database` |
565
585
  | `DATA_IMPORT_RULES` | `input[type="file"]` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeplr/ui-utils",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "UI utility components: file upload with progress, snackbar, static data (countries/states)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -246,15 +246,18 @@ export function resolveDateValue(value, now, options) {
246
246
  return null
247
247
  }
248
248
 
249
+ // A range with times (DateRange withTime) reads "2026-11-12 09:30", not "…T09:30".
250
+ function shown(v) { return String(v).replace('T', ' ') }
251
+
249
252
  /** What the chip and the panel read. */
250
253
  export function dateValueLabel(value) {
251
254
  if (!value) return null
252
255
  if (value.kind === 'quick') return PRESET_LABEL.get(value.preset) || value.preset
253
256
  if (value.kind === 'single') return value.value || null
254
257
  if (value.kind === 'range') {
255
- if (value.from && value.to) return `${value.from} → ${value.to}`
256
- if (value.from) return `From ${value.from}`
257
- if (value.to) return `Until ${value.to}`
258
+ if (value.from && value.to) return `${shown(value.from)} → ${shown(value.to)}`
259
+ if (value.from) return `From ${shown(value.from)}`
260
+ if (value.to) return `Until ${shown(value.to)}`
258
261
  return null
259
262
  }
260
263
  return null
@@ -61,12 +61,12 @@ export default function DateRangeSample(props) {
61
61
  the year 2. Enter in either input applies too. */}
62
62
  <label className="xeplr-daterange-field">
63
63
  <span>From</span>
64
- <input type="date" value={props.range.from || ''} onChange={function(e) { props.setRangeFrom(e.target.value); }}
64
+ <input type={props.withTime ? 'datetime-local' : 'date'} value={props.range.from || ''} onChange={function(e) { props.setRangeFrom(e.target.value); }}
65
65
  onKeyDown={function(e) { if (e.key === 'Enter') { e.preventDefault(); props.applyRange(); } }} />
66
66
  </label>
67
67
  <label className="xeplr-daterange-field">
68
68
  <span>To</span>
69
- <input type="date" value={props.range.to || ''} onChange={function(e) { props.setRangeTo(e.target.value); }}
69
+ <input type={props.withTime ? 'datetime-local' : 'date'} value={props.range.to || ''} onChange={function(e) { props.setRangeTo(e.target.value); }}
70
70
  onKeyDown={function(e) { if (e.key === 'Enter') { e.preventDefault(); props.applyRange(); } }} />
71
71
  </label>
72
72
  {/* One-sided is legitimate — "everything since April" is a real
@@ -13,6 +13,9 @@ import { QUICK_PRESETS, parseSingleDate, dateValueLabel, singleDateSuggestions,
13
13
  * @param {boolean} [props.allowClear] - default true. Set false where an
14
14
  * empty selection is not a state the host can accept — a report bounded by
15
15
  * a date, say, for which "no date" means scanning all of history.
16
+ * @param {boolean} [props.withTime] - default false. The From/To of a range
17
+ * take a time too ("2026-11-12T09:30"), for what is read by the minute, such
18
+ * as a log. Presets and Single still name whole days.
16
19
  */
17
20
  export function useDateRangeController(props) {
18
21
  var value = props.value || null;
@@ -138,6 +141,7 @@ export function useDateRangeController(props) {
138
141
  commitSingle: commitSingle,
139
142
  clear: clear,
140
143
  allowClear: allowClear,
144
+ withTime: Boolean(props.withTime),
141
145
  inheritedLabel: props.inheritedLabel || null
142
146
  };
143
147
  }
@@ -13,6 +13,7 @@ export var DATE_RANGE_RULES = [
13
13
  '.xeplr-daterange-list button',
14
14
  '[data-xeplr-daterange-preset]',
15
15
  'input[type="date"]',
16
+ 'input[type="datetime-local"]',
16
17
  '.xeplr-daterange-input'
17
18
  ],
18
19
  label: 'A way to pick a date — a quick preset list, or a date input'
@@ -0,0 +1,48 @@
1
+ /**
2
+ * DesignCheck — model. Which required elements a rendered design is missing.
3
+ * Pure: it only calls querySelector on the root it is given.
4
+ *
5
+ * The BLOCKING check, for a page whose design must not load without its
6
+ * controls: the page renders an error naming what is missing INSTEAD of the
7
+ * design (useDesignCheck). useDesignValidator (fileUpload/validateDesign.js)
8
+ * is the other kind — it reports and lets the design load — and stays as it is.
9
+ *
10
+ * Rules take the same shapes as useDesignValidator's, plus `when`:
11
+ * { id: 'x-email', label: 'Email input' }
12
+ * { role: 'listbox', label: '…' }
13
+ * { selector: 'button[type="submit"]', label: '…' }
14
+ * { anyOf: ['#a', '#b'], label: '…' }
15
+ * { selector: '#x-code', label: '…', when: (c) => c.needsCode } // only while that holds
16
+ */
17
+
18
+ /** The selector a rule looks for, or a list of them for anyOf. */
19
+ export function ruleSelectors(rule) {
20
+ if (rule.id) return ['#' + rule.id];
21
+ if (rule.role) return ['[role="' + rule.role + '"]'];
22
+ if (rule.anyOf) return rule.anyOf.slice();
23
+ if (rule.selector) return [rule.selector];
24
+ return [];
25
+ }
26
+
27
+ /** Whether a rule is checked now: always, or while its `when(state)` holds. */
28
+ export function ruleApplies(rule, state) {
29
+ return !rule.when || Boolean(rule.when(state));
30
+ }
31
+
32
+ /** What a missing rule is called: its label and where it was looked for. */
33
+ export function ruleLabel(rule) {
34
+ var where = rule.id ? ' (id="' + rule.id + '")'
35
+ : rule.anyOf ? ' (one of: ' + rule.anyOf.join(', ') + ')'
36
+ : rule.selector ? ' (' + rule.selector + ')'
37
+ : rule.role ? ' (role="' + rule.role + '")' : '';
38
+ return rule.label + where;
39
+ }
40
+
41
+ /** The labels of the rules `root` breaks, given the page's `state` for `when`. [] when none. */
42
+ export function missingFrom(root, rules, state) {
43
+ if (!root) return [];
44
+ return (rules || []).filter(function(rule) {
45
+ if (!ruleApplies(rule, state)) return false;
46
+ return !ruleSelectors(rule).some(function(s) { return root.querySelector(s); });
47
+ }).map(ruleLabel);
48
+ }
@@ -0,0 +1,31 @@
1
+ import { useLayoutEffect, useRef, useState } from 'react';
2
+ import { missingFrom } from './designCheck.js';
3
+
4
+ /**
5
+ * DesignCheck — controller. Checks the design after EVERY render (rules with
6
+ * `when` depend on what is open), and once something is missing, keeps it
7
+ * missing: the page shows the error, not a design that half works.
8
+ *
9
+ * var check = useDesignCheck(LOGIN_RULES, controller)
10
+ * if (check.missing.length) return <MyBroken missing={check.missing} />
11
+ * return <div ref={check.ref}><Design {...controller} /></div>
12
+ *
13
+ * @param {Array} rules - see designCheck.js
14
+ * @param {any} state - what `when` is asked about (usually the controller)
15
+ * @returns {{ ref, missing: string[] }}
16
+ */
17
+ export function useDesignCheck(rules, state) {
18
+ var ref = useRef(null);
19
+ var missingState = useState([]);
20
+ var missing = missingState[0];
21
+ var setMissing = missingState[1];
22
+ useLayoutEffect(function() {
23
+ if (missing.length) return;
24
+ var m = missingFrom(ref.current, rules, state);
25
+ if (m.length) {
26
+ console.error('[xeplr-ui-utils] design is missing required elements:\n' + m.map(function(x) { return ' - ' + x; }).join('\n'));
27
+ setMissing(m);
28
+ }
29
+ });
30
+ return { ref: ref, missing: missing };
31
+ }
@@ -7,6 +7,22 @@
7
7
 
8
8
  import { uploadFile, uploadHeaders } from '../fileUpload/uploadFile.js';
9
9
 
10
+ /**
11
+ * How a picked file is sent: the app's own `upload` when it gives one —
12
+ * handed the file, the progress callback and the standard sender, so it can
13
+ * keep the standard one for most files and send a big one its own way (in
14
+ * pieces, say) — else the standard: one request to /files. Either answers
15
+ * { filePath } inside the tenant's uploads/ folder, which is all the import
16
+ * needs.
17
+ */
18
+ export function uploaderFor(api, upload) {
19
+ if (typeof upload !== 'function') return function(file, onProgress) { return api.upload(file, onProgress); };
20
+ return function(file, onProgress) { return upload(file, onProgress, { standard: api.upload }); };
21
+ }
22
+
23
+ /** The files the import reads, for the file input. */
24
+ export var ACCEPT = '.csv,.json,.xlsx,.xls,.parquet';
25
+
10
26
  /** The import routes under one base path. Every call rejects with the server's own `error`. */
11
27
  export function createImportsApi(basePath) {
12
28
  var base = String(basePath || '/imports').replace(/\/+$/, '');
@@ -1,4 +1,5 @@
1
1
  import { useImportsController } from './useImportsController.js';
2
+ import { ACCEPT } from './importsApi.js';
2
3
  import ImportsSample from './designs/ImportsSample.jsx';
3
4
  import { IMPORTS_RULES } from './validateDesign.js';
4
5
  import { useDesignValidator } from '../dataImport/validateDesign.js';
@@ -17,7 +18,7 @@ export function ImportsPage(props) {
17
18
  return (
18
19
  <div ref={ref}>
19
20
  <ImportsSample {...c}
20
- importSection={<DataImportPage accept=".csv,.json,.xlsx,.xls" targetLabel="Table name" {...c.importProps} />}
21
+ importSection={<DataImportPage accept={props.accept || ACCEPT} targetLabel="Table name" {...c.importProps} />}
21
22
  historySection={<ImportHistoryPage key={c.historyVersion} {...c.historyProps} />} />
22
23
  </div>
23
24
  );
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { createImportsApi, importProgressText, runResults, historyJob, databasesOf } from './importsApi.js';
2
+ import { createImportsApi, importProgressText, runResults, historyJob, databasesOf, uploaderFor } from './importsApi.js';
3
3
 
4
4
  /**
5
5
  * The whole import screen against @xeplr/imports' routes: which database,
@@ -10,6 +10,7 @@ import { createImportsApi, importProgressText, runResults, historyJob, databases
10
10
  * @param {object} props
11
11
  * @param {string} [props.basePath='/imports'] - where the app mounted the router, as the browser sees it
12
12
  * @param {number} [props.pollMs=1000] - how often a running import is asked how far it has got
13
+ * @param {(file, onProgress, { standard }) => Promise<{ filePath }>} [props.upload] - the app's own way to send a file (see uploaderFor)
13
14
  */
14
15
  export function useImportsController(props = {}) {
15
16
  var api = useMemo(function() { return createImportsApi(props.basePath); }, [props.basePath]);
@@ -42,7 +43,8 @@ export function useImportsController(props = {}) {
42
43
  setDbInfoId((databasesOf(targets, id)[0] || {}).id || '');
43
44
  }
44
45
 
45
- var onUpload = useCallback(function(file, onProgress) { return api.upload(file, onProgress); }, [api]);
46
+ var upload = props.upload;
47
+ var onUpload = useMemo(function() { return uploaderFor(api, upload); }, [api, upload]);
46
48
 
47
49
  var onInspect = useCallback(async function(filePath) {
48
50
  var found = await api.inspect(filePath);
package/src/index.js CHANGED
@@ -7,6 +7,12 @@ export { useFileUploadController } from './fileUpload/useFileUploadController.js
7
7
  // File Upload — design validation
8
8
  export { useDesignValidator, FILE_UPLOAD_RULES } from './fileUpload/validateDesign.js';
9
9
 
10
+ // DesignCheck — the BLOCKING design check: a page whose design lacks a
11
+ // required element renders an error naming it instead of the design. Rules
12
+ // as useDesignValidator's, plus `when(state)`; checked after every render.
13
+ export { missingFrom, ruleSelectors, ruleApplies, ruleLabel } from './designCheck/designCheck.js';
14
+ export { useDesignCheck } from './designCheck/useDesignCheck.js';
15
+
10
16
  // File Upload — sample design
11
17
  export { FileUploadSample } from './fileUpload/designs/index.js';
12
18
 
@@ -53,7 +59,7 @@ export { DroppedRowsPage } from './dataImport/pages.jsx';
53
59
  // Imports — the whole import screen against @xeplr/imports' routes: database
54
60
  // picker, import (DataImportPage), progress with ✕, history (ImportHistoryPage).
55
61
  // <ImportsPage basePath="/api/imports" /> is all an app adds.
56
- export { createImportsApi, importProgressText, runResults, historyJob, databasesOf, fileNameOf } from './imports/importsApi.js';
62
+ export { createImportsApi, importProgressText, runResults, historyJob, databasesOf, fileNameOf, uploaderFor, ACCEPT as IMPORT_ACCEPT } from './imports/importsApi.js';
57
63
  export { useImportsController } from './imports/useImportsController.js';
58
64
  export { IMPORTS_RULES } from './imports/validateDesign.js';
59
65
  export { ImportsSample } from './imports/designs/index.js';
@@ -38,7 +38,7 @@ export default function TextFieldSample({
38
38
  ) : (
39
39
  <input
40
40
  className="xeplr-textfield-input"
41
- type={search ? 'search' : 'text'}
41
+ type={search ? 'search' : type === 'password' ? 'password' : 'text'}
42
42
  value={raw}
43
43
  placeholder={placeholder}
44
44
  disabled={disabled}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * TextField — pure model. No React.
3
3
  *
4
- * The plain text input, and the two shapes that are the same control with a
5
- * different edge: a multi-line one and a search one. Kept together because
4
+ * The plain text input, and the shapes that are the same control with a
5
+ * different edge: a multi-line one, a search one, and a password one (masked). Kept together because
6
6
  * they are one thing to style — an app that wants a bottom-rule-only textbox
7
7
  * wants a bottom-rule-only search box too, and splitting them is how those
8
8
  * drift apart.
9
9
  */
10
10
 
11
- export var TEXT_TYPES = ['text', 'multiline', 'search'];
11
+ export var TEXT_TYPES = ['text', 'multiline', 'search', 'password'];
12
12
 
13
13
  /**
14
14
  * What the control accepts as a value. Anything nullish is the empty string:
@@ -3,7 +3,7 @@ import { toValue, normalise, validate, remaining, TEXT_TYPES } from './textField
3
3
 
4
4
  /**
5
5
  * @param {object} props
6
- * @param {'text'|'multiline'|'search'} [props.type='text']
6
+ * @param {'text'|'multiline'|'search'|'password'} [props.type='text']
7
7
  * @param {string} [props.value] — controlled
8
8
  * @param {string} [props.defaultValue] — uncontrolled initial
9
9
  * @param {(value) => void} [props.onChange]
@@ -1,3 +1,3 @@
1
1
  export var TEXT_FIELD_RULES = [
2
- { selector: 'input[type="text"], input[type="search"], textarea, .xeplr-textfield-input', label: 'Text input element' }
2
+ { selector: 'input[type="text"], input[type="search"], input[type="password"], textarea, .xeplr-textfield-input', label: 'Text input element' }
3
3
  ];