@pretable/core 0.6.1 → 0.7.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/LICENSE +19 -0
- package/dist/index.cjs +8 -3
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.mjs +8 -3
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -19,3 +19,22 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Acknowledgements
|
|
26
|
+
|
|
27
|
+
@chenglou/pretext — MIT, Copyright (c) Pretext contributors
|
|
28
|
+
https://github.com/chenglou/pretext
|
|
29
|
+
|
|
30
|
+
Pretable's text layout predictor (`@pretable-internal/text-core`, together with
|
|
31
|
+
the canvas-backed measurer in `@pretable/react`) follows pretext's two-phase
|
|
32
|
+
design: measure each segment once, cache the result by (segment, font), and then
|
|
33
|
+
decide line breaks with pure arithmetic over those cached widths. Before that,
|
|
34
|
+
pretable modelled a whole font as a single number — pixels per character — and
|
|
35
|
+
wrapped by character count.
|
|
36
|
+
|
|
37
|
+
This is our own implementation against a different API, written independently
|
|
38
|
+
rather than adapted from pretext's source, so this acknowledgement is a courtesy
|
|
39
|
+
rather than a licence obligation. It is recorded because the idea is the load-
|
|
40
|
+
bearing part and it was not ours.
|
package/dist/index.cjs
CHANGED
|
@@ -2002,9 +2002,14 @@ function validateFilterOperand(column, filter, path) {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
if (!Array.isArray(value))
|
|
2004
2004
|
fail("selection operand must be an array", path, column.id);
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2005
|
+
if (column.type === "boolean") {
|
|
2006
|
+
if (value.some((entry) => typeof entry !== "boolean" && entry !== "true" && entry !== "false")) {
|
|
2007
|
+
fail('boolean selection must contain only boolean values or the strings "true"/"false"', path, column.id);
|
|
2008
|
+
}
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
if (value.some((entry) => typeof entry !== "string")) {
|
|
2012
|
+
fail(`${column.type} selection must contain only string values`, path, column.id);
|
|
2008
2013
|
}
|
|
2009
2014
|
}
|
|
2010
2015
|
function validateQuery(query, columns) {
|
package/dist/index.d.cts
CHANGED
|
@@ -64,6 +64,12 @@ interface PretableColumnDefinition<TRow extends object, TId extends string, TVal
|
|
|
64
64
|
readonly value: (row: TRow) => TValue;
|
|
65
65
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
66
66
|
readonly aggregate?: TAggregate;
|
|
67
|
+
/**
|
|
68
|
+
* Native number presentation. Outranked by `format` for data cells and by
|
|
69
|
+
* `formatAggregate` for group aggregates; derivation, editing, and every
|
|
70
|
+
* row-model read continue to see the raw value.
|
|
71
|
+
*/
|
|
72
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
67
73
|
readonly format?: (input: PretableFormatInput<TRow, TValue, PretableColumnDefinition<TRow, TId, TValue, TType, TAggregate>>) => string;
|
|
68
74
|
readonly formatAggregate?: (input: PretableAggregateFormatInput<PretableAggregateOutputOf<TAggregate>, PretableColumnDefinition<TRow, TId, TValue, TType, TAggregate>>) => string;
|
|
69
75
|
readonly [columnDescriptor]: {
|
|
@@ -90,6 +96,8 @@ type PretableColumnOptions<TRow extends object, TId extends string, TValue, TTyp
|
|
|
90
96
|
readonly header?: string;
|
|
91
97
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
92
98
|
readonly aggregate?: TAggregate;
|
|
99
|
+
/** Native number presentation; `format` outranks it for data cells. */
|
|
100
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
93
101
|
readonly format?: (input: {
|
|
94
102
|
readonly value: TValue;
|
|
95
103
|
readonly row: TRow;
|
|
@@ -107,6 +115,8 @@ interface PretableColumnHelper<TRow extends object> {
|
|
|
107
115
|
readonly header?: string;
|
|
108
116
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
109
117
|
readonly aggregate?: TAggregate;
|
|
118
|
+
/** Native number presentation; `format` outranks it for data cells. */
|
|
119
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
110
120
|
readonly format?: (input: {
|
|
111
121
|
readonly value: TValue;
|
|
112
122
|
readonly row: TRow;
|
|
@@ -784,6 +794,20 @@ interface PretableResultMeta {
|
|
|
784
794
|
total?: PretableMatchingTotal;
|
|
785
795
|
/** Stable identity for the query/result population represented by the rows. */
|
|
786
796
|
datasetKey?: string;
|
|
797
|
+
/**
|
|
798
|
+
* Where the loaded rows sit inside the population, when they are a window
|
|
799
|
+
* rather than a prefix. Absent means the classic prefix case.
|
|
800
|
+
*
|
|
801
|
+
* `hasMore` rather than a remaining count: a keyset cursor walks forward, so
|
|
802
|
+
* the extent must promise only what is fetchable. A count would invite a
|
|
803
|
+
* scrollbar that reaches rows the cursor cannot serve.
|
|
804
|
+
*/
|
|
805
|
+
window?: {
|
|
806
|
+
/** Dataset index of `rows[0]`. */
|
|
807
|
+
readonly start: number;
|
|
808
|
+
/** Whether anything follows this window. NOT how much. */
|
|
809
|
+
readonly hasMore: boolean;
|
|
810
|
+
};
|
|
787
811
|
}
|
|
788
812
|
/**
|
|
789
813
|
* One entry in the ordered sort list; index in the list = priority.
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,12 @@ interface PretableColumnDefinition<TRow extends object, TId extends string, TVal
|
|
|
64
64
|
readonly value: (row: TRow) => TValue;
|
|
65
65
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
66
66
|
readonly aggregate?: TAggregate;
|
|
67
|
+
/**
|
|
68
|
+
* Native number presentation. Outranked by `format` for data cells and by
|
|
69
|
+
* `formatAggregate` for group aggregates; derivation, editing, and every
|
|
70
|
+
* row-model read continue to see the raw value.
|
|
71
|
+
*/
|
|
72
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
67
73
|
readonly format?: (input: PretableFormatInput<TRow, TValue, PretableColumnDefinition<TRow, TId, TValue, TType, TAggregate>>) => string;
|
|
68
74
|
readonly formatAggregate?: (input: PretableAggregateFormatInput<PretableAggregateOutputOf<TAggregate>, PretableColumnDefinition<TRow, TId, TValue, TType, TAggregate>>) => string;
|
|
69
75
|
readonly [columnDescriptor]: {
|
|
@@ -90,6 +96,8 @@ type PretableColumnOptions<TRow extends object, TId extends string, TValue, TTyp
|
|
|
90
96
|
readonly header?: string;
|
|
91
97
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
92
98
|
readonly aggregate?: TAggregate;
|
|
99
|
+
/** Native number presentation; `format` outranks it for data cells. */
|
|
100
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
93
101
|
readonly format?: (input: {
|
|
94
102
|
readonly value: TValue;
|
|
95
103
|
readonly row: TRow;
|
|
@@ -107,6 +115,8 @@ interface PretableColumnHelper<TRow extends object> {
|
|
|
107
115
|
readonly header?: string;
|
|
108
116
|
readonly compare?: (left: TValue, right: TValue) => number;
|
|
109
117
|
readonly aggregate?: TAggregate;
|
|
118
|
+
/** Native number presentation; `format` outranks it for data cells. */
|
|
119
|
+
readonly numberFormat?: Intl.NumberFormatOptions;
|
|
110
120
|
readonly format?: (input: {
|
|
111
121
|
readonly value: TValue;
|
|
112
122
|
readonly row: TRow;
|
|
@@ -784,6 +794,20 @@ interface PretableResultMeta {
|
|
|
784
794
|
total?: PretableMatchingTotal;
|
|
785
795
|
/** Stable identity for the query/result population represented by the rows. */
|
|
786
796
|
datasetKey?: string;
|
|
797
|
+
/**
|
|
798
|
+
* Where the loaded rows sit inside the population, when they are a window
|
|
799
|
+
* rather than a prefix. Absent means the classic prefix case.
|
|
800
|
+
*
|
|
801
|
+
* `hasMore` rather than a remaining count: a keyset cursor walks forward, so
|
|
802
|
+
* the extent must promise only what is fetchable. A count would invite a
|
|
803
|
+
* scrollbar that reaches rows the cursor cannot serve.
|
|
804
|
+
*/
|
|
805
|
+
window?: {
|
|
806
|
+
/** Dataset index of `rows[0]`. */
|
|
807
|
+
readonly start: number;
|
|
808
|
+
/** Whether anything follows this window. NOT how much. */
|
|
809
|
+
readonly hasMore: boolean;
|
|
810
|
+
};
|
|
787
811
|
}
|
|
788
812
|
/**
|
|
789
813
|
* One entry in the ordered sort list; index in the list = priority.
|
package/dist/index.mjs
CHANGED
|
@@ -2000,9 +2000,14 @@ function validateFilterOperand(column, filter, path) {
|
|
|
2000
2000
|
}
|
|
2001
2001
|
if (!Array.isArray(value))
|
|
2002
2002
|
fail("selection operand must be an array", path, column.id);
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2003
|
+
if (column.type === "boolean") {
|
|
2004
|
+
if (value.some((entry) => typeof entry !== "boolean" && entry !== "true" && entry !== "false")) {
|
|
2005
|
+
fail('boolean selection must contain only boolean values or the strings "true"/"false"', path, column.id);
|
|
2006
|
+
}
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
if (value.some((entry) => typeof entry !== "string")) {
|
|
2010
|
+
fail(`${column.type} selection must contain only string values`, path, column.id);
|
|
2006
2011
|
}
|
|
2007
2012
|
}
|
|
2008
2013
|
function validateQuery(query, columns) {
|