@fieldia/widgets 0.11.0 → 0.12.0
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/package.json +2 -2
- package/src/index.d.mts +2 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +6 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +2 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/badge.d.mts +8 -0
- package/src/lib/badge.d.ts +8 -0
- package/src/lib/badge.js +37 -0
- package/src/lib/badge.js.map +1 -0
- package/src/lib/badge.mjs +33 -0
- package/src/lib/badge.mjs.map +1 -0
- package/src/lib/calendar.d.mts +3 -1
- package/src/lib/calendar.d.ts +3 -1
- package/src/lib/calendar.js +17 -1
- package/src/lib/calendar.js.map +1 -1
- package/src/lib/calendar.mjs +17 -1
- package/src/lib/calendar.mjs.map +1 -1
- package/src/lib/cards.js +12 -4
- package/src/lib/cards.js.map +1 -1
- package/src/lib/cards.mjs +13 -5
- package/src/lib/cards.mjs.map +1 -1
- package/src/lib/choice-images.js +1 -1
- package/src/lib/choice-images.js.map +1 -1
- package/src/lib/choice-images.mjs +1 -1
- package/src/lib/choice-images.mjs.map +1 -1
- package/src/lib/choice-tags.js +2 -2
- package/src/lib/choice-tags.js.map +1 -1
- package/src/lib/choice-tags.mjs +2 -2
- package/src/lib/choice-tags.mjs.map +1 -1
- package/src/lib/colour.d.mts +11 -0
- package/src/lib/colour.d.ts +11 -0
- package/src/lib/colour.js +114 -0
- package/src/lib/colour.js.map +1 -0
- package/src/lib/colour.mjs +110 -0
- package/src/lib/colour.mjs.map +1 -0
- package/src/lib/copy.d.mts +8 -0
- package/src/lib/copy.d.ts +8 -0
- package/src/lib/copy.js +58 -0
- package/src/lib/copy.js.map +1 -0
- package/src/lib/copy.mjs +54 -0
- package/src/lib/copy.mjs.map +1 -0
- package/src/lib/date-range.d.mts +2 -0
- package/src/lib/date-range.d.ts +2 -0
- package/src/lib/date-range.js +220 -0
- package/src/lib/date-range.js.map +1 -0
- package/src/lib/date-range.mjs +216 -0
- package/src/lib/date-range.mjs.map +1 -0
- package/src/lib/display.d.mts +25 -1
- package/src/lib/display.d.ts +25 -1
- package/src/lib/display.js +42 -2
- package/src/lib/display.js.map +1 -1
- package/src/lib/display.mjs +39 -2
- package/src/lib/display.mjs.map +1 -1
- package/src/lib/distribution.d.mts +13 -0
- package/src/lib/distribution.d.ts +13 -0
- package/src/lib/distribution.js +159 -0
- package/src/lib/distribution.js.map +1 -0
- package/src/lib/distribution.mjs +152 -0
- package/src/lib/distribution.mjs.map +1 -0
- package/src/lib/duration.d.mts +18 -0
- package/src/lib/duration.d.ts +18 -0
- package/src/lib/duration.js +137 -0
- package/src/lib/duration.js.map +1 -0
- package/src/lib/duration.mjs +128 -0
- package/src/lib/duration.mjs.map +1 -0
- package/src/lib/embed.d.mts +3 -0
- package/src/lib/embed.d.ts +3 -0
- package/src/lib/embed.js +97 -0
- package/src/lib/embed.js.map +1 -0
- package/src/lib/embed.mjs +92 -0
- package/src/lib/embed.mjs.map +1 -0
- package/src/lib/extras.js +6 -0
- package/src/lib/extras.js.map +1 -1
- package/src/lib/extras.mjs +6 -0
- package/src/lib/extras.mjs.map +1 -1
- package/src/lib/files.d.mts +11 -0
- package/src/lib/files.d.ts +11 -0
- package/src/lib/files.js +19 -0
- package/src/lib/files.js.map +1 -1
- package/src/lib/files.mjs +18 -0
- package/src/lib/files.mjs.map +1 -1
- package/src/lib/kind-parts.d.mts +4 -3
- package/src/lib/kind-parts.d.ts +4 -3
- package/src/lib/kind-parts.js +5 -3
- package/src/lib/kind-parts.js.map +1 -1
- package/src/lib/kind-parts.mjs +5 -3
- package/src/lib/kind-parts.mjs.map +1 -1
- package/src/lib/labels.d.mts +37 -0
- package/src/lib/labels.d.ts +37 -0
- package/src/lib/labels.js +28 -0
- package/src/lib/labels.js.map +1 -1
- package/src/lib/labels.mjs +28 -0
- package/src/lib/labels.mjs.map +1 -1
- package/src/lib/lines.d.mts +12 -2
- package/src/lib/lines.d.ts +12 -2
- package/src/lib/lines.js +251 -15
- package/src/lib/lines.js.map +1 -1
- package/src/lib/lines.mjs +250 -16
- package/src/lib/lines.mjs.map +1 -1
- package/src/lib/links-table.d.mts +11 -0
- package/src/lib/links-table.d.ts +11 -0
- package/src/lib/links-table.js +116 -0
- package/src/lib/links-table.js.map +1 -0
- package/src/lib/links-table.mjs +112 -0
- package/src/lib/links-table.mjs.map +1 -0
- package/src/lib/locales/ar.js +28 -0
- package/src/lib/locales/ar.js.map +1 -1
- package/src/lib/locales/ar.mjs +28 -0
- package/src/lib/locales/ar.mjs.map +1 -1
- package/src/lib/locales/de.js +28 -0
- package/src/lib/locales/de.js.map +1 -1
- package/src/lib/locales/de.mjs +28 -0
- package/src/lib/locales/de.mjs.map +1 -1
- package/src/lib/locales/fr.js +28 -0
- package/src/lib/locales/fr.js.map +1 -1
- package/src/lib/locales/fr.mjs +28 -0
- package/src/lib/locales/fr.mjs.map +1 -1
- package/src/lib/payments.d.mts +2 -0
- package/src/lib/payments.d.ts +2 -0
- package/src/lib/payments.js +94 -0
- package/src/lib/payments.js.map +1 -0
- package/src/lib/payments.mjs +90 -0
- package/src/lib/payments.mjs.map +1 -0
- package/src/lib/popup.d.mts +11 -0
- package/src/lib/popup.d.ts +11 -0
- package/src/lib/popup.js +48 -0
- package/src/lib/popup.js.map +1 -0
- package/src/lib/popup.mjs +45 -0
- package/src/lib/popup.mjs.map +1 -0
- package/src/lib/priority.d.mts +10 -0
- package/src/lib/priority.d.ts +10 -0
- package/src/lib/priority.js +59 -0
- package/src/lib/priority.js.map +1 -0
- package/src/lib/priority.mjs +55 -0
- package/src/lib/priority.mjs.map +1 -0
- package/src/lib/progress.js +3 -0
- package/src/lib/progress.js.map +1 -1
- package/src/lib/progress.mjs +3 -0
- package/src/lib/progress.mjs.map +1 -1
- package/src/lib/properties.js +100 -9
- package/src/lib/properties.js.map +1 -1
- package/src/lib/properties.mjs +100 -9
- package/src/lib/properties.mjs.map +1 -1
- package/src/lib/read-text.d.mts +25 -0
- package/src/lib/read-text.d.ts +25 -0
- package/src/lib/read-text.js +102 -0
- package/src/lib/read-text.js.map +1 -0
- package/src/lib/read-text.mjs +98 -0
- package/src/lib/read-text.mjs.map +1 -0
- package/src/lib/relations.d.mts +12 -0
- package/src/lib/relations.d.ts +12 -0
- package/src/lib/relations.js +99 -8
- package/src/lib/relations.js.map +1 -1
- package/src/lib/relations.mjs +97 -8
- package/src/lib/relations.mjs.map +1 -1
- package/src/lib/slider.js +1 -1
- package/src/lib/slider.js.map +1 -1
- package/src/lib/slider.mjs +1 -1
- package/src/lib/slider.mjs.map +1 -1
- package/src/lib/state-dot.d.mts +2 -0
- package/src/lib/state-dot.d.ts +2 -0
- package/src/lib/state-dot.js +107 -0
- package/src/lib/state-dot.js.map +1 -0
- package/src/lib/state-dot.mjs +103 -0
- package/src/lib/state-dot.mjs.map +1 -0
- package/src/lib/statusbar.js +151 -14
- package/src/lib/statusbar.js.map +1 -1
- package/src/lib/statusbar.mjs +151 -14
- package/src/lib/statusbar.mjs.map +1 -1
- package/src/lib/styles-business.d.mts +8 -0
- package/src/lib/styles-business.d.ts +8 -0
- package/src/lib/styles-business.js +120 -0
- package/src/lib/styles-business.js.map +1 -0
- package/src/lib/styles-business.mjs +117 -0
- package/src/lib/styles-business.mjs.map +1 -0
- package/src/lib/styles-kinds.d.mts +1 -1
- package/src/lib/styles-kinds.d.ts +1 -1
- package/src/lib/styles-kinds.js +1 -1
- package/src/lib/styles-kinds.mjs +1 -1
- package/src/lib/styles-sheet.d.mts +6 -0
- package/src/lib/styles-sheet.d.ts +6 -0
- package/src/lib/styles-sheet.js +123 -0
- package/src/lib/styles-sheet.js.map +1 -0
- package/src/lib/styles-sheet.mjs +120 -0
- package/src/lib/styles-sheet.mjs.map +1 -0
- package/src/lib/styles.js +142 -10
- package/src/lib/styles.js.map +1 -1
- package/src/lib/styles.mjs +142 -10
- package/src/lib/styles.mjs.map +1 -1
- package/src/lib/tax-totals.d.mts +2 -0
- package/src/lib/tax-totals.d.ts +2 -0
- package/src/lib/tax-totals.js +92 -0
- package/src/lib/tax-totals.js.map +1 -0
- package/src/lib/tax-totals.mjs +88 -0
- package/src/lib/tax-totals.mjs.map +1 -0
- package/src/lib/timer.d.mts +4 -0
- package/src/lib/timer.d.ts +4 -0
- package/src/lib/timer.js +62 -0
- package/src/lib/timer.js.map +1 -0
- package/src/lib/timer.mjs +57 -0
- package/src/lib/timer.mjs.map +1 -0
- package/src/lib/widgets.d.mts +18 -3
- package/src/lib/widgets.d.ts +18 -3
- package/src/lib/widgets.js +63 -5
- package/src/lib/widgets.js.map +1 -1
- package/src/lib/widgets.mjs +63 -5
- package/src/lib/widgets.mjs.map +1 -1
- package/src/lib/yes-no.js +1 -1
- package/src/lib/yes-no.js.map +1 -1
- package/src/lib/yes-no.mjs +1 -1
- package/src/lib/yes-no.mjs.map +1 -1
package/src/lib/labels.js
CHANGED
|
@@ -22,6 +22,11 @@ const en = {
|
|
|
22
22
|
searchMore: 'Search more…',
|
|
23
23
|
openNamed: 'Open {name}',
|
|
24
24
|
openLine: 'Open line',
|
|
25
|
+
chooseLine: 'Choose {name}',
|
|
26
|
+
chooseAllLines: 'Choose every line',
|
|
27
|
+
linesChosen: '{n} chosen',
|
|
28
|
+
moreSteps: 'More',
|
|
29
|
+
timeInStep: '{time} in this step',
|
|
25
30
|
chooseDate: 'Choose a date',
|
|
26
31
|
other: 'Other:',
|
|
27
32
|
otherAnswer: 'Your own answer',
|
|
@@ -105,6 +110,29 @@ const en = {
|
|
|
105
110
|
keepOrder: 'Keep this order',
|
|
106
111
|
ofMax: '{n} of {max}',
|
|
107
112
|
charactersLeft: 'Characters left: {n}',
|
|
113
|
+
colourNames: 'No colour|Red|Orange|Yellow|Cyan|Purple|Almond|Teal|Blue|Raspberry|Green|Violet',
|
|
114
|
+
copyValue: 'Copy',
|
|
115
|
+
copied: 'Copied',
|
|
116
|
+
noDocument: 'No document yet',
|
|
117
|
+
openInNewTab: 'Open in a new tab',
|
|
118
|
+
account: 'Account',
|
|
119
|
+
share: 'Percentage',
|
|
120
|
+
addAccount: 'Add an account',
|
|
121
|
+
sharesOff: 'The shares add up to {n}, not 100%',
|
|
122
|
+
untaxed: 'Untaxed amount',
|
|
123
|
+
paidOn: 'Paid on {date}',
|
|
124
|
+
amountDue: 'Amount due',
|
|
125
|
+
paymentOf: 'Payment of {amount}',
|
|
126
|
+
journal: 'Journal',
|
|
127
|
+
memo: 'Memo',
|
|
128
|
+
openPayment: 'Open',
|
|
129
|
+
addProperty: 'Add a property',
|
|
130
|
+
propertyName: 'Property name',
|
|
131
|
+
propertyType: 'Kind',
|
|
132
|
+
propertyTypes: 'Text|Long text|Whole number|Number|Yes or no|Date',
|
|
133
|
+
add: 'Add',
|
|
134
|
+
cancel: 'Cancel',
|
|
135
|
+
loading: 'Loading…',
|
|
108
136
|
};
|
|
109
137
|
/**
|
|
110
138
|
* The widgets' words in every language Fieldia has. This package holds all
|
package/src/lib/labels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../../../../libs/widgets/src/lib/labels.ts"],"names":[],"mappings":";;;AACA,uCAA0C;
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../../../../libs/widgets/src/lib/labels.ts"],"names":[],"mappings":";;;AACA,uCAA0C;AAiL1C,iEAAiE;AACjE,MAAM,EAAE,GAAiB;IACvB,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,YAAY;IACvB,MAAM,EAAE,eAAe;IACvB,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,aAAa;IACzB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,qBAAqB;IAClC,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,gBAAgB;IAC/B,W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AAY,EAAE,mBAAmB;IACjC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,YAAY;IACnB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,oCAAoC;IAC/C,OAAO,EAAE,gBAAgB;IACzB,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,qBAAqB;IAChC,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,gBAAgB;IAC7B,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,MAAM;IACpB,aAAa,EAAE,mDAAmD;IAClE,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF;;;;;GAKG;AACU,QAAA,aAAa,GAAiC,EAAE,EAAE,EAAE,GAAG,eAAS,EAAE,CAAC"}
|
package/src/lib/labels.mjs
CHANGED
|
@@ -19,6 +19,11 @@ const en = {
|
|
|
19
19
|
searchMore: 'Search more…',
|
|
20
20
|
openNamed: 'Open {name}',
|
|
21
21
|
openLine: 'Open line',
|
|
22
|
+
chooseLine: 'Choose {name}',
|
|
23
|
+
chooseAllLines: 'Choose every line',
|
|
24
|
+
linesChosen: '{n} chosen',
|
|
25
|
+
moreSteps: 'More',
|
|
26
|
+
timeInStep: '{time} in this step',
|
|
22
27
|
chooseDate: 'Choose a date',
|
|
23
28
|
other: 'Other:',
|
|
24
29
|
otherAnswer: 'Your own answer',
|
|
@@ -102,6 +107,29 @@ const en = {
|
|
|
102
107
|
keepOrder: 'Keep this order',
|
|
103
108
|
ofMax: '{n} of {max}',
|
|
104
109
|
charactersLeft: 'Characters left: {n}',
|
|
110
|
+
colourNames: 'No colour|Red|Orange|Yellow|Cyan|Purple|Almond|Teal|Blue|Raspberry|Green|Violet',
|
|
111
|
+
copyValue: 'Copy',
|
|
112
|
+
copied: 'Copied',
|
|
113
|
+
noDocument: 'No document yet',
|
|
114
|
+
openInNewTab: 'Open in a new tab',
|
|
115
|
+
account: 'Account',
|
|
116
|
+
share: 'Percentage',
|
|
117
|
+
addAccount: 'Add an account',
|
|
118
|
+
sharesOff: 'The shares add up to {n}, not 100%',
|
|
119
|
+
untaxed: 'Untaxed amount',
|
|
120
|
+
paidOn: 'Paid on {date}',
|
|
121
|
+
amountDue: 'Amount due',
|
|
122
|
+
paymentOf: 'Payment of {amount}',
|
|
123
|
+
journal: 'Journal',
|
|
124
|
+
memo: 'Memo',
|
|
125
|
+
openPayment: 'Open',
|
|
126
|
+
addProperty: 'Add a property',
|
|
127
|
+
propertyName: 'Property name',
|
|
128
|
+
propertyType: 'Kind',
|
|
129
|
+
propertyTypes: 'Text|Long text|Whole number|Number|Yes or no|Date',
|
|
130
|
+
add: 'Add',
|
|
131
|
+
cancel: 'Cancel',
|
|
132
|
+
loading: 'Loading…',
|
|
105
133
|
};
|
|
106
134
|
/**
|
|
107
135
|
* The widgets' words in every language Fieldia has. This package holds all
|
package/src/lib/labels.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.mjs","sourceRoot":"","sources":["../../../../../libs/widgets/src/lib/labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"labels.mjs","sourceRoot":"","sources":["../../../../../libs/widgets/src/lib/labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAiL1C,iEAAiE;AACjE,MAAM,EAAE,GAAiB;IACvB,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,YAAY;IACvB,MAAM,EAAE,eAAe;IACvB,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,eAAe;IAC3B,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,aAAa;IACzB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,OAAO;IACd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9F,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,iBAAiB;IAC7B,YAAY,EAAE,mBAAmB;IACjC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,YAAY;IACnB,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,oCAAoC;IAC/C,OAAO,EAAE,gBAAgB;IACzB,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,qBAAqB;IAChC,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,gBAAgB;IAC7B,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,MAAM;IACpB,aAAa,EAAE,mDAAmD;IAClE,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,EAAE,EAAE,EAAE,GAAG,SAAS,EAAE,CAAC"}
|
package/src/lib/lines.d.mts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { type Form, type LineField } from '@fieldia/core';
|
|
2
|
-
import { type WidgetFactory } from './widgets.mjs';
|
|
1
|
+
import { type FieldNode, type Form, type Line, type LineField, type Values } from '@fieldia/core';
|
|
2
|
+
import { type WidgetDialogs, type WidgetFactory } from './widgets.mjs';
|
|
3
3
|
/** The field a section or note is typed into: one line for a heading, a growing box for a note. */
|
|
4
4
|
export declare function kindTextField(def: LineField, kind: 'section' | 'note'): LineField;
|
|
5
5
|
/** The form a cell sees: the line's values, written back into the line. Shared with @fieldia/grid. */
|
|
6
6
|
export declare function lineForm(form: Form, field: string, key: string): Form;
|
|
7
|
+
/** A line's money in its record's currency (`parent.…`), as a field of its own: in that currency, fixed — for a dialog with no record round it. */
|
|
8
|
+
export declare function ownCurrency(sub: LineField, parent: Readonly<Values>): LineField;
|
|
9
|
+
/**
|
|
10
|
+
* A line opened in a dialog: with `lineOpens: "record"`, a saved line's own
|
|
11
|
+
* record by the table's model — what its page saved is written back to the
|
|
12
|
+
* line's fields of the same names — else, or for a line not saved yet, every
|
|
13
|
+
* one of its fields, recalculated as they change and written back on Save &
|
|
14
|
+
* Close. Shared with @fieldia/grid.
|
|
15
|
+
*/
|
|
16
|
+
export declare function openLineDialog(form: Form, name: string, node: FieldNode, line: Line, dialogs: WidgetDialogs, readonly: boolean): Promise<void>;
|
|
7
17
|
export declare const linesWidget: WidgetFactory;
|
package/src/lib/lines.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { type Form, type LineField } from '@fieldia/core';
|
|
2
|
-
import { type WidgetFactory } from './widgets';
|
|
1
|
+
import { type FieldNode, type Form, type Line, type LineField, type Values } from '@fieldia/core';
|
|
2
|
+
import { type WidgetDialogs, type WidgetFactory } from './widgets';
|
|
3
3
|
/** The field a section or note is typed into: one line for a heading, a growing box for a note. */
|
|
4
4
|
export declare function kindTextField(def: LineField, kind: 'section' | 'note'): LineField;
|
|
5
5
|
/** The form a cell sees: the line's values, written back into the line. Shared with @fieldia/grid. */
|
|
6
6
|
export declare function lineForm(form: Form, field: string, key: string): Form;
|
|
7
|
+
/** A line's money in its record's currency (`parent.…`), as a field of its own: in that currency, fixed — for a dialog with no record round it. */
|
|
8
|
+
export declare function ownCurrency(sub: LineField, parent: Readonly<Values>): LineField;
|
|
9
|
+
/**
|
|
10
|
+
* A line opened in a dialog: with `lineOpens: "record"`, a saved line's own
|
|
11
|
+
* record by the table's model — what its page saved is written back to the
|
|
12
|
+
* line's fields of the same names — else, or for a line not saved yet, every
|
|
13
|
+
* one of its fields, recalculated as they change and written back on Save &
|
|
14
|
+
* Close. Shared with @fieldia/grid.
|
|
15
|
+
*/
|
|
16
|
+
export declare function openLineDialog(form: Form, name: string, node: FieldNode, line: Line, dialogs: WidgetDialogs, readonly: boolean): Promise<void>;
|
|
7
17
|
export declare const linesWidget: WidgetFactory;
|
package/src/lib/lines.js
CHANGED
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.linesWidget = void 0;
|
|
4
4
|
exports.kindTextField = kindTextField;
|
|
5
5
|
exports.lineForm = lineForm;
|
|
6
|
+
exports.ownCurrency = ownCurrency;
|
|
7
|
+
exports.openLineDialog = openLineDialog;
|
|
6
8
|
const core_1 = require("@fieldia/core");
|
|
7
9
|
const display_1 = require("./display");
|
|
10
|
+
const icons_1 = require("./icons");
|
|
8
11
|
const kind_parts_1 = require("./kind-parts");
|
|
9
12
|
const labels_1 = require("./labels");
|
|
10
13
|
const line_moves_1 = require("./line-moves");
|
|
@@ -21,11 +24,57 @@ function lineForm(form, field, key) {
|
|
|
21
24
|
...form,
|
|
22
25
|
getState: () => ({ ...form.getState(), values: values() }),
|
|
23
26
|
setValue: (name, value) => form.updateLine(field, key, name, value),
|
|
24
|
-
search: (name, query, limit) => form.searchLine(field, key, name, query, limit),
|
|
27
|
+
search: (name, query, limit, options) => form.searchLine(field, key, name, query, limit, options),
|
|
25
28
|
canCreate: (name) => form.canCreateLine(field, name),
|
|
26
|
-
quickCreate: (name, text) => form.quickCreateLine(field, name, text),
|
|
29
|
+
quickCreate: (name, text) => form.quickCreateLine(field, name, text, key),
|
|
30
|
+
createValues: (name) => form.createValues(name, { lines: field, key }),
|
|
27
31
|
};
|
|
28
32
|
}
|
|
33
|
+
/** A line's money in its record's currency (`parent.…`), as a field of its own: in that currency, fixed — for a dialog with no record round it. */
|
|
34
|
+
function ownCurrency(sub, parent) {
|
|
35
|
+
if (sub.type !== 'monetary' || !sub.currencyField?.startsWith('parent.'))
|
|
36
|
+
return sub;
|
|
37
|
+
const { currencyField: _, ...rest } = sub;
|
|
38
|
+
const code = (0, display_1.currencyOf)(sub, {}, parent);
|
|
39
|
+
return code && /^[A-Z]{3}$/.test(code) ? { ...rest, currency: code } : rest;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A line opened in a dialog: with `lineOpens: "record"`, a saved line's own
|
|
43
|
+
* record by the table's model — what its page saved is written back to the
|
|
44
|
+
* line's fields of the same names — else, or for a line not saved yet, every
|
|
45
|
+
* one of its fields, recalculated as they change and written back on Save &
|
|
46
|
+
* Close. Shared with @fieldia/grid.
|
|
47
|
+
*/
|
|
48
|
+
async function openLineDialog(form, name, node, line, dialogs, readonly) {
|
|
49
|
+
const def = form.page.fields[name];
|
|
50
|
+
const lines = () => form.getState().values[name] ?? [];
|
|
51
|
+
const write = (values) => form.setValue(name, lines().map((l) => (l.key === line.key ? { ...l, values: { ...l.values, ...values } } : l)));
|
|
52
|
+
if (node.lineOpens === 'record' && line.id !== undefined && dialogs.canOpen(def.relation)) {
|
|
53
|
+
const saved = await dialogs.openRecord(def.relation, { recordId: line.id, title: def.label, withValues: true });
|
|
54
|
+
const back = Object.fromEntries(Object.entries(saved?.values ?? {}).filter(([key]) => key in def.fields && key !== def.sequenceField));
|
|
55
|
+
if (Object.keys(back).length)
|
|
56
|
+
write(back);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const fields = Object.fromEntries(Object.entries(def.fields)
|
|
60
|
+
.filter(([key]) => key !== def.lineKinds?.field && key !== def.sequenceField)
|
|
61
|
+
.map(([key, sub]) => [key, ownCurrency(sub, form.getState().values)]));
|
|
62
|
+
// The dialog shows what the onchange makes of the line as it is edited; the line itself waits for Save & Close.
|
|
63
|
+
// Laid out by the table's lineForm when it has one, its conditions reading the line, its record as parent.
|
|
64
|
+
const state = form.getState();
|
|
65
|
+
const values = await dialogs.editValues({
|
|
66
|
+
title: def.label,
|
|
67
|
+
fields,
|
|
68
|
+
values: line.values,
|
|
69
|
+
readonly,
|
|
70
|
+
recompute: (edited) => form.previewLine(name, line.key, edited),
|
|
71
|
+
parent: { values: state.values, fields: form.page.fields, id: state.recordId },
|
|
72
|
+
...(node.lineForm ? { layout: node.lineForm.children } : {}),
|
|
73
|
+
});
|
|
74
|
+
// Written in one go, so the form recalculates once.
|
|
75
|
+
if (values)
|
|
76
|
+
write(values);
|
|
77
|
+
}
|
|
29
78
|
const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.WIDGET_LABELS.en, locale, dialogs }) => {
|
|
30
79
|
const def = field;
|
|
31
80
|
const kinds = def.lineKinds;
|
|
@@ -36,10 +85,20 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
36
85
|
const words = (key) => (typeof options[key] === 'string' && options[key].trim() ? options[key] : null);
|
|
37
86
|
// The fields that say what a line is and keep the lines' order never show as columns.
|
|
38
87
|
// Optional columns the page starts hidden stay out of the plain table.
|
|
39
|
-
const
|
|
88
|
+
const heads = new Map();
|
|
89
|
+
// The table's own rules, read by the form line by line; a table with none asks nothing.
|
|
90
|
+
const ruled = !!(node.cells || node.rowTones || node.rowBold !== undefined || node.rowButtons || node.lineDelete !== undefined);
|
|
91
|
+
const columns = (node.columns ?? Object.keys(def.fields)).filter(
|
|
92
|
+
// Lines a line holds are edited in its form, never drawn in its row.
|
|
93
|
+
(column) => def.fields[column] && def.fields[column].type !== 'one2many' && column !== kinds?.field && column !== def.sequenceField && node.optionalColumns?.[column] !== 'hide');
|
|
40
94
|
const element = document.createElement('div');
|
|
41
95
|
element.className = 'fd-lines';
|
|
42
96
|
element.id = id;
|
|
97
|
+
// Lines as cards on a narrow form, or always; columns as wide as they hold: the stylesheet draws them so.
|
|
98
|
+
if (node.cards)
|
|
99
|
+
element.dataset['cards'] = node.cards;
|
|
100
|
+
if (node.fit)
|
|
101
|
+
element.dataset['fit'] = node.fit;
|
|
43
102
|
element.setAttribute('role', 'group');
|
|
44
103
|
const scroller = document.createElement('div');
|
|
45
104
|
scroller.className = 'fd-lines-scroll';
|
|
@@ -47,11 +106,20 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
47
106
|
table.className = 'fd-lines-table';
|
|
48
107
|
const head = document.createElement('thead');
|
|
49
108
|
const headRow = document.createElement('tr');
|
|
50
|
-
|
|
109
|
+
// Lines chosen for the table's buttons for them: a tick on each line, one in the head for every line, and a bar over the table.
|
|
110
|
+
const choosing = !!node.selectedButtons?.length;
|
|
111
|
+
const chosen = new Set();
|
|
112
|
+
const pickAll = choosing ? make('input', { type: 'checkbox', class: 'fd-checkbox fd-line-pick fd-line-pick-all', 'aria-label': labels.chooseAllLines }) : null;
|
|
113
|
+
headRow.append(make('th', { class: 'fd-lines-grip' }, ...(pickAll ? [pickAll] : [])));
|
|
51
114
|
for (const column of columns) {
|
|
52
115
|
const th = document.createElement('th');
|
|
53
116
|
th.scope = 'col';
|
|
117
|
+
th.dataset['column'] = column;
|
|
54
118
|
th.textContent = def.fields[column].label;
|
|
119
|
+
const width = node.cells?.[column]?.width;
|
|
120
|
+
if (width)
|
|
121
|
+
th.style.width = `${width}ch`;
|
|
122
|
+
heads.set(column, th);
|
|
55
123
|
headRow.append(th);
|
|
56
124
|
}
|
|
57
125
|
const lastTh = document.createElement('th');
|
|
@@ -63,6 +131,7 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
63
131
|
// Number columns the page asks to add up, in a row under the lines.
|
|
64
132
|
const totals = (node.totals ?? []).filter((column) => columns.includes(column));
|
|
65
133
|
const sums = new Map();
|
|
134
|
+
const footCells = new Map();
|
|
66
135
|
if (totals.length) {
|
|
67
136
|
const foot = document.createElement('tfoot');
|
|
68
137
|
const row = document.createElement('tr');
|
|
@@ -70,6 +139,8 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
70
139
|
row.append(document.createElement('td'));
|
|
71
140
|
columns.forEach((column, i) => {
|
|
72
141
|
const td = document.createElement('td');
|
|
142
|
+
td.dataset['column'] = column;
|
|
143
|
+
footCells.set(column, td);
|
|
73
144
|
if (totals.includes(column))
|
|
74
145
|
sums.set(column, td);
|
|
75
146
|
else if (i === 0)
|
|
@@ -101,16 +172,77 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
101
172
|
};
|
|
102
173
|
addButton(words('addLabel') ?? labels.addLine, {}, 'line');
|
|
103
174
|
if (kinds) {
|
|
104
|
-
addButton(labels.addSection, { [kinds.field]: kinds.section ?? 'section' }, 'section');
|
|
105
|
-
addButton(labels.addNote, { [kinds.field]: kinds.note ?? 'note' }, 'note');
|
|
175
|
+
addButton(words('addSectionLabel') ?? labels.addSection, { [kinds.field]: kinds.section ?? 'section' }, 'section');
|
|
176
|
+
addButton(words('addNoteLabel') ?? labels.addNote, { [kinds.field]: kinds.note ?? 'note' }, 'note');
|
|
106
177
|
}
|
|
178
|
+
// Buttons in the control row, beside the add buttons: the record's, shown by a condition on it (Flectra's <control>).
|
|
179
|
+
const controls = (node.controlButtons ?? []).map((own) => {
|
|
180
|
+
const icon = (0, icons_1.drawIcon)(document, own.icon);
|
|
181
|
+
const button = make('button', { type: 'button', class: 'fd-button fd-button-link fd-lines-add fd-lines-control', 'data-node': own.id }, ...(icon ? [icon] : []), own.label);
|
|
182
|
+
button.addEventListener('click', () => void pressed(button, () => form.runAction(own.id)));
|
|
183
|
+
adds.append(button);
|
|
184
|
+
return { id: own.id, button };
|
|
185
|
+
});
|
|
186
|
+
// The bar of buttons for the lines chosen, over the table while any is.
|
|
187
|
+
const chosenCount = make('span', { class: 'fd-lines-chosen-count', role: 'status' });
|
|
188
|
+
const chosenButtons = (node.selectedButtons ?? []).map((own) => {
|
|
189
|
+
const icon = (0, icons_1.drawIcon)(document, own.icon);
|
|
190
|
+
const button = make('button', { type: 'button', class: `fd-button fd-button-${own.style ?? 'secondary'} fd-lines-chosen-button`, 'data-node': own.id }, ...(icon ? [icon] : []), own.label);
|
|
191
|
+
// In the table's order, whatever order they were ticked in.
|
|
192
|
+
button.addEventListener('click', () => void pressed(button, () => form.runLinesAction(node.id, own.id, current().filter((line) => chosen.has(line.key)).map((line) => line.key))));
|
|
193
|
+
return { id: own.id, button };
|
|
194
|
+
});
|
|
195
|
+
const bar = choosing ? make('div', { class: 'fd-lines-chosen', hidden: '' }, chosenCount, ...chosenButtons.map((b) => b.button)) : null;
|
|
107
196
|
const emptyWords = words('emptyLabel');
|
|
108
197
|
const empty = emptyWords ? make('div', { class: 'fd-help fd-lines-empty' }, emptyWords) : null;
|
|
109
198
|
// Removing a line with something in it asks first, in place: "Remove line 2? Remove · Keep".
|
|
110
199
|
const confirm = (0, kind_parts_1.askFirst)(make, labels);
|
|
111
200
|
// Where a line went, said politely; not the page's own announcer, which a page looks for by its class.
|
|
112
201
|
const voice = make('div', { class: 'fd-sr-only', role: 'status' });
|
|
113
|
-
element.append(scroller, ...(empty ? [empty] : []), adds, confirm.element, voice);
|
|
202
|
+
element.append(...(bar ? [bar] : []), scroller, ...(empty ? [empty] : []), adds, confirm.element, voice);
|
|
203
|
+
/** A press that waits for its run, and is not pressed again meanwhile. */
|
|
204
|
+
async function pressed(button, run) {
|
|
205
|
+
if (button.hasAttribute('aria-busy'))
|
|
206
|
+
return;
|
|
207
|
+
button.setAttribute('aria-busy', 'true');
|
|
208
|
+
try {
|
|
209
|
+
await run();
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
button.removeAttribute('aria-busy');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** The bar and the head's tick, as the lines chosen are now. */
|
|
216
|
+
function showChosen() {
|
|
217
|
+
if (!bar || !pickAll)
|
|
218
|
+
return;
|
|
219
|
+
const items = current().filter((line) => !(0, core_1.lineKind)(def, line.values));
|
|
220
|
+
for (const key of [...chosen])
|
|
221
|
+
if (!items.some((line) => line.key === key))
|
|
222
|
+
chosen.delete(key);
|
|
223
|
+
bar.hidden = readonly || chosen.size === 0;
|
|
224
|
+
chosenCount.textContent = (0, kind_parts_1.fillIn)(labels.linesChosen, { n: chosen.size });
|
|
225
|
+
for (const { id, button } of chosenButtons)
|
|
226
|
+
button.hidden = form.node(id).invisible;
|
|
227
|
+
pickAll.checked = items.length > 0 && chosen.size === items.length;
|
|
228
|
+
pickAll.indeterminate = chosen.size > 0 && chosen.size < items.length;
|
|
229
|
+
pickAll.disabled = readonly || !items.length;
|
|
230
|
+
for (const [key, row] of rows) {
|
|
231
|
+
if (!row.pick)
|
|
232
|
+
continue;
|
|
233
|
+
row.pick.checked = chosen.has(key);
|
|
234
|
+
row.pick.disabled = readonly;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
pickAll?.addEventListener('change', () => {
|
|
238
|
+
const items = current().filter((line) => !(0, core_1.lineKind)(def, line.values));
|
|
239
|
+
if (pickAll.checked)
|
|
240
|
+
for (const line of items)
|
|
241
|
+
chosen.add(line.key);
|
|
242
|
+
else
|
|
243
|
+
chosen.clear();
|
|
244
|
+
showChosen();
|
|
245
|
+
});
|
|
114
246
|
const rows = new Map();
|
|
115
247
|
let focusNew = null;
|
|
116
248
|
let readonly = false;
|
|
@@ -140,10 +272,17 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
140
272
|
});
|
|
141
273
|
function makeCell(tr, line, column, sub, span = 1) {
|
|
142
274
|
const cellId = `${id}-${line.key}-${column}`;
|
|
143
|
-
|
|
275
|
+
// A cell the page draws as a pill in its tone (Flectra's widget="badge"), never edited, or with a widget of its own.
|
|
276
|
+
const rules = (0, core_1.lineKind)(def, line.values) ? undefined : node.cells?.[column];
|
|
277
|
+
// Its settings reach its widget even without a widget named: a calendar's week numbers.
|
|
278
|
+
const look = rules?.badge ? { widget: 'badge' } : rules?.widget ? { widget: rules.widget, ...(rules.options ? { options: rules.options } : {}) } : rules?.options ? { options: rules.options } : {};
|
|
279
|
+
const subNode = { type: 'field', id: `${node.id}.${line.key}.${column}`, field: column, ...look };
|
|
144
280
|
const widget = (0, widgets_1.createWidget)({ form: lineForm(form, name, line.key), name: column, field: sub, node: subNode, id: cellId, document, labels, locale, dialogs });
|
|
145
281
|
const td = document.createElement('td');
|
|
146
282
|
td.colSpan = span;
|
|
283
|
+
td.dataset['column'] = column;
|
|
284
|
+
// Its column's label, which a card shows before its value.
|
|
285
|
+
td.dataset['label'] = sub.label;
|
|
147
286
|
const label = document.createElement('label');
|
|
148
287
|
label.className = 'fd-sr-only';
|
|
149
288
|
label.htmlFor = cellId;
|
|
@@ -153,7 +292,7 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
153
292
|
error.hidden = true;
|
|
154
293
|
td.append(label, widget.element, error);
|
|
155
294
|
tr.append(td);
|
|
156
|
-
return { name: column, def: sub, widget, error };
|
|
295
|
+
return { name: column, def: sub, widget, error, td };
|
|
157
296
|
}
|
|
158
297
|
function makeRow(line) {
|
|
159
298
|
const tr = document.createElement('tr');
|
|
@@ -179,7 +318,16 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
179
318
|
});
|
|
180
319
|
for (const end of ['pointerup', 'pointercancel'])
|
|
181
320
|
grip.addEventListener(end, () => (dragging = false));
|
|
182
|
-
|
|
321
|
+
// Its tick for the table's buttons for chosen lines, before the grip.
|
|
322
|
+
const pick = choosing && !kind ? make('input', { type: 'checkbox', class: 'fd-checkbox fd-line-pick' }) : null;
|
|
323
|
+
pick?.addEventListener('change', () => {
|
|
324
|
+
if (pick.checked)
|
|
325
|
+
chosen.add(line.key);
|
|
326
|
+
else
|
|
327
|
+
chosen.delete(line.key);
|
|
328
|
+
showChosen();
|
|
329
|
+
});
|
|
330
|
+
tr.append(make('td', { class: 'fd-lines-grip' }, ...(pick ? [make('span', { class: 'fd-line-lead' }, pick, grip)] : [grip])));
|
|
183
331
|
const cells = kind && kinds
|
|
184
332
|
? [makeCell(tr, line, kinds.text, kindTextField(def.fields[kinds.text], kind), columns.length)]
|
|
185
333
|
: columns.map((column) => makeCell(tr, line, column, def.fields[column]));
|
|
@@ -204,9 +352,55 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
204
352
|
(next ? rows.get(next.key)?.remove : adds.querySelector('button'))?.focus();
|
|
205
353
|
});
|
|
206
354
|
});
|
|
355
|
+
// The line's own buttons, each shown by its condition on the line; a press runs with the line.
|
|
356
|
+
const buttons = new Map();
|
|
357
|
+
for (const own of kind ? [] : (node.rowButtons ?? [])) {
|
|
358
|
+
const icon = (0, icons_1.drawIcon)(document, own.icon);
|
|
359
|
+
const button = make('button', { type: 'button', class: `fd-button fd-button-link fd-line-button${icon ? ' fd-line-button-icon' : ''}`, 'data-row-button': own.id, 'aria-label': own.label, title: own.label });
|
|
360
|
+
button.append(icon ?? own.label);
|
|
361
|
+
button.addEventListener('click', async () => {
|
|
362
|
+
if (button.hasAttribute('aria-busy'))
|
|
363
|
+
return;
|
|
364
|
+
button.setAttribute('aria-busy', 'true');
|
|
365
|
+
try {
|
|
366
|
+
await form.runRowAction(node.id, own.id, line.key);
|
|
367
|
+
}
|
|
368
|
+
finally {
|
|
369
|
+
button.removeAttribute('aria-busy');
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
buttons.set(own.id, button);
|
|
373
|
+
tools.append(button);
|
|
374
|
+
}
|
|
375
|
+
// A copy of the line, its values too, right after it: never its saved id or its place in the order.
|
|
376
|
+
const copy = options['copy'] === true && !kind ? make('button', { type: 'button', class: 'fd-line-copy' }, '⧉') : null;
|
|
377
|
+
copy?.addEventListener('click', () => {
|
|
378
|
+
const all = current();
|
|
379
|
+
const at = all.findIndex((l) => l.key === line.key);
|
|
380
|
+
if (readonly || at < 0 || all.length >= max)
|
|
381
|
+
return;
|
|
382
|
+
const values = { ...all[at].values };
|
|
383
|
+
if (def.sequenceField)
|
|
384
|
+
delete values[def.sequenceField];
|
|
385
|
+
const made = form.addLine(name, values);
|
|
386
|
+
(0, line_moves_1.moveLineTo)(form, name, def, made, at + 1);
|
|
387
|
+
rows.get(made)?.cells[0]?.widget.focus();
|
|
388
|
+
});
|
|
389
|
+
if (copy)
|
|
390
|
+
tools.append(copy);
|
|
391
|
+
// Its own page, its own form (lineForm), or its every field, in a dialog (lineOpens).
|
|
392
|
+
if ((node.lineOpens || node.lineForm) && dialogs && !kind) {
|
|
393
|
+
const open = make('button', { type: 'button', class: 'fd-line-open', 'aria-label': labels.openLine, title: labels.openLine }, '↗');
|
|
394
|
+
open.addEventListener('click', () => {
|
|
395
|
+
const now = current().find((l) => l.key === line.key);
|
|
396
|
+
if (now)
|
|
397
|
+
void openLineDialog(form, name, node, now, dialogs, readonly);
|
|
398
|
+
});
|
|
399
|
+
tools.append(open);
|
|
400
|
+
}
|
|
207
401
|
tools.append(remove);
|
|
208
402
|
tr.append(tools);
|
|
209
|
-
return { element: tr, kind, cells, remove, grip };
|
|
403
|
+
return { element: tr, kind, cells, remove, grip, buttons, pick, copy };
|
|
210
404
|
}
|
|
211
405
|
return {
|
|
212
406
|
element,
|
|
@@ -220,6 +414,12 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
220
414
|
if (empty)
|
|
221
415
|
empty.hidden = current.length > 0;
|
|
222
416
|
const errors = form.getState().errors;
|
|
417
|
+
// Columns the record hides now: their head, cells and total go with them.
|
|
418
|
+
const gone = new Set(ruled ? columns.filter((column) => form.columnHidden(node.id, column)) : []);
|
|
419
|
+
for (const [column, th] of heads)
|
|
420
|
+
th.hidden = gone.has(column);
|
|
421
|
+
for (const [column, td] of footCells)
|
|
422
|
+
td.hidden = gone.has(column);
|
|
223
423
|
const keep = new Set(current.map((line) => line.key));
|
|
224
424
|
for (const [key, row] of rows) {
|
|
225
425
|
if (!keep.has(key)) {
|
|
@@ -240,30 +440,59 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
240
440
|
}
|
|
241
441
|
if (body.children[index] !== row.element)
|
|
242
442
|
body.insertBefore(row.element, body.children[index] ?? null);
|
|
243
|
-
|
|
443
|
+
const now = ruled ? form.lineState(node.id, line.key) : null;
|
|
444
|
+
// A line the table keeps (lineDelete) shows no ×.
|
|
445
|
+
row.remove.hidden = readonly || current.length <= min || now?.deletable === false;
|
|
244
446
|
row.grip.hidden = readonly;
|
|
447
|
+
// Named by where it is now: it moves.
|
|
448
|
+
const lineName = (0, kind_parts_1.fillIn)(labels.lineN, { n: index + 1 });
|
|
449
|
+
row.pick?.setAttribute('aria-label', (0, kind_parts_1.fillIn)(labels.chooseLine, { name: lineName }));
|
|
450
|
+
if (row.copy) {
|
|
451
|
+
row.copy.setAttribute('aria-label', (0, kind_parts_1.fillIn)(labels.copy, { name: lineName }));
|
|
452
|
+
row.copy.title = row.copy.getAttribute('aria-label');
|
|
453
|
+
row.copy.hidden = readonly || current.length >= max;
|
|
454
|
+
}
|
|
245
455
|
if (readonly)
|
|
246
456
|
row.remove.remove();
|
|
247
457
|
else if (!row.remove.isConnected)
|
|
248
458
|
row.element.lastElementChild?.append(row.remove);
|
|
459
|
+
setData(row.element, 'tone', now?.tone);
|
|
460
|
+
row.element.classList.toggle('fd-line-bold', !!now?.bold);
|
|
461
|
+
// A line's buttons act on the saved line, so a read-only table keeps them, as the grid and Flectra's lists do.
|
|
462
|
+
for (const [id, button] of row.buttons)
|
|
463
|
+
button.hidden = !now?.buttons[id];
|
|
464
|
+
// A section's or note's one cell spans the columns shown.
|
|
465
|
+
if (row.kind)
|
|
466
|
+
row.cells[0].td.colSpan = columns.length - gone.size;
|
|
249
467
|
for (const cell of row.cells) {
|
|
250
468
|
const message = errors[`${name}.${line.key}.${cell.name}`];
|
|
469
|
+
const rules = row.kind ? undefined : now?.cells[cell.name];
|
|
470
|
+
if (!row.kind)
|
|
471
|
+
cell.td.hidden = gone.has(cell.name);
|
|
472
|
+
// Hidden by its line, the cell stays, empty, so the column lines up.
|
|
473
|
+
cell.widget.element.hidden = !!rules?.invisible;
|
|
474
|
+
setData(cell.td, 'tone', rules?.tone);
|
|
475
|
+
cell.td.classList.toggle('fd-cell-bold', !!rules?.bold);
|
|
251
476
|
cell.error.hidden = !message;
|
|
252
477
|
cell.error.textContent = message ?? '';
|
|
253
478
|
cell.widget.update({
|
|
254
479
|
value: line.values[cell.name],
|
|
255
480
|
values: line.values,
|
|
481
|
+
parent: state.values,
|
|
256
482
|
// A value worked out from the line's others is shown, never typed.
|
|
257
|
-
readonly: readonly || cell.def.readonly === true || cell.def.compute !== undefined,
|
|
258
|
-
required: cell.def.required === true,
|
|
483
|
+
readonly: readonly || cell.def.readonly === true || cell.def.compute !== undefined || !!rules?.readonly,
|
|
484
|
+
required: cell.def.required === true || !!rules?.required,
|
|
259
485
|
invalid: !!message,
|
|
260
486
|
});
|
|
261
487
|
}
|
|
262
488
|
});
|
|
263
489
|
for (const [column, td] of sums) {
|
|
264
490
|
const sum = current.filter((line) => !(0, core_1.lineKind)(def, line.values)).reduce((total, line) => total + Number(line.values[column] ?? 0), 0);
|
|
265
|
-
td.textContent = (0, display_1.
|
|
491
|
+
td.textContent = (0, display_1.cellText)(def.fields[column], sum, current[0]?.values ?? {}, locale, state.values, node.cells?.[column]);
|
|
266
492
|
}
|
|
493
|
+
for (const { id, button } of controls)
|
|
494
|
+
button.hidden = form.node(id).invisible;
|
|
495
|
+
showChosen();
|
|
267
496
|
if (focusNew && rows.has(focusNew)) {
|
|
268
497
|
rows.get(focusNew)?.cells[0]?.widget.focus();
|
|
269
498
|
focusNew = null;
|
|
@@ -272,4 +501,11 @@ const linesWidget = ({ form, name, field, node, id, document, labels = labels_1.
|
|
|
272
501
|
};
|
|
273
502
|
};
|
|
274
503
|
exports.linesWidget = linesWidget;
|
|
504
|
+
/** A data attribute set, or taken away when there is nothing to say. */
|
|
505
|
+
function setData(element, key, value) {
|
|
506
|
+
if (value)
|
|
507
|
+
element.dataset[key] = value;
|
|
508
|
+
else
|
|
509
|
+
delete element.dataset[key];
|
|
510
|
+
}
|
|
275
511
|
//# sourceMappingURL=lines.js.map
|