@operato/data-grist 7.0.59 → 7.0.64

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/src/data-card/data-card-gutter.js +4 -4
  3. package/dist/src/data-card/data-card-gutter.js.map +1 -1
  4. package/dist/src/record-view/record-view-body.js +47 -25
  5. package/dist/src/record-view/record-view-body.js.map +1 -1
  6. package/dist/src/types.d.ts +3 -0
  7. package/dist/src/types.js.map +1 -1
  8. package/dist/stories/default-filters.stories copy.d.ts +26 -0
  9. package/dist/stories/default-filters.stories copy.js +219 -0
  10. package/dist/stories/default-filters.stories copy.js.map +1 -0
  11. package/dist/stories/fixed-column.stories.js +5 -1
  12. package/dist/stories/fixed-column.stories.js.map +1 -1
  13. package/dist/stories/grid-setting.stories.js +5 -1
  14. package/dist/stories/grid-setting.stories.js.map +1 -1
  15. package/dist/stories/grist-modes.stories.js +2 -1
  16. package/dist/stories/grist-modes.stories.js.map +1 -1
  17. package/dist/stories/group-header.stories.js +2 -1
  18. package/dist/stories/group-header.stories.js.map +1 -1
  19. package/dist/stories/record-view.stories.d.ts +24 -0
  20. package/dist/stories/record-view.stories.js +125 -0
  21. package/dist/stories/record-view.stories.js.map +1 -0
  22. package/dist/stories/textarea.stories.js +2 -1
  23. package/dist/stories/textarea.stories.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +11 -11
  26. package/src/data-card/data-card-gutter.ts +4 -4
  27. package/src/record-view/record-view-body.ts +47 -25
  28. package/src/types.ts +3 -0
  29. package/stories/fixed-column.stories.ts +5 -1
  30. package/stories/grid-setting.stories.ts +5 -1
  31. package/stories/grist-modes.stories.ts +2 -1
  32. package/stories/group-header.stories.ts +2 -1
  33. package/stories/record-view.stories.ts +143 -0
  34. package/stories/textarea.stories.ts +2 -1
  35. package/tsconfig.json +1 -0
@@ -30,27 +30,6 @@ export class RecordViewBody extends LitElement {
30
30
  box-sizing: border-box;
31
31
  }
32
32
 
