@xeplr/ui-utils 1.1.4 → 1.1.5
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 +4 -0
- package/package.json +1 -1
- package/src/fields/fieldLabel.js +31 -0
- package/src/index.js +4 -0
package/README.md
CHANGED
|
@@ -525,6 +525,10 @@ await sources.fetchSuggestions('procedureParams', { connectionId, procedure })
|
|
|
525
525
|
- **`key`** names the list in a hand-written endpoint's answer (default `dataArray`). Guessing it wrong would show an empty list and no error.
|
|
526
526
|
- **Pure, no React, no login of its own:** the host passes its own fetch.
|
|
527
527
|
|
|
528
|
+
## `fieldLabel`
|
|
529
|
+
|
|
530
|
+
A schema field's name as words, when it has no `label` of its own: `connectionInfoId` → **Connection**, `dbInfoId` → **Database**, `streaming_mode` → **Streaming mode**, `timeoutMs` → **Timeout (ms)**. `Id` / `Info` are dropped: you pick a connection, not its id. Used by `@xeplr/ui-jobs` and X-Flow's step editor.
|
|
531
|
+
|
|
528
532
|
## raiseSnackbar, raiseConfirm, raiseChoice
|
|
529
533
|
|
|
530
534
|
```js
|
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// WHAT A SCHEMA FIELD IS CALLED ON SCREEN.
|
|
2
|
+
//
|
|
3
|
+
// A field's name is written for the action's code. Showing it raw put
|
|
4
|
+
// "connectionInfoId", "dbInfoId", "streaming_mode" and "batchSize" in front of
|
|
5
|
+
// people as though those were English. A field may carry its own `label`;
|
|
6
|
+
// this is the fallback, good enough that most fields never need one.
|
|
7
|
+
// `Id` / `Info` are suffixes of the storage, not of the thing: you pick a
|
|
8
|
+
// Connection, not a connectionInfoId.
|
|
9
|
+
//
|
|
10
|
+
// One copy, used by @xeplr/ui-jobs' job editor and X-Flow's step editor.
|
|
11
|
+
// Pure: no React.
|
|
12
|
+
|
|
13
|
+
const LABEL_WORDS = { db: 'Database', sql: 'SQL', url: 'URL', id: 'ID', api: 'API', http: 'HTTP', ms: '(ms)' }
|
|
14
|
+
|
|
15
|
+
export function fieldLabel(field) {
|
|
16
|
+
if (!field) return ''
|
|
17
|
+
if (field.label) return field.label
|
|
18
|
+
return String(field.name || '')
|
|
19
|
+
.replace(/Id$/, '')
|
|
20
|
+
.replace(/Info$/, '')
|
|
21
|
+
.replace(/[_-]+/g, ' ')
|
|
22
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
23
|
+
.trim()
|
|
24
|
+
.split(' ')
|
|
25
|
+
.map((w, i) => {
|
|
26
|
+
const known = LABEL_WORDS[w.toLowerCase()]
|
|
27
|
+
if (known) return known
|
|
28
|
+
return i === 0 ? w.charAt(0).toUpperCase() + w.slice(1) : w.toLowerCase()
|
|
29
|
+
})
|
|
30
|
+
.join(' ')
|
|
31
|
+
}
|
package/src/index.js
CHANGED
|
@@ -241,3 +241,7 @@ export { ExpandersPage, SettingsTreePage } from './panel/pages.jsx';
|
|
|
241
241
|
// Option sources — where a KIND of thing an input names (`optionsFrom`) is
|
|
242
242
|
// listed. Shared by @xeplr/ui-jobs and X-Flow's step editor.
|
|
243
243
|
export { createOptionSources } from './optionSources/optionSources.js';
|
|
244
|
+
|
|
245
|
+
// Field labels — a schema field's name as words ("connectionInfoId" →
|
|
246
|
+
// "Connection"). Shared by @xeplr/ui-jobs and X-Flow's step editor.
|
|
247
|
+
export { fieldLabel } from './fields/fieldLabel.js';
|