@operato/dataset 1.14.0 → 1.14.2

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 (31) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/demo/favicon.ico +0 -0
  3. package/demo/index.html +338 -0
  4. package/demo/ox-data-ooc-brief-view-test.html +338 -0
  5. package/dist/src/ox-data-ooc-brief-view.js +0 -1
  6. package/dist/src/ox-data-ooc-brief-view.js.map +1 -1
  7. package/dist/src/ox-data-ooc-correction-part.js +0 -1
  8. package/dist/src/ox-data-ooc-correction-part.js.map +1 -1
  9. package/dist/src/ox-data-ooc-view.js +0 -1
  10. package/dist/src/ox-data-ooc-view.js.map +1 -1
  11. package/dist/src/usecase/spc/index.d.ts +1 -0
  12. package/dist/src/usecase/spc/index.js +8 -0
  13. package/dist/src/usecase/spc/index.js.map +1 -0
  14. package/dist/src/usecase/spc/ox-data-use-case-spc.d.ts +7 -0
  15. package/dist/src/usecase/spc/ox-data-use-case-spc.js +102 -0
  16. package/dist/src/usecase/spc/ox-data-use-case-spc.js.map +1 -0
  17. package/dist/src/usecase/spc/ox-input-spc-limits.d.ts +44 -0
  18. package/dist/src/usecase/spc/ox-input-spc-limits.js +193 -0
  19. package/dist/src/usecase/spc/ox-input-spc-limits.js.map +1 -0
  20. package/dist/src/usecase/spc/ox-property-editor-spc-limits.d.ts +6 -0
  21. package/dist/src/usecase/spc/ox-property-editor-spc-limits.js +24 -0
  22. package/dist/src/usecase/spc/ox-property-editor-spc-limits.js.map +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +5 -5
  25. package/src/ox-data-ooc-brief-view.ts +0 -1
  26. package/src/ox-data-ooc-correction-part.ts +0 -1
  27. package/src/ox-data-ooc-view.ts +0 -1
  28. package/src/usecase/spc/index.ts +10 -0
  29. package/src/usecase/spc/ox-data-use-case-spc.ts +147 -0
  30. package/src/usecase/spc/ox-input-spc-limits.ts +182 -0
  31. package/src/usecase/spc/ox-property-editor-spc-limits.ts +23 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/dataset",
3
3
  "description": "WebApplication dataset supporting components following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "1.14.0",
5
+ "version": "1.14.2",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "exports": {
@@ -110,12 +110,12 @@
110
110
  "@material/mwc-icon-button": "^0.27.0",
111
111
  "@operato/data-grist": "^1.14.0",
112
112
  "@operato/graphql": "^1.12.9",
113
- "@operato/grist-editor": "^1.14.0",
113
+ "@operato/grist-editor": "^1.14.1",
114
114
  "@operato/i18n": "^1.5.14",
115
115
  "@operato/input": "^1.13.14",
116
116
  "@operato/popup": "^1.13.9",
117
- "@operato/property-editor": "^1.14.0",
118
- "@operato/shell": "^1.13.9",
117
+ "@operato/property-editor": "^1.14.1",
118
+ "@operato/shell": "^1.14.1",
119
119
  "@operato/styles": "^1.12.3",
120
120
  "@operato/utils": "^1.13.9",
121
121
  "lit": "^2.5.0"
@@ -152,5 +152,5 @@
152
152
  "prettier --write"
153
153
  ]
154
154
  },
155
- "gitHead": "b7a6a59d2bd40418ee530cd7a0561b52156d3ca7"
155
+ "gitHead": "0612202892166b995c92e75955269f2ae961b3bf"
156
156
  }
