@plasmicpkgs/plasmic-rich-components 1.0.74 → 1.0.76

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.
@@ -1,51 +1,95 @@
1
- import { TableSchema } from "@plasmicapp/data-sources";
1
+ import { TableFieldSchema, TableSchema } from "@plasmicapp/data-sources";
2
+ import { PropType } from "@plasmicapp/host/registerComponent";
3
+ import { QueryResult } from "./queries";
2
4
  export declare const tuple: <T extends any[]>(...args: T) => T;
3
5
  export interface HasId {
4
6
  id: string;
5
7
  }
6
8
  export declare function mkIdMap<T extends HasId>(xs: ReadonlyArray<T>): Map<string, T>;
7
9
  export declare const mkShortId: () => string;
8
- export declare const withoutNils: <T>(xs: (T | null | undefined)[]) => T[];
9
- interface AutoSettings {
10
+ export interface AutoSettings {
10
11
  dataType: "auto";
11
12
  }
12
- interface NumberSettings {
13
+ interface _SharedNumberSettings {
14
+ notation?: "standard" | "scientific" | "engineering" | "compact";
15
+ signDisplay?: "auto" | "always" | "exceptZero";
16
+ maximumFractionDigits?: number;
17
+ minimumFractionDigits?: number;
18
+ locale?: string;
19
+ }
20
+ export interface DecimalSettings extends _SharedNumberSettings {
13
21
  dataType: "number";
14
- decimalPlacesExpr: RowFunc<number>;
15
- showThousandsSeparator: boolean;
16
22
  }
17
- interface BooleanSettings {
23
+ export interface PercentSettings extends _SharedNumberSettings {
24
+ dataType: "percent";
25
+ }
26
+ export interface CurrencySettings extends _SharedNumberSettings {
27
+ dataType: "currency";
28
+ currency?: string;
29
+ currencyDisplay?: "symbol" | "narrowSymbol" | "code" | "name";
30
+ }
31
+ export declare const DEFAULT_CURRENCY_SETTINGS: CurrencySettings;
32
+ export type NumberSettings = DecimalSettings | PercentSettings | CurrencySettings;
33
+ export declare const NUMBER_TYPES: readonly ["number", "percent", "currency"];
34
+ export interface DateTimeSettings {
35
+ dataType: "datetime";
36
+ locale?: string;
37
+ dateStyle?: "none" | "full" | "long" | "medium" | "short";
38
+ timeStyle?: "none" | "full" | "long" | "medium" | "short";
39
+ hour12?: boolean;
40
+ timeZone?: string;
41
+ }
42
+ export declare const DEFAULT_DATETIME_SETTINGS: DateTimeSettings;
43
+ export interface RelativeDateTimeSettings {
44
+ dataType: "relative-datetime";
45
+ locale?: string;
46
+ numeric?: "always" | "auto";
47
+ style?: "long" | "short" | "narrow";
48
+ unit?: "year" | "month" | "week" | "day" | "hour" | "minute" | "second";
49
+ }
50
+ export declare const DEFAULT_RELATIVE_DATETIME_SETTINGS: RelativeDateTimeSettings;
51
+ export declare const DATETIME_TYPES: readonly ["datetime", "relative-datetime"];
52
+ export interface BooleanSettings {
18
53
  dataType: "boolean";
19
- showFalseAs: "empty" | "dash" | "cross";
54
+ showAs?: "text" | "checkbox" | "switch";
20
55
  }
21
- interface StringSettings {
56
+ export declare const DEFAULT_BOOLEAN_SETTINGS: BooleanSettings;
57
+ export interface StringSettings {
22
58
  dataType: "string";
23
59
  }
24
- interface StyleConfig {
25
- styles: {};
26
- align: "left" | "center" | "right";
27
- freeze: "off" | "left" | "right";
28
- }
29
- type RowFunc<Result> = (row: Record<string, unknown>) => Result;
60
+ export type RowFunc<Result> = (row: Record<string, unknown>) => Result;
61
+ export type CellFunc<Result> = (row: Record<string, unknown>, value: unknown) => Result;
30
62
  /**
31
63
  * Exprs are for things that can must re-evaluate from row to row.
32
64
  *
33
65
  * Literal values are for things that are column-level. (But in Plasmic Studio, as with all props, you can still use a dynamic value.)
34
66
  */
35
- export type ColumnConfig = {
67
+ interface _BaseColumnConfig {
36
68
  key: string;
37
69
  fieldId?: string;
38
70
  title?: string;
39
- expr?: RowFunc<any>;
40
- isEditableExpr: RowFunc<boolean>;
41
- disableSorting: boolean;
42
- sortByExpr?: RowFunc<any>;
43
71
  isHidden: boolean;
44
- formatting: StyleConfig;
45
- } & (AutoSettings | NumberSettings | StringSettings | BooleanSettings);
46
- export type PartialColumnConfig = Partial<ColumnConfig>;
47
- export declare function deriveFieldConfigs(specifiedFieldsPartial: PartialColumnConfig[], schema: TableSchema | undefined): {
72
+ expr?: CellFunc<any>;
73
+ }
74
+ export type BaseColumnConfig = _BaseColumnConfig & (AutoSettings | NumberSettings | StringSettings | BooleanSettings | DateTimeSettings | RelativeDateTimeSettings);
75
+ export declare function deriveFieldConfigs<ColumnConfig extends BaseColumnConfig>(specifiedFieldsPartial: Partial<ColumnConfig>[], schema: TableSchema | undefined, makeDefaultConfig: (field: TableFieldSchema | undefined) => ColumnConfig): {
48
76
  mergedFields: ColumnConfig[];
49
- minimalFullLengthFields: PartialColumnConfig[];
77
+ minimalFullLengthFields: Partial<ColumnConfig>[];
50
78
  };
79
+ export declare function deriveValueType(cconfig: BaseColumnConfig): "text" | "switch" | "digit" | undefined;
80
+ export interface ControlContextData<ColumnConfig extends BaseColumnConfig> {
81
+ data: unknown[];
82
+ schema?: TableSchema;
83
+ mergedFields: ColumnConfig[];
84
+ minimalFullLengthFields: Partial<ColumnConfig>[];
85
+ }
86
+ export interface FieldfulProps<ColumnConfig extends BaseColumnConfig> {
87
+ className?: string;
88
+ data?: QueryResult;
89
+ fields?: Partial<ColumnConfig>[];
90
+ setControlContextData?: (ctx: ControlContextData<ColumnConfig>) => void;
91
+ }
92
+ export declare function buildFieldsPropType<ColumnConfig extends BaseColumnConfig, Props extends FieldfulProps<ColumnConfig>>(opts: {
93
+ fieldTypes?: Record<string, PropType<any>>;
94
+ }): PropType<Props>;
51
95
  export {};
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { BaseColumnConfig } from "./field-mappings";
3
+ export declare function renderValue(value: any, record: any, cconfig: BaseColumnConfig): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Registerable } from "./utils";
2
2
  export { RichLayout } from "./rich-layout";
3
3
  export { RichTable, tableHelpers } from "./rich-table";
4
+ export { RichDetails } from "./rich-details";
4
5
  export declare function registerAll(loader?: Registerable): void;