33
- @media only screen and (max-width: 600px) {
34
- div[content] {
35
- grid-template-columns: 2fr 3fr;
36
- padding: var(--spacing-medium);
37
- }
38
- }
39
-
40
- @media only screen and (min-width: 1200px) {
41
- div[content] {
42
- grid-template-columns: 1fr 3fr 1fr 3fr;
43
- }
44
- }
45
-
46
- @media only screen and (min-width: 1600px) {
47
- div[content] {
48
- grid-template-columns: 1fr 3fr 1fr 3fr;
49
- width: 95%;
50
- margin: auto;
51
- }
52
- }
53
-
54
33
  label {
55
34
  display: flex;
56
35
  align-items: center;
@@ -63,6 +42,10 @@ export class RecordViewBody extends LitElement {
63
42
  padding-right: var(--spacing-large);
64
43
  }
65
44
 
45
+ label[wide] {
46
+ grid-column: 1 / 2;
47
+ }
48
+
66
49
  label md-icon {
67
50
  display: none;
68
51
  }
@@ -93,10 +76,47 @@ export class RecordViewBody extends LitElement {
93
76
  border: var(--record-view-edit-border);
94
77
  }
95
78
 
79
+ ox-grid-field[wide] {
80
+ grid-column: 2 / 5;
81
+ width: 100%;
82
+ max-width: unset;
83
+ }
84
+
96
85
  :first-child + ox-grid-field {
97
86
  color: var(--record-view-focus-color);
98
87
  font-weight: bold;
99
88
  }
89
+
90
+ @media only screen and (max-width: 600px) {
91
+ div[content] {
92
+ grid-template-columns: 2fr 3fr;
93
+ padding: var(--spacing-medium);
94
+ }
95
+
96
+ label[wide] {
97
+ grid-column: 1 / 2;
98
+ }
99
+
100
+ ox-grid-field[wide] {
101
+ grid-column: 1 / 3;
102
+ width: 100%;
103
+ max-width: unset;
104
+ }
105
+ }
106
+
107
+ @media only screen and (min-width: 1200px) {
108
+ div[content] {
109
+ grid-template-columns: 1fr 3fr 1fr 3fr;
110
+ }
111
+ }
112
+
113
+ @media only screen and (min-width: 1600px) {
114
+ div[content] {
115
+ grid-template-columns: 1fr 3fr 1fr 3fr;
116
+ width: 95%;
117
+ margin: auto;
118
+ }
119
+ }
100
120
  `
101
121
  ]
102
122
 
@@ -145,7 +165,7 @@ export class RecordViewBody extends LitElement {
145
165
  return html`
146
166
  <div content>
147
167
  ${columns.map((column, index) => {
148
- let { editable, mandatory } = column.record
168
+ let { editable, mandatory, wide } = column.record
149
169
  if (typeof editable === 'function') {
150
170
  editable = editable.call(this, record[column.name], column, record, rowIndex, this)
151
171
  }
@@ -153,9 +173,10 @@ export class RecordViewBody extends LitElement {
153
173
  let dirtyFields = record['__dirtyfields__'] || {}
154
174
 
155
175
  return html`
156
- <label ?editable=${editable}
157
- ><span>${mandatory ? '*' : ''}${this._renderLabel(column)}</span> <md-icon>edit</md-icon></label
158
- >
176
+ <label ?editable=${editable} ?wide=${wide}>
177
+ <span>${mandatory ? '*' : ''}${this._renderLabel(column)}</span>
178
+ <md-icon>edit</md-icon>
179
+ </label>
159
180
  <ox-grid-field
160
181
  .rowIndex=${rowIndex}
161
182
  .column=${column}
@@ -163,6 +184,7 @@ export class RecordViewBody extends LitElement {
163
184
  .value=${record[column.name]}
164
185
  ?dirty=${!!dirtyFields[column.name]}
165
186
  ?tabstop=${!!editable}
187
+ ?wide=${wide}
166
188
  ></ox-grid-field>
167
189
  `
168
190
  })}
package/src/types.ts CHANGED
@@ -501,6 +501,8 @@ export type DefaultValueFnConfig =
501
501
  * @property {DefaultValueFnConfig|undefined} [defaultValue] - Configuration for specifying the default value for the field.
502
502
  * It can be a predefined value generator function or a custom user-defined function (optional).
503
503
  * @property {Object.<string, *>|undefined} [extended] - Additional extended properties that can be added as needed for specific field configurations (optional).
504
+ * @property {boolean} [wide] - Specifies if the field should occupy a larger width within the viewer or editor.
505
+ * When set to `true`, the field will attempt to span across multiple columns or occupy more space horizontally.
504
506
  */
505
507
  export type RecordConfig = {
506
508
  renderer: FieldRenderer
@@ -512,6 +514,7 @@ export type RecordConfig = {
512
514
  options: any
513
515
  rowOptionField?: string
514
516
  defaultValue?: DefaultValueFnConfig
517
+ wide?: boolean
515
518
  [extended: string]: any
516
519
  }
517
520
 
@@ -248,6 +248,9 @@ const config = {
248
248
  type: 'json5',
249
249
  name: 'json5',
250
250
  header: 'JSON5',
251
+ record: {
252
+ wide: true
253
+ },
251
254
  width: 200
252
255
  },
253
256
  {
@@ -255,7 +258,8 @@ const config = {
255
258
  name: 'thumbnail',
256
259
  header: 'thumbnail',
257
260
  record: {
258
- editable: true
261
+ editable: true,
262
+ wide: true
259
263
  },
260
264
  width: 120
261
265
  },
@@ -255,6 +255,9 @@ const config = {
255
255
  type: 'json5',
256
256
  name: 'json5',
257
257
  header: 'JSON5',
258
+ record: {
259
+ wide: true
260
+ },
258
261
  width: 200
259
262
  },
260
263
  {
@@ -262,7 +265,8 @@ const config = {
262
265
  name: 'thumbnail',
263
266
  header: 'thumbnail',
264
267
  record: {
265
- editable: true
268
+ editable: true,
269
+ wide: true
266
270
  },
267
271
  width: 120
268
272
  },
@@ -260,7 +260,8 @@ const config = {
260
260
  name: 'thumbnail',
261
261
  header: 'thumbnail',
262
262
  record: {
263
- editable: true
263
+ editable: true,
264
+ wide: true
264
265
  },
265
266
  width: 120
266
267
  },
@@ -284,7 +284,8 @@ const config = {
284
284
  group: '2023'
285
285
  },
286
286
  record: {
287
- editable: true
287
+ editable: true,
288
+ wide: true
288
289
  },
289
290
  width: 120
290
291
  },
@@ -0,0 +1,143 @@
1
+ import '@material/web/icon/icon.js'
2
+ import '../src/index.js'
3
+ import '../src/record-view/record-view-body.js'
4
+
5
+ import { html, TemplateResult } from 'lit'
6
+ import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'
7
+
8
+ import { CommonGristStyles } from '@operato/styles'
9
+ import { ColumnConfig, GristRecord } from '../src/types.js'
10
+ import { buildColumn } from '../src/configure/column-builder.js'
11
+ import { ZERO_RECORD } from '../src/index.js'
12
+
13
+ const columnsConfig: ColumnConfig[] = [
14
+ {
15
+ type: 'string',
16
+ name: 'id',
17
+ hidden: true
18
+ },
19
+ {
20
+ type: 'string',
21
+ name: 'name',
22
+ label: true,
23
+ header: 'name',
24
+ record: {
25
+ editable: true
26
+ },
27
+ filter: 'search',
28
+ sortable: true,
29
+ width: 120
30
+ },
31
+ {
32
+ type: 'string',
33
+ name: 'description',
34
+ header: 'description',
35
+ filter: 'search',
36
+ record: {
37
+ editable: true,
38
+ align: 'left'
39
+ },
40
+ width: 200
41
+ },
42
+ {
43
+ type: 'textarea',
44
+ name: 'textarea',
45
+ label: true,
46
+ header: 'textarea',
47
+ record: {
48
+ editable: true,
49
+ wide: true
50
+ },
51
+ filter: 'search',
52
+ sortable: true,
53
+ width: 130
54
+ },
55
+ {
56
+ type: 'datetime',
57
+ name: 'updatedAt',
58
+ header: 'updated at',
59
+ record: {
60
+ editable: true,
61
+ defaultValue: {
62
+ name: 'now'
63
+ }
64
+ },
65
+ filter: 'between',
66
+ sortable: true,
67
+ width: 180
68
+ },
69
+ {
70
+ type: 'datetime',
71
+ name: 'createdAt',
72
+ header: 'created at',
73
+ record: {
74
+ editable: false
75
+ },
76
+ sortable: true,
77
+ width: 180
78
+ }
79
+ ].map((column: any) => buildColumn(column))
80
+
81
+ const record: GristRecord = ZERO_RECORD
82
+
83
+ export default {
84
+ title: 'ox-record-view-body',
85
+ component: 'ox-record-view-body',
86
+ argTypes: {
87
+ headerFilter: { control: 'boolean' }
88
+ }
89
+ }
90
+
91
+ interface Story<T> {
92
+ (args: T): TemplateResult
93
+ args?: Partial<T>
94
+ argTypes?: Record<string, unknown>
95
+ }
96
+
97
+ interface ArgTypes {
98
+ headerFilter: boolean
99
+ theme?: 'light' | 'dark'
100
+ }
101
+
102
+ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) => html`
103
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
104
+
105
+ <link href="/themes/light.css" rel="stylesheet" />
106
+ <link href="/themes/dark.css" rel="stylesheet" />
107
+ <link href="/themes/spacing.css" rel="stylesheet" />
108
+ <link href="/themes/grist-theme.css" rel="stylesheet" />
109
+
110
+ <link
111
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
112
+ rel="stylesheet"
113
+ />
114
+ <link
115
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
116
+ rel="stylesheet"
117
+ />
118
+ <link
119
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
120
+ rel="stylesheet"
121
+ />
122
+
123
+ <style>
124
+ ${MDTypeScaleStyles.cssText}
125
+ </style>
126
+
127
+ <style>
128
+ ${CommonGristStyles.cssText}
129
+ </style>
130
+
131
+ <style>
132
+ ox-record-view-body {
133
+ height: 600px;
134
+ }
135
+ </style>
136
+
137
+ <ox-record-view-body .columns=${columnsConfig} .record=${record}> </ox-record-view-body>
138
+ `
139
+
140
+ export const Regular = Template.bind({})
141
+ Regular.args = {
142
+ headerFilter: true
143
+ }
@@ -117,7 +117,8 @@ const config = {
117
117
  label: true,
118
118
  header: 'textarea',
119
119
  record: {
120
- editable: true
120
+ editable: true,
121
+ wide: true
121
122
  },
122
123
  filter: 'search',
123
124
  sortable: true,
package/tsconfig.json CHANGED
@@ -18,6 +18,7 @@
18
18
  "rootDir": "./",
19
19
  "declaration": true,
20
20
  "incremental": true,
21
+ "skipLibCheck": true,
21
22
  "types": ["node", "mocha"]
22
23
  },
23
24
  "include": ["**/*.ts", "*.d.ts"],