@@ -15,7 +15,6 @@ export class OxDataOocBriefView extends LitElement {
15
15
  :host {
16
16
  display: flex;
17
17
  flex-direction: column;
18
- background-color: var(--main-section-background-color);
19
18
 
20
19
  position: relative;
21
20
  }
@@ -14,7 +14,6 @@ export class OxDataOocCorrectionPart extends LitElement {
14
14
  :host {
15
15
  display: flex;
16
16
  flex-direction: column;
17
- background-color: var(--main-section-background-color);
18
17
 
19
18
  position: relative;
20
19
  }
@@ -19,7 +19,6 @@ export class OxDataOocView extends LitElement {
19
19
  :host {
20
20
  display: flex;
21
21
  flex-direction: column;
22
- background-color: var(--main-section-background-color);
23
22
 
24
23
  position: relative;
25
24
  }
@@ -0,0 +1,10 @@
1
+ /* Here, only the common module of client and server is imported/exported. Be careful not to use a module dedicated to client or server. */
2
+
3
+ import { OxDataUseCase } from '../ox-data-use-case'
4
+ import { OxDataUseCaseSPC } from './ox-data-use-case-spc'
5
+
6
+ // OxPropertyEditor.register({
7
+ // 'spc-limits': 'ox-property-editor-spc-limits'
8
+ // })
9
+
10
+ OxDataUseCase.registerUseCase('SPC', new OxDataUseCaseSPC())
@@ -0,0 +1,147 @@
1
+ import i18next from 'i18next' // Since this is a common module, @operato/i18n was deliberately avoided.
2
+
3
+ import { DataItem, EvaluationResult, UseCaseDefinition } from '../../types'
4
+ import { OxDataUseCase } from '../ox-data-use-case.js'
5
+
6
+ export class OxDataUseCaseSPC extends OxDataUseCase {
7
+ getSpecification(dataItem: DataItem): UseCaseDefinition {
8
+ return {
9
+ name: 'SPC',
10
+ description: 'Critical Control Point Data Spec',
11
+ help: '',
12
+ specs: [
13
+ {
14
+ type: 'spc-limits' /* A value which seperates acceptability from unacceptability */,
15
+ label: 'critical-limits',
16
+ name: 'criticalLimits',
17
+ property: dataItem
18
+ },
19
+ {
20
+ type: 'spc-limits',
21
+ label: 'target-limits',
22
+ name: 'targetLimits',
23
+ property: dataItem
24
+ }
25
+ ]
26
+ }
27
+ }
28
+
29
+ evaluate(spec: any, values: any | any[]): EvaluationResult | undefined {
30
+ if (!spec || typeof values === 'undefined') {
31
+ return
32
+ }
33
+
34
+ if (!(values instanceof Array)) {
35
+ values = [values]
36
+ }
37
+
38
+ const {
39
+ minimum: criticalMinimum,
40
+ maximum: criticalMaximum,
41
+ acceptables: criticalAcceptables
42
+ } = spec['criticalLimits'] || {}
43
+
44
+ const {
45
+ minimum: targetMinimum,
46
+ maximum: targetMaximum,
47
+ acceptables: targetAcceptables
48
+ } = spec['targetLimits'] || {}
49
+
50
+ var oos = false
51
+ var ooc = false
52
+
53
+ for (let i = 0; i < values.length; i++) {
54
+ const value = values[i]
55
+
56
+ if (criticalMinimum != null && value < criticalMinimum) {
57
+ oos = true
58
+ break
59
+ }
60
+
61
+ if (criticalMaximum != null && value > criticalMaximum) {
62
+ oos = true
63
+ break
64
+ }
65
+
66
+ if (criticalAcceptables != null && !criticalAcceptables.includes(value)) {
67
+ oos = true
68
+ break
69
+ }
70
+ }
71
+
72
+ for (let i = 0; i < values.length; i++) {
73
+ const value = values[i]
74
+
75
+ if (targetMinimum != null && value < targetMinimum) {
76
+ ooc = true
77
+ break
78
+ }
79
+
80
+ if (targetMaximum != null && value > targetMaximum) {
81
+ ooc = true
82
+ break
83
+ }
84
+
85
+ if (targetAcceptables != null && !targetAcceptables.includes(value)) {
86
+ ooc = true
87
+ break
88
+ }
89
+ }
90
+
91
+ return { oos, ooc }
92
+ }
93
+
94
+ elaborateUseCaseSpec(limits: any): string | undefined {
95
+ if (!limits) {
96
+ return
97
+ }
98
+
99
+ var text = ''
100
+
101
+ const {
102
+ minimum: criticalMinimum,
103
+ maximum: criticalMaximum,
104
+ acceptables: criticalAcceptables
105
+ } = limits['criticalLimits'] || {}
106
+
107
+ if (criticalMinimum != null || criticalMaximum != null || criticalAcceptables != null) {
108
+ text += `${i18next.t('label.critical-limits')}\n`
109
+ }
110
+
111
+ if (criticalMinimum != null) {
112
+ text += `\t${i18next.t('label.minimum value')} : ${criticalMinimum}\n`
113
+ }
114
+ if (criticalMaximum != null) {
115
+ text += `\t${i18next.t('label.maximum value')} : ${criticalMaximum}\n`
116
+ }
117
+ if (criticalAcceptables != null) {
118
+ text += `\t${i18next.t('label.acceptables')} : ${
119
+ criticalAcceptables instanceof Array ? criticalAcceptables.join(', ') : criticalAcceptables
120
+ }\n`
121
+ }
122
+
123
+ const {
124
+ minimum: targetMinimum,
125
+ maximum: targetMaximum,
126
+ acceptables: targetAcceptables
127
+ } = limits['targetLimits'] || {}
128
+
129
+ if (targetMinimum != null || targetMaximum != null || targetAcceptables != null) {
130
+ text += `${i18next.t('label.target-limits')}\n`
131
+ }
132
+
133
+ if (targetMinimum != null) {
134
+ text += `\t${i18next.t('label.minimum value')} : ${targetMinimum}\n`
135
+ }
136
+ if (targetMaximum != null) {
137
+ text += `\t${i18next.t('label.maximum value')} : ${targetMaximum}\n`
138
+ }
139
+ if (targetAcceptables != null) {
140
+ text += `\t${i18next.t('label.acceptables')} : ${
141
+ targetAcceptables instanceof Array ? targetAcceptables.join(', ') : targetAcceptables
142
+ }\n`
143
+ }
144
+
145
+ return text
146
+ }
147
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { css, html, LitElement } from 'lit'
6
+ import { customElement, property, query, queryAll } from 'lit/decorators.js'
7
+
8
+ import { i18next } from '@operato/i18n'
9
+
10
+ export enum DataItemType {
11
+ number = 'number',
12
+ text = 'text',
13
+ boolean = 'boolean',
14
+ select = 'select',
15
+ file = 'file'
16
+ }
17
+
18
+ export type SpcLimitValue = {
19
+ minimum?: number
20
+ maximum?: number
21
+ acceptables?: string[] | boolean[]
22
+ }
23
+
24
+ /**
25
+ element for SPC limits
26
+
27
+ Example:
28
+
29
+ <ox-input-spc-limits
30
+ .value=${value}
31
+ .type=${type}>
32
+ </ox-input-spc-limits>
33
+ */
34
+ @customElement('ox-input-spc-limits')
35
+ export class OxInputSpcLimits extends LitElement {
36
+ static styles = css`
37
+ :host {
38
+ display: flex;
39
+ flex-direction: column;
40
+ align-content: center;
41
+ }
42
+
43
+ label {
44
+ margin: 0 var(--margin-default) var(--margin-default) 0;
45
+ }
46
+
47
+ label div > * {
48
+ vertical-align: middle;
49
+ }
50
+
51
+ button {
52
+ width: 20px;
53
+ text-align: center;
54
+ }
55
+
56
+ div[name],
57
+ input[type='checkbox'] + span {
58
+ display: inline-block;
59
+ font: var(--label-font);
60
+ color: var(--label-color);
61
+ text-align: right;
62
+ }
63
+ input,
64
+ select {
65
+ border: var(--input-field-border);
66
+ border-radius: var(--input-field-border-radius);
67
+ padding: var(--input-field-padding);
68
+ font: var(--input-field-font);
69
+ }
70
+
71
+ input[type='checkbox'] {
72
+ width: initial;
73
+ }
74
+ input[checked] + span {
75
+ font-weight: bold;
76
+ }
77
+ [unit],
78
+ [value] {
79
+ display: inline-block;
80
+ opacity: 0.7;
81
+ font: var(--form-sublabel-font);
82
+ }
83
+ [properties] {
84
+ font: var(--input-field-font);
85
+ color: var(--label-color);
86
+ }
87
+ `
88
+
89
+ @property({ type: Object }) value: SpcLimitValue = {}
90
+ @property({ type: String }) type: DataItemType = DataItemType.number
91
+ @property({ type: String }) unit?: string
92
+ @property({ type: Object }) options: { options?: { text: string; value: string }[] } = {}
93
+
94
+ @query('[name=minimum]') minimum!: HTMLInputElement
95
+ @query('[name=maximum]') maximum!: HTMLInputElement
96
+ @queryAll('[type=checkbox]:checked') checkedAll!: NodeListOf<HTMLInputElement>
97
+
98
+ firstUpdated() {
99
+ this.renderRoot.addEventListener('change', this.onChange.bind(this))
100
+ }
101
+
102
+ render() {
103
+ const { minimum, maximum, acceptables = [] } = this.value || {}
104
+
105
+ return html`
106
+ <div>
107
+ ${this.type === DataItemType.number
108
+ ? html`
109
+ <label>
110
+ <div name>${i18next.t('text.minimum value')}</div>
111
+ <input type="number" name="minimum" .value=${String(minimum)} />
112
+ <div unit>${this.unit}</div>
113
+ </select>
114
+ </label>
115
+ <label>
116
+ <div name>${i18next.t('text.maximum value')}</div>
117
+ <input type="number" name="maximum" .value=${String(maximum)} />
118
+ <div unit>${this.unit}</div>
119
+ </label>
120
+ `
121
+ : this.type === DataItemType.select
122
+ ? html`
123
+ <!-- <div>Acceptables</div> -->
124
+ ${this.options?.options?.map(
125
+ option => html`
126
+ <div>
127
+ <input
128
+ type="checkbox"
129
+ data-value=${option.value}
130
+ ?checked=${(acceptables as string[]).includes(option.value)}
131
+ />
132
+ <span>${option.text}</span>
133
+ <span value>(${option.value})</span>
134
+ </div>
135
+ `
136
+ )}
137
+ `
138
+ : this.type === DataItemType.boolean
139
+ ? html`
140
+ <div>
141
+ <input type="checkbox" data-value=${true} ?checked=${(acceptables as boolean[]).includes(true)} />
142
+ <span value>true</span>
143
+ </div>
144
+ <div>
145
+ <input type="checkbox" data-value=${false} ?checked=${(acceptables as boolean[]).includes(false)} />
146
+ <span value>false</span>
147
+ </div>
148
+ `
149
+ : html` <div properties>${i18next.t('text.no properties to set')}</div> `}
150
+ </div>
151
+ `
152
+ }
153
+
154
+ private onChange(e: Event) {
155
+ if (this.type === DataItemType.number) {
156
+ this.value = {
157
+ minimum: this.minimum.valueAsNumber,
158
+ maximum: this.maximum.valueAsNumber
159
+ }
160
+ } else if (this.type === DataItemType.select) {
161
+ this.value = {
162
+ acceptables: Array.from(this.checkedAll).map(checked => {
163
+ const x = checked.getAttribute('data-value')!
164
+ console.log(x)
165
+ return x
166
+ })
167
+ }
168
+ } else if (this.type === DataItemType.boolean) {
169
+ this.value = {
170
+ acceptables: Array.from(this.checkedAll).map(checked => {
171
+ const x = checked.getAttribute('data-value')! === 'true'
172
+ console.log(x)
173
+ return x
174
+ })
175
+ }
176
+ } else {
177
+ this.value = {}
178
+ }
179
+
180
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
181
+ }
182
+ }
@@ -0,0 +1,23 @@
1
+ import './ox-input-spc-limits.js'
2
+
3
+ import { html, TemplateResult } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
7
+
8
+ @customElement('ox-property-editor-spc-limits')
9
+ export class OxPropertyEditorSpcLimits extends OxPropertyEditor {
10
+ editorTemplate(value: any, spec: PropertySpec): TemplateResult {
11
+ const { type, options, unit } = spec.property || {}
12
+
13
+ return html`
14
+ <ox-input-spc-limits
15
+ id="editor"
16
+ .value=${value}
17
+ .type=${type}
18
+ .unit=${unit}
19
+ .options=${options}
20
+ ></ox-input-spc-limits>
21
+ `
22
+ }
23
+ }