@oicl/openbridge-webcomponents 2.0.0-next.66 → 2.0.0-next.68
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/bundle/openbridge-webcomponents.bundle.js +2738 -2408
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +347 -30
- package/dist/automation/automation-button/automation-button.css.js +9 -9
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts +1 -0
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.d.ts.map +1 -1
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js +9 -28
- package/dist/automation/valve-analoge-two-way-icon/valve-analog-two-way-icon.js.map +1 -1
- package/dist/components/accordion-card/accordion-card.css.js +1 -1
- package/dist/components/dropdown-button/dropdown-button.d.ts +11 -0
- package/dist/components/dropdown-button/dropdown-button.d.ts.map +1 -1
- package/dist/components/dropdown-button/dropdown-button.js +24 -2
- package/dist/components/dropdown-button/dropdown-button.js.map +1 -1
- package/dist/components/keyboard-numeric/keyboard-numeric.d.ts +1 -2
- package/dist/components/keyboard-numeric/keyboard-numeric.d.ts.map +1 -1
- package/dist/components/keyboard-numeric/keyboard-numeric.js +10 -15
- package/dist/components/keyboard-numeric/keyboard-numeric.js.map +1 -1
- package/dist/components/number-input-field/number-input-field.d.ts +9 -0
- package/dist/components/number-input-field/number-input-field.d.ts.map +1 -1
- package/dist/components/number-input-field/number-input-field.js +30 -1
- package/dist/components/number-input-field/number-input-field.js.map +1 -1
- package/dist/components/number-input-field/number-input-format.d.ts +9 -0
- package/dist/components/number-input-field/number-input-format.d.ts.map +1 -1
- package/dist/components/number-input-field/number-input-format.js +33 -2
- package/dist/components/number-input-field/number-input-format.js.map +1 -1
- package/dist/components/stepper-box/stepper-box.css.js +0 -6
- package/dist/components/stepper-box/stepper-box.css.js.map +1 -1
- package/dist/components/stepper-box/stepper-box.d.ts +3 -13
- package/dist/components/stepper-box/stepper-box.d.ts.map +1 -1
- package/dist/components/stepper-box/stepper-box.js.map +1 -1
- package/dist/components/toggle-button-group/toggle-button-group.d.ts +14 -0
- package/dist/components/toggle-button-group/toggle-button-group.d.ts.map +1 -1
- package/dist/components/toggle-button-group/toggle-button-group.js +25 -5
- package/dist/components/toggle-button-group/toggle-button-group.js.map +1 -1
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.css.js +4 -0
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.css.js.map +1 -1
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.d.ts +1 -0
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.d.ts.map +1 -1
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.js +13 -1
- package/dist/integration-systems/integration-fleet-button/integration-fleet-button.js.map +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.css.js +2 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.css.js.map +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.d.ts.map +1 -1
- package/dist/navigation-instruments/graph-mini/graph-mini.js +7 -5
- package/dist/navigation-instruments/graph-mini/graph-mini.js.map +1 -1
- package/dist/navigation-instruments/indicator-graph/indicator-graph.css.js +66 -0
- package/dist/navigation-instruments/indicator-graph/indicator-graph.css.js.map +1 -0
- package/dist/navigation-instruments/indicator-graph/indicator-graph.d.ts +54 -0
- package/dist/navigation-instruments/indicator-graph/indicator-graph.d.ts.map +1 -0
- package/dist/navigation-instruments/indicator-graph/indicator-graph.js +203 -0
- package/dist/navigation-instruments/indicator-graph/indicator-graph.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button-group.js","sources":["../../../src/components/toggle-button-group/toggle-button-group.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\nimport {\n ObcToggleButtonOption,\n ObcToggleButtonOptionVariant,\n ObcToggleButtonOptionType,\n} from '../toggle-button-option/toggle-button-option.js';\nimport componentStyle from './toggle-button-group.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nexport type ObcToggleButtonGroupValueChangeEvent = CustomEvent<{\n value: string;\n previousValue: string;\n}>;\n\n/**\n * `<obc-toggle-button-group>` – A segmented control for selecting a single option from a set (also known as a button group or segmented button).\n *\n * Provides a horizontal group of connected toggle buttons where only one option can be selected at a time.\n * Each option is represented by an `<obc-toggle-button-option>` child element. The group manages selection\n * state automatically, deselecting the previous option when a new one is chosen.\n *\n * Appears as a visually unified set of buttons with clear selection indicators. Commonly used for switching\n * between views, modes, or categories in a compact, space-efficient way. Ideal for toolbar controls,\n * filtering options, or layout toggles (e.g., list vs. grid view).\n *\n * ### Features\n *\n * - **Single selection mode:** Only one option can be active at a time; selecting a new option automatically\n * deselects the previous one. Similar to radio button behavior but with a button-like appearance.\n * - **Visual variants:**\n * - `regular` (default): Standard appearance with full background and border styling.\n * - `flat`: Minimal style with reduced visual weight, no prominent background or border.\n * - `normal`: **TODO(designer)** – Clarify the visual difference and intended use case for the `normal` variant compared to `regular` and `flat`.\n * - **Content type options:**\n * - `text` (default): Options display text labels only.\n * - `icon`: Options display only an icon (compact, suitable for limited space).\n * - `iconText`: Options display an icon and text side-by-side.\n * - `iconTextUnder`: Options display an icon above the text label (vertical layout within each button).\n * - **Size control:**\n * - Standard size (default): Regular button dimensions.\n * - Large size (`large`): Increased touch target and visual prominence for accessibility or emphasis.\n * - **Layout behavior:**\n * - By default, the group stretches to fill available container width, distributing space equally among options.\n * - When `hugText` is true, the group shrinks to fit its content width instead of expanding.\n * - **External control mode:** When `externalControl` is true, the group emits selection events but does not\n * update its own `value` property, allowing parent components to manage state (useful for form libraries or\n * custom state management).\n * - **Disabled state:** Setting `disabled` on the group disables all contained options at once. Individual\n * options can also be disabled independently while the group remains enabled.\n * - **Divider management:** Automatically shows visual dividers between options and hides the divider after\n * the selected option for a seamless, unified appearance.\n * - **Property propagation:** The group automatically synchronizes `type`, `variant`, `hugText`, and `large`\n * properties to all child `<obc-toggle-button-option>` elements for consistent styling.\n * - **Automatic fallback selection:** If the current value is set to a disabled or non-existent option, the\n * group automatically selects the first enabled option to ensure a valid state.\n *\n * ### Usage Guidelines\n *\n * Use `<obc-toggle-button-group>` when you need users to choose exactly one option from a small set of\n * mutually exclusive choices (typically 2-5 options). It provides a more compact and visually integrated\n * alternative to radio buttons.\n *\n * **Ideal use cases:**\n * - View mode toggles (e.g., list vs. grid, map vs. chart)\n * - Filter options (e.g., all/active/completed tasks)\n * - Alignment or layout controls (e.g., left/center/right alignment)\n * - Time range selectors (e.g., day/week/month)\n * - Toolbar mode switches (e.g., edit/preview modes)\n *\n * **When not to use:**\n * - For binary on/off choices, use a switch or checkbox instead.\n * - For multiple selections from a set, use checkboxes or chips.\n * - For many options (6+), consider a dropdown/select or radio button list for better scannability.\n * - For navigation between pages or sections, use tabs or a navigation menu.\n *\n * **Best Practices:**\n * - Each option must have a unique `value` property to prevent selection conflicts.\n * - Provide clear, concise labels for each option. Keep text short (1-2 words ideal).\n * - For icon-only buttons (`type=\"icon\"`), ensure icons are universally recognizable or provide tooltips.\n * - Set an initial `value` to indicate the default selection, or the first enabled option will be selected automatically.\n * - Avoid disabling the currently selected option; if an option becomes unavailable, selection will shift to the first enabled option.\n * - Use `variant=\"flat\"` in dense UIs or when the toggle is secondary to other content.\n * - Use `large` size for touch interfaces or when the control is a primary interaction element.\n *\n * **TODO(designer):** Confirm if vertical orientation is supported or planned for future releases. Also clarify recommended maximum number of options for optimal usability (currently assumes 2-5 options).\n *\n * ### Slots\n *\n * | Slot Name | Renders When... | Purpose |\n * |-----------|-----------------|---------|\n * | (default) | Always | Place one or more `<obc-toggle-button-option>` elements here to define the selectable options in the group. |\n *\n * ### Events\n *\n * - `value` – Fired when the selected value changes, either through user interaction or programmatic change.\n * Event detail: `{ value: string, previousValue: string }`. Listen to this event to react to selection changes.\n *\n * ### Example\n *\n * ```html\n * <obc-toggle-button-group value=\"list\" type=\"iconText\">\n * <obc-toggle-button-option value=\"list\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * List\n * </obc-toggle-button-option>\n * <obc-toggle-button-option value=\"grid\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * Grid\n * </obc-toggle-button-option>\n * <obc-toggle-button-option value=\"table\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * Table\n * </obc-toggle-button-option>\n * </obc-toggle-button-group>\n * ```\n *\n * @slot - Place one or more `<obc-toggle-button-option>` elements here to define the selectable options.\n * @fires value {CustomEvent<{value: string, previousValue: string}>} Fired when the selected value changes.\n */\n@customElement('obc-toggle-button-group')\nexport class ObcToggleButtonGroup extends LitElement {\n /**\n * The currently selected option's value.\n *\n * Set this property to programmatically select an option. When the user selects a different option, this property updates and a `value` event is fired.\n *\n * If set to a value that does not match any enabled option, the first enabled option is selected by default.\n */\n @property({type: String}) value = '';\n\n /**\n * The value of the option that is activated.\n *\n * When the group is controlled by an external source, this property is used to set the value of the option that is activated.\n * This is a visual indication that the option is clicked but not yet stored.\n */\n @property({type: String}) activated: string | undefined;\n\n /**\n * The visual type of the toggle button options.\n *\n * - `text` (default): Options display text only.\n * - `icon`: Options display only an icon.\n * - `iconText`: Options display an icon and text side-by-side.\n * - `iconTextUnder`: Options display an icon above the text.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: String}) type = ObcToggleButtonOptionType.text;\n\n /**\n * The visual variant of the toggle button group.\n *\n * - `regular` (default): Standard appearance with background and border.\n * - `flat`: Minimal style with no background or border.\n * - `normal`: Alternative style variant.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: String}) variant = ObcToggleButtonOptionVariant.regular;\n\n /**\n * If true, the group shrinks to fit its content (\"hug\" the text) instead of stretching to fill the container.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: Boolean}) hugText = false;\n\n /**\n * If true, the group is controlled by an external source.\n *\n * When true, the group will not update its selection when the `value` property changes.\n *\n * Defaults to false.\n */\n @property({type: Boolean}) externalControl = false;\n\n /**\n * Disables the entire toggle button group and all contained options when true.\n *\n * When disabled, no option can be selected or interacted with.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * If true, the group and all contained options use a larger size.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: Boolean, reflect: true}) large = false;\n\n @queryAssignedElements({selector: 'obc-toggle-button-option'})\n options!: NodeListOf<ObcToggleButtonOption>;\n\n private hasAnyEnabledOption(): boolean {\n if (this.disabled) return false;\n return Array.from(this.options).some((opt) => !opt.disabled);\n }\n\n private canSelectOption(value: string): boolean {\n if (this.disabled) return false;\n const option = this.getOptionByValue(value);\n return option !== null && !option.disabled;\n }\n\n private getOptionByValue(value: string): ObcToggleButtonOption | null {\n return Array.from(this.options).find((opt) => opt.value === value) || null;\n }\n\n private getFirstSelectableOption(): ObcToggleButtonOption | null {\n if (this.disabled) return null;\n return Array.from(this.options).find((opt) => !opt.disabled) || null;\n }\n\n private updateSelection(newValue: string, emitEvent: boolean = true) {\n const oldValue = this.value;\n\n if (!this.hasAnyEnabledOption()) {\n this.options.forEach((option) => {\n option.selected = option.value === this.value;\n });\n this.setNoDivider();\n return;\n }\n\n if (!this.canSelectOption(newValue)) {\n if (this.value && this.getOptionByValue(this.value)) {\n this.options.forEach((option) => {\n option.selected = option.value === this.value;\n });\n this.setNoDivider();\n return;\n }\n const fallback = this.getFirstSelectableOption();\n newValue = fallback?.value || '';\n }\n\n this.value = newValue;\n\n this.options.forEach((option) => {\n option.selected = option.value === newValue;\n });\n\n this.setNoDivider();\n\n if (emitEvent && oldValue !== newValue) {\n this.dispatchEvent(\n new CustomEvent('value', {\n detail: {value: newValue, previousValue: oldValue},\n })\n );\n }\n }\n\n private updateActivated(newValue: string | undefined) {\n if (newValue) {\n this.options.forEach((option) => {\n option.activated = option.value === newValue;\n });\n } else {\n this.options.forEach((option) => {\n option.activated = false;\n });\n }\n }\n\n private setNoDivider() {\n const selectedOptionIndex = Array.from(this.options).findIndex(\n (option) => option.selected\n );\n this.options.forEach((option) => {\n option.showDivider = true;\n });\n if (selectedOptionIndex === -1) {\n return;\n }\n const nextOption = this.options[selectedOptionIndex + 1];\n if (nextOption) {\n nextOption.showDivider = false;\n }\n }\n\n private _originalDisabledStates = new Map<ObcToggleButtonOption, boolean>();\n\n protected override firstUpdated(\n _changedProperties: PropertyValues<unknown> | Map<PropertyKey, unknown>\n ): void {\n super.firstUpdated(_changedProperties);\n\n const values = Array.from(this.options).map((opt) => opt.value);\n const uniqueValues = new Set(values);\n if (values.length !== uniqueValues.size) {\n console.warn(\n 'Toggle button group has duplicate values. This may cause unexpected behavior.'\n );\n }\n\n this.options.forEach((option) => {\n this._originalDisabledStates.set(option, option.hasAttribute('disabled'));\n\n option.addEventListener('selected', (e) => this.handleOptionClick(e));\n\n const observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n if (\n mutation.attributeName === 'disabled' &&\n !option.hasAttribute('data-group-disabled')\n ) {\n this._originalDisabledStates.set(\n option,\n option.hasAttribute('disabled')\n );\n this.handleOptionDisabledChange();\n }\n });\n });\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['disabled'],\n });\n\n option.type = this.type;\n option.variant = this.variant;\n option.hugText = this.hugText;\n option.large = this.large;\n\n if (this.disabled) {\n option.setAttribute('data-group-disabled', 'true');\n option.disabled = true;\n }\n });\n\n if (!this.value || !this.getOptionByValue(this.value)) {\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value, false);\n }\n } else {\n this.updateSelection(this.value, false);\n }\n\n if (this.activated) {\n this.updateActivated(this.activated);\n }\n }\n\n private handleOptionDisabledChange() {\n const currentOption = this.getOptionByValue(this.value);\n if (currentOption?.disabled && this.hasAnyEnabledOption()) {\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value);\n }\n }\n }\n\n handleOptionClick(event: Event) {\n const {value} = (event as CustomEvent).detail;\n if (this.externalControl) {\n this.dispatchEvent(\n new CustomEvent('value', {\n detail: {value, previousValue: this.value},\n })\n );\n } else {\n this.updateSelection(value);\n }\n }\n\n override willUpdate(changedProperties: PropertyValues) {\n if (changedProperties.has('value')) {\n this.updateSelection(this.value);\n }\n\n if (changedProperties.has('activated')) {\n this.updateActivated(this.activated);\n }\n\n if (\n changedProperties.has('type') ||\n changedProperties.has('variant') ||\n changedProperties.has('hugText') ||\n changedProperties.has('large')\n ) {\n this.options.forEach((option) => {\n option.type = this.type;\n option.variant = this.variant;\n option.hugText = this.hugText;\n option.large = this.large;\n });\n }\n\n if (changedProperties.has('disabled')) {\n this.options.forEach((option) => {\n if (this.disabled) {\n option.setAttribute('data-group-disabled', 'true');\n option.disabled = true;\n } else {\n option.removeAttribute('data-group-disabled');\n const originalState =\n this._originalDisabledStates.get(option) || false;\n option.disabled = originalState;\n }\n });\n }\n }\n\n override updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n\n const currentOption = this.getOptionByValue(this.value);\n if (currentOption?.disabled && this.hasAnyEnabledOption()) {\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value);\n }\n }\n }\n\n override render() {\n const classes = {\n 'outer-wrapper': true,\n flat: this.variant === ObcToggleButtonOptionVariant.flat,\n regular: this.variant === ObcToggleButtonOptionVariant.regular,\n 'hug-text': this.hugText,\n 'icon-text-under': this.type === ObcToggleButtonOptionType.iconTextUnder,\n disabled: this.disabled,\n large: this.large,\n };\n\n return html`\n <div class=${classMap(classes)}>\n <div class=\"wrapper\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-toggle-button-group': ObcToggleButtonGroup;\n }\n}\n"],"names":[],"mappings":";;;;;;;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,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GA9D7B,qBA8D+B,WAAA,YAAA,CAAA;AAOA,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GArE7B,qBAqE+B,WAAA,SAAA,CAAA;AAG1C,gBAAA;AAAA,EADC,sBAAsB,EAAC,UAAU,2BAAA,CAA2B;AAAA,GAvElD,qBAwEX,WAAA,WAAA,CAAA;AAxEW,uBAAN,gBAAA;AAAA,EADN,cAAc,yBAAyB;AAAA,GAC3B,oBAAA;"}
|
|
1
|
+
{"version":3,"file":"toggle-button-group.js","sources":["../../../src/components/toggle-button-group/toggle-button-group.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\nimport {\n ObcToggleButtonOption,\n ObcToggleButtonOptionVariant,\n ObcToggleButtonOptionType,\n} from '../toggle-button-option/toggle-button-option.js';\nimport componentStyle from './toggle-button-group.css?inline';\nimport {customElement} from '../../decorator.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nexport type ObcToggleButtonGroupValueChangeEvent = CustomEvent<{\n value: string;\n previousValue: string;\n}>;\n\n/**\n * `<obc-toggle-button-group>` – A segmented control for selecting a single option from a set (also known as a button group or segmented button).\n *\n * Provides a horizontal group of connected toggle buttons where only one option can be selected at a time.\n * Each option is represented by an `<obc-toggle-button-option>` child element. The group manages selection\n * state automatically, deselecting the previous option when a new one is chosen.\n *\n * Appears as a visually unified set of buttons with clear selection indicators. Commonly used for switching\n * between views, modes, or categories in a compact, space-efficient way. Ideal for toolbar controls,\n * filtering options, or layout toggles (e.g., list vs. grid view).\n *\n * ### Features\n *\n * - **Single selection mode:** Only one option can be active at a time; selecting a new option automatically\n * deselects the previous one. Similar to radio button behavior but with a button-like appearance.\n * - **Visual variants:**\n * - `regular` (default): Standard appearance with full background and border styling.\n * - `flat`: Minimal style with reduced visual weight, no prominent background or border.\n * - `normal`: **TODO(designer)** – Clarify the visual difference and intended use case for the `normal` variant compared to `regular` and `flat`.\n * - **Content type options:**\n * - `text` (default): Options display text labels only.\n * - `icon`: Options display only an icon (compact, suitable for limited space).\n * - `iconText`: Options display an icon and text side-by-side.\n * - `iconTextUnder`: Options display an icon above the text label (vertical layout within each button).\n * - **Size control:**\n * - Standard size (default): Regular button dimensions.\n * - Large size (`large`): Increased touch target and visual prominence for accessibility or emphasis.\n * - **Layout behavior:**\n * - By default, the group stretches to fill available container width, distributing space equally among options.\n * - When `hugText` is true, the group shrinks to fit its content width instead of expanding.\n * - **External control mode:** When `externalControl` is true, the group emits selection events but does not\n * update its own `value` property, allowing parent components to manage state (useful for form libraries or\n * custom state management).\n * - **Empty selection mode:** When `allowEmptySelection` is true, a `value` that does not match any enabled\n * option leaves the group with no option selected, instead of defaulting to the first enabled option. Use\n * this when a selection may legitimately be absent (e.g. unset, loading, or error states) so the UI does not\n * imply a choice the user has not made.\n * - **Disabled state:** Setting `disabled` on the group disables all contained options at once. Individual\n * options can also be disabled independently while the group remains enabled.\n * - **Divider management:** Automatically shows visual dividers between options and hides the divider after\n * the selected option for a seamless, unified appearance.\n * - **Property propagation:** The group automatically synchronizes `type`, `variant`, `hugText`, and `large`\n * properties to all child `<obc-toggle-button-option>` elements for consistent styling.\n * - **Automatic fallback selection:** If the current value is set to a disabled or non-existent option, the\n * group automatically selects the first enabled option to ensure a valid state.\n *\n * ### Usage Guidelines\n *\n * Use `<obc-toggle-button-group>` when you need users to choose exactly one option from a small set of\n * mutually exclusive choices (typically 2-5 options). It provides a more compact and visually integrated\n * alternative to radio buttons.\n *\n * **Ideal use cases:**\n * - View mode toggles (e.g., list vs. grid, map vs. chart)\n * - Filter options (e.g., all/active/completed tasks)\n * - Alignment or layout controls (e.g., left/center/right alignment)\n * - Time range selectors (e.g., day/week/month)\n * - Toolbar mode switches (e.g., edit/preview modes)\n *\n * **When not to use:**\n * - For binary on/off choices, use a switch or checkbox instead.\n * - For multiple selections from a set, use checkboxes or chips.\n * - For many options (6+), consider a dropdown/select or radio button list for better scannability.\n * - For navigation between pages or sections, use tabs or a navigation menu.\n *\n * **Best Practices:**\n * - Each option must have a unique `value` property to prevent selection conflicts.\n * - Provide clear, concise labels for each option. Keep text short (1-2 words ideal).\n * - For icon-only buttons (`type=\"icon\"`), ensure icons are universally recognizable or provide tooltips.\n * - Set an initial `value` to indicate the default selection, or the first enabled option will be selected automatically.\n * - Avoid disabling the currently selected option; if an option becomes unavailable, selection will shift to the first enabled option.\n * - Use `variant=\"flat\"` in dense UIs or when the toggle is secondary to other content.\n * - Use `large` size for touch interfaces or when the control is a primary interaction element.\n *\n * **TODO(designer):** Confirm if vertical orientation is supported or planned for future releases. Also clarify recommended maximum number of options for optimal usability (currently assumes 2-5 options).\n *\n * ### Slots\n *\n * | Slot Name | Renders When... | Purpose |\n * |-----------|-----------------|---------|\n * | (default) | Always | Place one or more `<obc-toggle-button-option>` elements here to define the selectable options in the group. |\n *\n * ### Events\n *\n * - `value` – Fired when the selected value changes, either through user interaction or programmatic change.\n * Event detail: `{ value: string, previousValue: string }`. Listen to this event to react to selection changes.\n *\n * ### Example\n *\n * ```html\n * <obc-toggle-button-group value=\"list\" type=\"iconText\">\n * <obc-toggle-button-option value=\"list\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * List\n * </obc-toggle-button-option>\n * <obc-toggle-button-option value=\"grid\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * Grid\n * </obc-toggle-button-option>\n * <obc-toggle-button-option value=\"table\">\n * <obi-placeholder slot=\"icon\"></obi-placeholder>\n * Table\n * </obc-toggle-button-option>\n * </obc-toggle-button-group>\n * ```\n *\n * @slot - Place one or more `<obc-toggle-button-option>` elements here to define the selectable options.\n * @fires value {CustomEvent<{value: string, previousValue: string}>} Fired when the selected value changes.\n */\n@customElement('obc-toggle-button-group')\nexport class ObcToggleButtonGroup extends LitElement {\n /**\n * The currently selected option's value.\n *\n * Set this property to programmatically select an option. When the user selects a different option, this property updates and a `value` event is fired.\n *\n * If set to a value that does not match any enabled option, the first enabled option is selected by default.\n */\n @property({type: String}) value = '';\n\n /**\n * The value of the option that is activated.\n *\n * When the group is controlled by an external source, this property is used to set the value of the option that is activated.\n * This is a visual indication that the option is clicked but not yet stored.\n */\n @property({type: String}) activated: string | undefined;\n\n /**\n * The visual type of the toggle button options.\n *\n * - `text` (default): Options display text only.\n * - `icon`: Options display only an icon.\n * - `iconText`: Options display an icon and text side-by-side.\n * - `iconTextUnder`: Options display an icon above the text.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: String}) type = ObcToggleButtonOptionType.text;\n\n /**\n * The visual variant of the toggle button group.\n *\n * - `regular` (default): Standard appearance with background and border.\n * - `flat`: Minimal style with no background or border.\n * - `normal`: Alternative style variant.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: String}) variant = ObcToggleButtonOptionVariant.regular;\n\n /**\n * If true, the group shrinks to fit its content (\"hug\" the text) instead of stretching to fill the container.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: Boolean}) hugText = false;\n\n /**\n * If true, the group is controlled by an external source.\n *\n * When true, the group will not update its selection when the `value` property changes.\n *\n * Defaults to false.\n */\n @property({type: Boolean}) externalControl = false;\n\n /**\n * If true, a `value` that does not match any enabled option leaves the group with no option selected\n * instead of defaulting to the first enabled option.\n *\n * This also applies when the currently selected option becomes disabled: the group clears its selection\n * rather than falling back to another option.\n *\n * Defaults to false (the first enabled option is selected when the value does not match).\n */\n @property({type: Boolean}) allowEmptySelection = false;\n\n /**\n * Disables the entire toggle button group and all contained options when true.\n *\n * When disabled, no option can be selected or interacted with.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * If true, the group and all contained options use a larger size.\n *\n * This setting is propagated to all child `<obc-toggle-button-option>` elements.\n */\n @property({type: Boolean, reflect: true}) large = false;\n\n @queryAssignedElements({selector: 'obc-toggle-button-option'})\n options!: NodeListOf<ObcToggleButtonOption>;\n\n private hasAnyEnabledOption(): boolean {\n if (this.disabled) return false;\n return Array.from(this.options).some((opt) => !opt.disabled);\n }\n\n private canSelectOption(value: string): boolean {\n if (this.disabled) return false;\n const option = this.getOptionByValue(value);\n return option !== null && !option.disabled;\n }\n\n private getOptionByValue(value: string): ObcToggleButtonOption | null {\n return Array.from(this.options).find((opt) => opt.value === value) || null;\n }\n\n private getFirstSelectableOption(): ObcToggleButtonOption | null {\n if (this.disabled) return null;\n return Array.from(this.options).find((opt) => !opt.disabled) || null;\n }\n\n private updateSelection(newValue: string, emitEvent: boolean = true) {\n const oldValue = this.value;\n\n if (!this.hasAnyEnabledOption()) {\n this.options.forEach((option) => {\n option.selected = option.value === this.value;\n });\n this.setNoDivider();\n return;\n }\n\n if (!this.canSelectOption(newValue)) {\n if (this.value && this.getOptionByValue(this.value)) {\n this.options.forEach((option) => {\n option.selected = option.value === this.value;\n });\n this.setNoDivider();\n return;\n }\n if (this.allowEmptySelection) {\n newValue = '';\n } else {\n const fallback = this.getFirstSelectableOption();\n newValue = fallback?.value || '';\n }\n }\n\n this.value = newValue;\n\n this.options.forEach((option) => {\n option.selected = option.value === newValue;\n });\n\n this.setNoDivider();\n\n if (emitEvent && oldValue !== newValue) {\n this.dispatchEvent(\n new CustomEvent('value', {\n detail: {value: newValue, previousValue: oldValue},\n })\n );\n }\n }\n\n private updateActivated(newValue: string | undefined) {\n if (newValue) {\n this.options.forEach((option) => {\n option.activated = option.value === newValue;\n });\n } else {\n this.options.forEach((option) => {\n option.activated = false;\n });\n }\n }\n\n private setNoDivider() {\n const selectedOptionIndex = Array.from(this.options).findIndex(\n (option) => option.selected\n );\n this.options.forEach((option) => {\n option.showDivider = true;\n });\n if (selectedOptionIndex === -1) {\n return;\n }\n const nextOption = this.options[selectedOptionIndex + 1];\n if (nextOption) {\n nextOption.showDivider = false;\n }\n }\n\n private _originalDisabledStates = new Map<ObcToggleButtonOption, boolean>();\n\n protected override firstUpdated(\n _changedProperties: PropertyValues<unknown> | Map<PropertyKey, unknown>\n ): void {\n super.firstUpdated(_changedProperties);\n\n const values = Array.from(this.options).map((opt) => opt.value);\n const uniqueValues = new Set(values);\n if (values.length !== uniqueValues.size) {\n console.warn(\n 'Toggle button group has duplicate values. This may cause unexpected behavior.'\n );\n }\n\n this.options.forEach((option) => {\n this._originalDisabledStates.set(option, option.hasAttribute('disabled'));\n\n option.addEventListener('selected', (e) => this.handleOptionClick(e));\n\n const observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n if (\n mutation.attributeName === 'disabled' &&\n !option.hasAttribute('data-group-disabled')\n ) {\n this._originalDisabledStates.set(\n option,\n option.hasAttribute('disabled')\n );\n this.handleOptionDisabledChange();\n }\n });\n });\n observer.observe(option, {\n attributes: true,\n attributeFilter: ['disabled'],\n });\n\n option.type = this.type;\n option.variant = this.variant;\n option.hugText = this.hugText;\n option.large = this.large;\n\n if (this.disabled) {\n option.setAttribute('data-group-disabled', 'true');\n option.disabled = true;\n }\n });\n\n if (!this.value || !this.getOptionByValue(this.value)) {\n if (this.allowEmptySelection) {\n this.updateSelection('', false);\n } else {\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value, false);\n }\n }\n } else {\n this.updateSelection(this.value, false);\n }\n\n if (this.activated) {\n this.updateActivated(this.activated);\n }\n }\n\n private handleOptionDisabledChange() {\n const currentOption = this.getOptionByValue(this.value);\n if (currentOption?.disabled && this.hasAnyEnabledOption()) {\n if (this.allowEmptySelection) {\n this.updateSelection('');\n return;\n }\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value);\n }\n }\n }\n\n handleOptionClick(event: Event) {\n const {value} = (event as CustomEvent).detail;\n if (this.externalControl) {\n this.dispatchEvent(\n new CustomEvent('value', {\n detail: {value, previousValue: this.value},\n })\n );\n } else {\n this.updateSelection(value);\n }\n }\n\n override willUpdate(changedProperties: PropertyValues) {\n if (changedProperties.has('value')) {\n this.updateSelection(this.value);\n }\n\n if (changedProperties.has('activated')) {\n this.updateActivated(this.activated);\n }\n\n if (\n changedProperties.has('type') ||\n changedProperties.has('variant') ||\n changedProperties.has('hugText') ||\n changedProperties.has('large')\n ) {\n this.options.forEach((option) => {\n option.type = this.type;\n option.variant = this.variant;\n option.hugText = this.hugText;\n option.large = this.large;\n });\n }\n\n if (changedProperties.has('disabled')) {\n this.options.forEach((option) => {\n if (this.disabled) {\n option.setAttribute('data-group-disabled', 'true');\n option.disabled = true;\n } else {\n option.removeAttribute('data-group-disabled');\n const originalState =\n this._originalDisabledStates.get(option) || false;\n option.disabled = originalState;\n }\n });\n }\n }\n\n override updated(changedProperties: PropertyValues) {\n super.updated(changedProperties);\n\n const currentOption = this.getOptionByValue(this.value);\n if (currentOption?.disabled && this.hasAnyEnabledOption()) {\n if (this.allowEmptySelection) {\n this.updateSelection('');\n return;\n }\n const firstSelectable = this.getFirstSelectableOption();\n if (firstSelectable) {\n this.updateSelection(firstSelectable.value);\n }\n }\n }\n\n override render() {\n const classes = {\n 'outer-wrapper': true,\n flat: this.variant === ObcToggleButtonOptionVariant.flat,\n regular: this.variant === ObcToggleButtonOptionVariant.regular,\n 'hug-text': this.hugText,\n 'icon-text-under': this.type === ObcToggleButtonOptionType.iconTextUnder,\n disabled: this.disabled,\n large: this.large,\n };\n\n return html`\n <div class=${classMap(classes)}>\n <div class=\"wrapper\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-toggle-button-group': ObcToggleButtonGroup;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA8HO,IAAM,uBAAN,cAAmC,WAAW;AAAA,EAA9C,cAAA;AAAA,UAAA,GAAA,SAAA;AAQqB,SAAA,QAAQ;AAoBR,SAAA,OAAO,0BAA0B;AAWjC,SAAA,UAAU,6BAA6B;AAOtC,SAAA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8CgB,WAAA,WAAA,CAAA;AASA,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,QAAA,CAAQ;AAAA,GAvDd,qBAuDgB,WAAA,mBAAA,CAAA;AAWA,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,QAAA,CAAQ;AAAA,GAlEd,qBAkEgB,WAAA,uBAAA,CAAA;AAOe,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GAzE7B,qBAyE+B,WAAA,YAAA,CAAA;AAOA,gBAAA;AAAA,EAAzC,SAAS,EAAC,MAAM,SAAS,SAAS,MAAK;AAAA,GAhF7B,qBAgF+B,WAAA,SAAA,CAAA;AAG1C,gBAAA;AAAA,EADC,sBAAsB,EAAC,UAAU,2BAAA,CAA2B;AAAA,GAlFlD,qBAmFX,WAAA,WAAA,CAAA;AAnFW,uBAAN,gBAAA;AAAA,EADN,cAAc,yBAAyB;AAAA,GAC3B,oBAAA;"}
|
package/dist/integration-systems/integration-fleet-button/integration-fleet-button.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-fleet-button.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration-fleet-button.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -16,6 +16,7 @@ export declare class ObcIntegrationFleetButton extends LitElement {
|
|
|
16
16
|
warning: number;
|
|
17
17
|
caution: number;
|
|
18
18
|
};
|
|
19
|
+
showAlerts: boolean;
|
|
19
20
|
render(): import('lit-html').TemplateResult<1>;
|
|
20
21
|
renderAlertCount(): import('lit-html').TemplateResult<1>[];
|
|
21
22
|
static styles: import('lit').CSSResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-fleet-button.d.ts","sourceRoot":"","sources":["../../../src/integration-systems/integration-fleet-button/integration-fleet-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAkB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"integration-fleet-button.d.ts","sourceRoot":"","sources":["../../../src/integration-systems/integration-fleet-button/integration-fleet-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAkB,MAAM,KAAK,CAAC;AAMhD,OAAO,iCAAiC,CAAC;AAEzC,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBACa,yBAA0B,SAAQ,UAAU;IAC5B,QAAQ,EAAE,OAAO,CAAS;IAC3B,SAAS,EAAE,MAAM,CAAM;IACvB,MAAM,EAAE,MAAM,CAAM;IAE9C,QAAQ,EAAE,6BAA6B,EAAE,CAAM;IACrB,UAAU,EAAE,MAAM,CAAM;IACN,MAAM,EAAE;QAClD,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAsC;IACZ,UAAU,EAAE,OAAO,CAAS;IAE9C,MAAM;IA2Cf,gBAAgB;IAiChB,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,8BAA8B,EAAE,yBAAyB,CAAC;KAC3D;CACF"}
|
|
@@ -2,6 +2,7 @@ import { unsafeCSS, LitElement, html } from "lit";
|
|
|
2
2
|
import { customElement } from "../../decorator.js";
|
|
3
3
|
import compentStyle from "./integration-fleet-button.css.js";
|
|
4
4
|
import { property } from "lit/decorators.js";
|
|
5
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
5
6
|
import { msg } from "@lit/localize";
|
|
6
7
|
import "../../components/badge/badge.js";
|
|
7
8
|
var __defProp = Object.defineProperty;
|
|
@@ -23,6 +24,7 @@ let ObcIntegrationFleetButton = class extends LitElement {
|
|
|
23
24
|
this.readouts = [];
|
|
24
25
|
this.alertTopic = "";
|
|
25
26
|
this.alerts = { alarm: 0, warning: 0, caution: 0 };
|
|
27
|
+
this.showAlerts = false;
|
|
26
28
|
}
|
|
27
29
|
render() {
|
|
28
30
|
const hasAlert = this.alerts.alarm > 0 || this.alerts.warning > 0 || this.alerts.caution > 0;
|
|
@@ -42,7 +44,14 @@ let ObcIntegrationFleetButton = class extends LitElement {
|
|
|
42
44
|
</div>`
|
|
43
45
|
)}
|
|
44
46
|
</div>
|
|
45
|
-
<div
|
|
47
|
+
<div
|
|
48
|
+
class=${classMap({
|
|
49
|
+
alerts: true,
|
|
50
|
+
"has-alert": hasAlert,
|
|
51
|
+
"no-alert": !hasAlert,
|
|
52
|
+
"show-alerts": this.showAlerts
|
|
53
|
+
})}
|
|
54
|
+
>
|
|
46
55
|
<div class="alert-icon ">
|
|
47
56
|
<slot name="alert-topic-icon"></slot>
|
|
48
57
|
</div>
|
|
@@ -107,6 +116,9 @@ __decorateClass([
|
|
|
107
116
|
__decorateClass([
|
|
108
117
|
property({ type: Object, attribute: false })
|
|
109
118
|
], ObcIntegrationFleetButton.prototype, "alerts", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: Boolean })
|
|
121
|
+
], ObcIntegrationFleetButton.prototype, "showAlerts", 2);
|
|
110
122
|
ObcIntegrationFleetButton = __decorateClass([
|
|
111
123
|
customElement("obc-integration-fleet-button")
|
|
112
124
|
], ObcIntegrationFleetButton);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-fleet-button.js","sources":["../../../src/integration-systems/integration-fleet-button/integration-fleet-button.ts"],"sourcesContent":["import {LitElement, html, unsafeCSS} from 'lit';\nimport {customElement} from '../../decorator.js';\nimport compentStyle from './integration-fleet-button.css?inline';\nimport {property} from 'lit/decorators.js';\nimport {msg} from '@lit/localize';\nimport '../../components/badge/badge.js';\n\nexport interface IntegrationFleetButtonReadout {\n label: string;\n value: string;\n unit: string;\n}\n\n@customElement('obc-integration-fleet-button')\nexport class ObcIntegrationFleetButton extends LitElement {\n @property({type: Boolean}) selected: boolean = false;\n @property({type: String}) fleetName: string = '';\n @property({type: String}) status: string = '';\n @property({type: Array, attribute: false})\n readouts: IntegrationFleetButtonReadout[] = [];\n @property({type: String}) alertTopic: string = '';\n @property({type: Object, attribute: false}) alerts: {\n alarm: number;\n warning: number;\n caution: number;\n } = {alarm: 0, warning: 0, caution: 0};\n\n override render() {\n const hasAlert =\n this.alerts.alarm > 0 ||\n this.alerts.warning > 0 ||\n this.alerts.caution > 0;\n return html`\n <button class=\"wrapper ${this.selected ? 'selected' : ''}\">\n <div class=\"header\">\n <div class=\"fleet-name\">${this.fleetName}</div>\n <div class=\"status\">${this.status}</div>\n </div>\n <div class=\"content\">\n <div class=\"readouts\">\n ${this.readouts.map(\n (readout) =>\n html`<div class=\"readout\">\n <div class=\"readout-label\">${readout.label}</div>\n <div class=\"readout-value\">${readout.value}</div>\n <div class=\"readout-unit\">${readout.unit}</div>\n </div>`\n )}\n </div>\n <div
|
|
1
|
+
{"version":3,"file":"integration-fleet-button.js","sources":["../../../src/integration-systems/integration-fleet-button/integration-fleet-button.ts"],"sourcesContent":["import {LitElement, html, unsafeCSS} from 'lit';\nimport {customElement} from '../../decorator.js';\nimport compentStyle from './integration-fleet-button.css?inline';\nimport {property} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {msg} from '@lit/localize';\nimport '../../components/badge/badge.js';\n\nexport interface IntegrationFleetButtonReadout {\n label: string;\n value: string;\n unit: string;\n}\n\n@customElement('obc-integration-fleet-button')\nexport class ObcIntegrationFleetButton extends LitElement {\n @property({type: Boolean}) selected: boolean = false;\n @property({type: String}) fleetName: string = '';\n @property({type: String}) status: string = '';\n @property({type: Array, attribute: false})\n readouts: IntegrationFleetButtonReadout[] = [];\n @property({type: String}) alertTopic: string = '';\n @property({type: Object, attribute: false}) alerts: {\n alarm: number;\n warning: number;\n caution: number;\n } = {alarm: 0, warning: 0, caution: 0};\n @property({type: Boolean}) showAlerts: boolean = false;\n\n override render() {\n const hasAlert =\n this.alerts.alarm > 0 ||\n this.alerts.warning > 0 ||\n this.alerts.caution > 0;\n return html`\n <button class=\"wrapper ${this.selected ? 'selected' : ''}\">\n <div class=\"header\">\n <div class=\"fleet-name\">${this.fleetName}</div>\n <div class=\"status\">${this.status}</div>\n </div>\n <div class=\"content\">\n <div class=\"readouts\">\n ${this.readouts.map(\n (readout) =>\n html`<div class=\"readout\">\n <div class=\"readout-label\">${readout.label}</div>\n <div class=\"readout-value\">${readout.value}</div>\n <div class=\"readout-unit\">${readout.unit}</div>\n </div>`\n )}\n </div>\n <div\n class=${classMap({\n alerts: true,\n 'has-alert': hasAlert,\n 'no-alert': !hasAlert,\n 'show-alerts': this.showAlerts,\n })}\n >\n <div class=\"alert-icon \">\n <slot name=\"alert-topic-icon\"></slot>\n </div>\n <div class=\"alert-topic\">${this.alertTopic}</div>\n <div class=\"alert-counts\">\n ${hasAlert ? this.renderAlertCount() : msg('No alerts')}\n </div>\n </div>\n </div>\n </button>\n `;\n }\n\n renderAlertCount() {\n const {alarm, warning, caution} = this.alerts;\n const divs = [];\n if (alarm > 0) {\n divs.push(\n html`<obc-badge\n type=\"alarm\"\n .number=\"${alarm}\"\n size=\"large\"\n ></obc-badge>`\n );\n }\n if (warning > 0) {\n divs.push(\n html`<obc-badge\n type=\"warning\"\n .number=\"${warning}\"\n size=\"large\"\n ></obc-badge>`\n );\n }\n if (caution > 0) {\n divs.push(\n html`<obc-badge\n type=\"caution\"\n .number=\"${caution}\"\n size=\"large\"\n ></obc-badge>`\n );\n }\n return divs;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-integration-fleet-button': ObcIntegrationFleetButton;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAeO,IAAM,4BAAN,cAAwC,WAAW;AAAA,EAAnD,cAAA;AAAA,UAAA,GAAA,SAAA;AACsB,SAAA,WAAoB;AACrB,SAAA,YAAoB;AACpB,SAAA,SAAiB;AAE3C,SAAA,WAA4C,CAAA;AAClB,SAAA,aAAqB;AACH,SAAA,SAIxC,EAAC,OAAO,GAAG,SAAS,GAAG,SAAS,EAAA;AACT,SAAA,aAAsB;AAAA,EAAA;AAAA,EAExC,SAAS;AAChB,UAAM,WACJ,KAAK,OAAO,QAAQ,KACpB,KAAK,OAAO,UAAU,KACtB,KAAK,OAAO,UAAU;AACxB,WAAO;AAAA,+BACoB,KAAK,WAAW,aAAa,EAAE;AAAA;AAAA,oCAE1B,KAAK,SAAS;AAAA,gCAClB,KAAK,MAAM;AAAA;AAAA;AAAA;AAAA,cAI7B,KAAK,SAAS;AAAA,MACd,CAAC,YACC;AAAA,+CAC+B,QAAQ,KAAK;AAAA,+CACb,QAAQ,KAAK;AAAA,8CACd,QAAQ,IAAI;AAAA;AAAA,IAAA,CAE7C;AAAA;AAAA;AAAA,oBAGO,SAAS;AAAA,MACf,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,YAAY,CAAC;AAAA,MACb,eAAe,KAAK;AAAA,IAAA,CACrB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,uCAKyB,KAAK,UAAU;AAAA;AAAA,gBAEtC,WAAW,KAAK,iBAAA,IAAqB,IAAI,WAAW,CAAC;AAAA;AAAA;A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AAA,GAChC,yBAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-mini.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph-mini.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-mini.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/graph-mini/graph-mini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAkB,MAAM,KAAK,CAAC;AAMhE;;;;;GAKG;AACH,qBACa,YAAa,SAAQ,UAAU;IAE1C,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAY;IAGtC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAGzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAGzB,KAAK,EAAG,cAAc,CAAC;IAGvB,OAAO,CAAC,CAAC,CAAc;IAEvB,OAAO,CAAC,KAAK,CAAsB;IAEnC,OAAO,CAAC,WAAW;IAKV,YAAY;IA2CrB,aAAa;IASb,OAAO,CAAC,OAAO;IAUN,OAAO,CAAC,iBAAiB,EAAE,cAAc;IAQzC,MAAM;
|
|
1
|
+
{"version":3,"file":"graph-mini.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/graph-mini/graph-mini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAkB,MAAM,KAAK,CAAC;AAMhE;;;;;GAKG;AACH,qBACa,YAAa,SAAQ,UAAU;IAE1C,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAY;IAGtC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAGzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAGzB,KAAK,EAAG,cAAc,CAAC;IAGvB,OAAO,CAAC,CAAC,CAAc;IAEvB,OAAO,CAAC,KAAK,CAAsB;IAEnC,OAAO,CAAC,WAAW;IAKV,YAAY;IA2CrB,aAAa;IASb,OAAO,CAAC,OAAO;IAUN,OAAO,CAAC,iBAAiB,EAAE,cAAc;IAQzC,MAAM;IAUf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,YAAY,CAAC;KAChC;CACF"}
|
|
@@ -26,8 +26,8 @@ let ObcGraphMini = class extends LitElement {
|
|
|
26
26
|
}
|
|
27
27
|
firstUpdated() {
|
|
28
28
|
const opts = {
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
29
|
+
width: 32,
|
|
30
|
+
height: 32,
|
|
31
31
|
scales: {
|
|
32
32
|
x: { time: false, show: false },
|
|
33
33
|
y: {
|
|
@@ -46,7 +46,7 @@ let ObcGraphMini = class extends LitElement {
|
|
|
46
46
|
{},
|
|
47
47
|
{
|
|
48
48
|
stroke: this.getCssColor("--element-neutral-color"),
|
|
49
|
-
width:
|
|
49
|
+
width: 1,
|
|
50
50
|
points: { show: false }
|
|
51
51
|
}
|
|
52
52
|
],
|
|
@@ -65,7 +65,7 @@ let ObcGraphMini = class extends LitElement {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
const stroke = this.getCssColor("--element-neutral-color");
|
|
68
|
-
this.uplot.setSeries(1, { stroke, width:
|
|
68
|
+
this.uplot.setSeries(1, { stroke, width: 1, points: { show: false } });
|
|
69
69
|
}
|
|
70
70
|
updateY() {
|
|
71
71
|
if (!this.uplot) {
|
|
@@ -85,7 +85,9 @@ let ObcGraphMini = class extends LitElement {
|
|
|
85
85
|
render() {
|
|
86
86
|
return html`
|
|
87
87
|
<div class="chart-container">
|
|
88
|
-
<div id="chart"
|
|
88
|
+
<div id="chart">
|
|
89
|
+
<div id="dot" style="transform: translateY(${-this.y}px);"></div>
|
|
90
|
+
</div>
|
|
89
91
|
</div>
|
|
90
92
|
`;
|
|
91
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-mini.js","sources":["../../../src/navigation-instruments/graph-mini/graph-mini.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport compentStyle from './graph-mini.css?inline';\nimport uPlot from 'uplot';\nimport {customElement} from '../../decorator.js';\n\n/**\n * @element obc-graph-mini\n * @description A mini graph component\n *\n * @property {Array} data - The data to display in the graph, first array is the x values, second array is the y values\n */\n@customElement('obc-graph-mini')\nexport class ObcGraphMini extends LitElement {\n @property({type: Array})\n data: [number[], number[]] = [[], []];\n\n @property({type: Number})\n minY: number | undefined;\n\n @property({type: Number})\n maxY: number | undefined;\n\n @query('#chart')\n chart!: HTMLDivElement;\n\n @state()\n private y: number = 24;\n\n private uplot: uPlot | null = null;\n\n private getCssColor(name: string) {\n const color = getComputedStyle(this).getPropertyValue(name).trim();\n return color;\n }\n\n override firstUpdated() {\n const opts = {\n width:
|
|
1
|
+
{"version":3,"file":"graph-mini.js","sources":["../../../src/navigation-instruments/graph-mini/graph-mini.ts"],"sourcesContent":["import {LitElement, PropertyValues, html, unsafeCSS} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport compentStyle from './graph-mini.css?inline';\nimport uPlot from 'uplot';\nimport {customElement} from '../../decorator.js';\n\n/**\n * @element obc-graph-mini\n * @description A mini graph component\n *\n * @property {Array} data - The data to display in the graph, first array is the x values, second array is the y values\n */\n@customElement('obc-graph-mini')\nexport class ObcGraphMini extends LitElement {\n @property({type: Array})\n data: [number[], number[]] = [[], []];\n\n @property({type: Number})\n minY: number | undefined;\n\n @property({type: Number})\n maxY: number | undefined;\n\n @query('#chart')\n chart!: HTMLDivElement;\n\n @state()\n private y: number = 24;\n\n private uplot: uPlot | null = null;\n\n private getCssColor(name: string) {\n const color = getComputedStyle(this).getPropertyValue(name).trim();\n return color;\n }\n\n override firstUpdated() {\n const opts = {\n width: 32,\n height: 32,\n scales: {\n x: {time: false, show: false},\n y: {\n auto: true,\n show: false,\n range: (\n _self: uPlot,\n initMin: number,\n initMax: number,\n _scaleKey: string\n ) => {\n const range = this.maxY ?? initMax - (this.minY ?? initMin);\n return [\n this.minY ?? initMin - range * 0.1,\n this.maxY ?? initMax + range * 0.1,\n ] as [number, number];\n },\n },\n },\n series: [\n {},\n {\n stroke: this.getCssColor('--element-neutral-color'),\n width: 1,\n points: {show: false},\n },\n ],\n axes: [\n {show: false},\n {ticks: {show: false}, show: false, grid: {show: false}},\n ],\n legend: {show: false},\n cursor: {show: false},\n };\n\n this.uplot = new uPlot(opts, this.data, this.chart);\n requestAnimationFrame(() => this.updateY());\n }\n\n updatePalette() {\n if (!this.uplot) {\n return;\n }\n const stroke = this.getCssColor('--element-neutral-color');\n // @ts-expect-error - stroke is not a property of the Series interface\n this.uplot.setSeries(1, {stroke: stroke, width: 1, points: {show: false}});\n }\n\n private updateY() {\n if (!this.uplot) {\n return;\n }\n const lastY = this.data[1][this.data[1].length - 1];\n // @ts-expect-error - valToPct is not a property of the Scale interface\n const yRatio = this.uplot.scales.y.valToPct(lastY);\n this.y = yRatio * 32 - 3;\n }\n\n override updated(changedProperties: PropertyValues) {\n if (changedProperties.has('data')) {\n this.updatePalette();\n this.uplot?.setData(this.data);\n requestAnimationFrame(() => this.updateY());\n }\n }\n\n override render() {\n return html`\n <div class=\"chart-container\">\n <div id=\"chart\">\n <div id=\"dot\" style=\"transform: translateY(${-this.y}px);\"></div>\n </div>\n </div>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-graph-mini': ObcGraphMini;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAaO,IAAM,eAAN,cAA2B,WAAW;AAAA,EAAtC,cAAA;AAAA,UAAA,GAAA,SAAA;AAEL,SAAA,OAA6B,CAAC,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
-webkit-tap-highlight-color: transparent;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.chart-container {
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
canvas {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#dot {
|
|
25
|
+
position: absolute;
|
|
26
|
+
width: 4px;
|
|
27
|
+
height: 4px;
|
|
28
|
+
right: -3px;
|
|
29
|
+
bottom: -3px;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
background: var(--element-neutral-color);
|
|
32
|
+
border: 1px solid var(--border-silhouette-color);
|
|
33
|
+
z-index: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.enhanced #dot {
|
|
37
|
+
background: var(--element-neutral-enhanced-color);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.medium #dot {
|
|
41
|
+
width: 6px;
|
|
42
|
+
height: 6px;
|
|
43
|
+
right: -4px;
|
|
44
|
+
bottom: -4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.large #dot {
|
|
48
|
+
width: 8px;
|
|
49
|
+
height: 8px;
|
|
50
|
+
right: -5px;
|
|
51
|
+
bottom: -5px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#zero-line {
|
|
55
|
+
position: absolute;
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 1px;
|
|
58
|
+
bottom: -0.5px;
|
|
59
|
+
background: var(--element-disabled-color);
|
|
60
|
+
border-radius: 2px;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
export {
|
|
64
|
+
compentStyle as default
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=indicator-graph.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator-graph.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export declare enum ObcIndicatorGraphSize {
|
|
3
|
+
small = "small",
|
|
4
|
+
medium = "medium",
|
|
5
|
+
large = "large"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ObcIndicatorGraphPriority {
|
|
8
|
+
regular = "regular",
|
|
9
|
+
enhanced = "enhanced"
|
|
10
|
+
}
|
|
11
|
+
export interface ObcIndicatorGraphLayout {
|
|
12
|
+
size?: ObcIndicatorGraphSize;
|
|
13
|
+
priority?: ObcIndicatorGraphPriority;
|
|
14
|
+
y?: {
|
|
15
|
+
min?: number;
|
|
16
|
+
max?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @element obc-indicator-graph
|
|
21
|
+
* @description A mini graph component
|
|
22
|
+
*
|
|
23
|
+
* @property {Array} data - The data to display in the graph, first array is the x values, second array is the y values
|
|
24
|
+
*/
|
|
25
|
+
export declare class ObcIndicatorGraph extends LitElement {
|
|
26
|
+
data: [number[], number[]];
|
|
27
|
+
layout: ObcIndicatorGraphLayout;
|
|
28
|
+
private chart;
|
|
29
|
+
private y;
|
|
30
|
+
private zeroLineY;
|
|
31
|
+
private uplot;
|
|
32
|
+
private resizeObserver;
|
|
33
|
+
private getCssColor;
|
|
34
|
+
firstUpdated(): void;
|
|
35
|
+
disconnectedCallback(): void;
|
|
36
|
+
private updateSize;
|
|
37
|
+
private _range;
|
|
38
|
+
private get _effectiveSize();
|
|
39
|
+
private get _effectivePriority();
|
|
40
|
+
private _getStrokeWidth;
|
|
41
|
+
private _getStrokeColor;
|
|
42
|
+
updatePalette(): void;
|
|
43
|
+
private updateY;
|
|
44
|
+
private updateZeroLine;
|
|
45
|
+
updated(changedProperties: PropertyValues): void;
|
|
46
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
47
|
+
static styles: import('lit').CSSResult;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
'obc-indicator-graph': ObcIndicatorGraph;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=indicator-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator-graph.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/indicator-graph/indicator-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAkB,MAAM,KAAK,CAAC;AAMhE,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,oBAAY,yBAAyB;IACnC,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,CAAC,CAAC,EAAE;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;CAClC;AAED;;;;;GAKG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IAE/C,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAY;IAGtC,MAAM,EAAE,uBAAuB,CAAM;IAGrC,OAAO,CAAC,KAAK,CAAkB;IAG/B,OAAO,CAAC,CAAC,CAAc;IAGvB,OAAO,CAAC,SAAS,CAAa;IAE9B,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,cAAc,CAA+B;IAErD,OAAO,CAAC,WAAW;IAKV,YAAY;IAmCZ,oBAAoB;IAQ7B,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,MAAM;IAed,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,kBAAkB,GAE7B;IAED,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,eAAe;IASvB,aAAa;IAab,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,cAAc;IASb,OAAO,CAAC,iBAAiB,EAAE,cAAc;IAQzC,MAAM;IAsBf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,iBAAiB,CAAC;KAC1C;CACF"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { unsafeCSS, LitElement, html } from "lit";
|
|
2
|
+
import { property, query, state } from "lit/decorators.js";
|
|
3
|
+
import compentStyle from "./indicator-graph.css.js";
|
|
4
|
+
import uPlot from "uplot";
|
|
5
|
+
import { customElement } from "../../decorator.js";
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
9
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
10
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
11
|
+
if (decorator = decorators[i])
|
|
12
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
13
|
+
if (kind && result) __defProp(target, key, result);
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
var ObcIndicatorGraphSize = /* @__PURE__ */ ((ObcIndicatorGraphSize2) => {
|
|
17
|
+
ObcIndicatorGraphSize2["small"] = "small";
|
|
18
|
+
ObcIndicatorGraphSize2["medium"] = "medium";
|
|
19
|
+
ObcIndicatorGraphSize2["large"] = "large";
|
|
20
|
+
return ObcIndicatorGraphSize2;
|
|
21
|
+
})(ObcIndicatorGraphSize || {});
|
|
22
|
+
var ObcIndicatorGraphPriority = /* @__PURE__ */ ((ObcIndicatorGraphPriority2) => {
|
|
23
|
+
ObcIndicatorGraphPriority2["regular"] = "regular";
|
|
24
|
+
ObcIndicatorGraphPriority2["enhanced"] = "enhanced";
|
|
25
|
+
return ObcIndicatorGraphPriority2;
|
|
26
|
+
})(ObcIndicatorGraphPriority || {});
|
|
27
|
+
let ObcIndicatorGraph = class extends LitElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.data = [[], []];
|
|
31
|
+
this.layout = {};
|
|
32
|
+
this.y = 24;
|
|
33
|
+
this.zeroLineY = 0;
|
|
34
|
+
this.uplot = null;
|
|
35
|
+
this.resizeObserver = null;
|
|
36
|
+
}
|
|
37
|
+
getCssColor(name) {
|
|
38
|
+
const color = getComputedStyle(this).getPropertyValue(name).trim();
|
|
39
|
+
return color;
|
|
40
|
+
}
|
|
41
|
+
firstUpdated() {
|
|
42
|
+
const opts = {
|
|
43
|
+
width: this.chart.clientWidth,
|
|
44
|
+
height: this.chart.clientHeight,
|
|
45
|
+
scales: {
|
|
46
|
+
x: { time: false, show: false },
|
|
47
|
+
y: {
|
|
48
|
+
auto: true,
|
|
49
|
+
show: false,
|
|
50
|
+
range: this._range.bind(this)
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
series: [
|
|
54
|
+
{},
|
|
55
|
+
{
|
|
56
|
+
stroke: this._getStrokeColor(),
|
|
57
|
+
width: this._getStrokeWidth(),
|
|
58
|
+
points: { show: false }
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
axes: [
|
|
62
|
+
{ show: false },
|
|
63
|
+
{ ticks: { show: false }, show: false, grid: { show: false } }
|
|
64
|
+
],
|
|
65
|
+
legend: { show: false },
|
|
66
|
+
cursor: { show: false }
|
|
67
|
+
};
|
|
68
|
+
this.uplot = new uPlot(opts, this.data, this.chart);
|
|
69
|
+
requestAnimationFrame(() => this.updateY());
|
|
70
|
+
this.resizeObserver = new ResizeObserver(() => this.updateSize());
|
|
71
|
+
this.resizeObserver.observe(this.chart);
|
|
72
|
+
}
|
|
73
|
+
disconnectedCallback() {
|
|
74
|
+
super.disconnectedCallback();
|
|
75
|
+
this.resizeObserver?.disconnect();
|
|
76
|
+
this.resizeObserver = null;
|
|
77
|
+
this.uplot?.destroy();
|
|
78
|
+
this.uplot = null;
|
|
79
|
+
}
|
|
80
|
+
updateSize() {
|
|
81
|
+
if (!this.uplot) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.uplot.setSize({
|
|
85
|
+
width: this.chart.clientWidth,
|
|
86
|
+
height: this.chart.clientHeight
|
|
87
|
+
});
|
|
88
|
+
this.updateY();
|
|
89
|
+
}
|
|
90
|
+
_range(_self, initMin, initMax, _scaleKey) {
|
|
91
|
+
const { min: minY, max: maxY } = this.layout.y ?? {};
|
|
92
|
+
const range = maxY ?? initMax - (minY ?? initMin);
|
|
93
|
+
let min = minY ?? initMin - range * 0.1;
|
|
94
|
+
if (minY === void 0) {
|
|
95
|
+
min = Math.min(0, min);
|
|
96
|
+
}
|
|
97
|
+
return [min, maxY ?? initMax + range * 0.1];
|
|
98
|
+
}
|
|
99
|
+
get _effectiveSize() {
|
|
100
|
+
return this.layout.size ?? "medium";
|
|
101
|
+
}
|
|
102
|
+
get _effectivePriority() {
|
|
103
|
+
return this.layout.priority ?? "regular";
|
|
104
|
+
}
|
|
105
|
+
_getStrokeWidth() {
|
|
106
|
+
switch (this._effectiveSize) {
|
|
107
|
+
case "small":
|
|
108
|
+
return 1;
|
|
109
|
+
case "medium":
|
|
110
|
+
return 1.5;
|
|
111
|
+
case "large":
|
|
112
|
+
return 2;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_getStrokeColor() {
|
|
116
|
+
switch (this._effectivePriority) {
|
|
117
|
+
case "regular":
|
|
118
|
+
return this.getCssColor("--element-neutral-color");
|
|
119
|
+
case "enhanced":
|
|
120
|
+
return this.getCssColor("--element-neutral-enhanced-color");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
updatePalette() {
|
|
124
|
+
if (!this.uplot) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const stroke = this._getStrokeColor();
|
|
128
|
+
this.uplot.setSeries(1, {
|
|
129
|
+
// @ts-expect-error - stroke is not a property of the Series interface
|
|
130
|
+
stroke,
|
|
131
|
+
width: this._getStrokeWidth(),
|
|
132
|
+
points: { show: false }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
updateY() {
|
|
136
|
+
if (!this.uplot) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const lastY = this.data[1][this.data[1].length - 1];
|
|
140
|
+
const yRatio = this.uplot.scales.y.valToPct(lastY);
|
|
141
|
+
this.y = yRatio * this.chart.clientHeight;
|
|
142
|
+
this.updateZeroLine();
|
|
143
|
+
}
|
|
144
|
+
updateZeroLine() {
|
|
145
|
+
if (!this.uplot) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const yRatio = this.uplot.scales.y.valToPct(0);
|
|
149
|
+
this.zeroLineY = yRatio * this.chart.clientHeight;
|
|
150
|
+
}
|
|
151
|
+
updated(changedProperties) {
|
|
152
|
+
if (changedProperties.has("data") || changedProperties.has("layout")) {
|
|
153
|
+
this.updatePalette();
|
|
154
|
+
this.uplot?.setData(this.data);
|
|
155
|
+
requestAnimationFrame(() => this.updateY());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
render() {
|
|
159
|
+
return html`
|
|
160
|
+
<div
|
|
161
|
+
class="chart-container ${this._effectivePriority} ${this._effectiveSize}"
|
|
162
|
+
>
|
|
163
|
+
<div
|
|
164
|
+
id="zero-line"
|
|
165
|
+
style="transform: translateY(${-this.zeroLineY}px);
|
|
166
|
+
display: ${this.zeroLineY > -0.5 ? "block" : "none"};
|
|
167
|
+
"
|
|
168
|
+
></div>
|
|
169
|
+
<div
|
|
170
|
+
id="dot"
|
|
171
|
+
style="transform: translateY(${-this.y}px);
|
|
172
|
+
display: ${this.y > -0.5 ? "block" : "none"};
|
|
173
|
+
"
|
|
174
|
+
></div>
|
|
175
|
+
</div>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
ObcIndicatorGraph.styles = unsafeCSS(compentStyle);
|
|
180
|
+
__decorateClass([
|
|
181
|
+
property({ type: Array })
|
|
182
|
+
], ObcIndicatorGraph.prototype, "data", 2);
|
|
183
|
+
__decorateClass([
|
|
184
|
+
property({ type: Object })
|
|
185
|
+
], ObcIndicatorGraph.prototype, "layout", 2);
|
|
186
|
+
__decorateClass([
|
|
187
|
+
query(".chart-container")
|
|
188
|
+
], ObcIndicatorGraph.prototype, "chart", 2);
|
|
189
|
+
__decorateClass([
|
|
190
|
+
state()
|
|
191
|
+
], ObcIndicatorGraph.prototype, "y", 2);
|
|
192
|
+
__decorateClass([
|
|
193
|
+
state()
|
|
194
|
+
], ObcIndicatorGraph.prototype, "zeroLineY", 2);
|
|
195
|
+
ObcIndicatorGraph = __decorateClass([
|
|
196
|
+
customElement("obc-indicator-graph")
|
|
197
|
+
], ObcIndicatorGraph);
|
|
198
|
+
export {
|
|
199
|
+
ObcIndicatorGraph,
|
|
200
|
+
ObcIndicatorGraphPriority,
|
|
201
|
+
ObcIndicatorGraphSize
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=indicator-graph.js.map
|