@molecule/app-bias-indicator-vue 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +272 -2
- package/dist/BiasIndicator.d.ts +105 -0
- package/dist/BiasIndicator.d.ts.map +1 -0
- package/dist/BiasIndicator.js +295 -0
- package/dist/BiasIndicator.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +45 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +66 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,273 @@
|
|
|
1
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-16T18:57:15.205Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-bias-indicator-vue
|
|
10
|
+
|
|
11
|
+
Vue political-bias / source-credibility indicator.
|
|
12
|
+
|
|
13
|
+
Exports `<BiasIndicator>` — left/right scale with marker plus optional
|
|
14
|
+
reliability dot/chip — for news-aggregator article headers and dense
|
|
15
|
+
article lists (compact variant). It is the Vue counterpart of
|
|
16
|
+
`@molecule/app-bias-indicator-react`: same props and the same DOM for the
|
|
17
|
+
same input.
|
|
18
|
+
|
|
19
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
20
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
21
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createApp, defineComponent, h } from 'vue'
|
|
27
|
+
import { BiasIndicator } from '@molecule/app-bias-indicator-vue'
|
|
28
|
+
|
|
29
|
+
const Article = defineComponent({
|
|
30
|
+
setup() {
|
|
31
|
+
return () => h(BiasIndicator, { bias: -0.4, reliability: 0.8, sourceLabel: 'Reuters' })
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
createApp(Article).mount('#app')
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Type
|
|
39
|
+
|
|
40
|
+
`feature`
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @molecule/app-bias-indicator-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### Interfaces
|
|
51
|
+
|
|
52
|
+
#### `BiasIndicatorProps`
|
|
53
|
+
|
|
54
|
+
Props accepted by the {@link BiasIndicator} component.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface BiasIndicatorProps {
|
|
58
|
+
/**
|
|
59
|
+
* Bias scalar from `-1` (far left) through `0` (center) to `+1`
|
|
60
|
+
* (far right). Values are clamped before rendering.
|
|
61
|
+
*/
|
|
62
|
+
bias: number
|
|
63
|
+
/**
|
|
64
|
+
* Optional source-credibility / reliability score from `0` (lowest /
|
|
65
|
+
* disputed) to `1` (highest). When omitted, no reliability indicator
|
|
66
|
+
* is rendered.
|
|
67
|
+
*/
|
|
68
|
+
reliability?: number
|
|
69
|
+
/**
|
|
70
|
+
* Compact variant collapses the scale to a single coloured dot —
|
|
71
|
+
* useful for dense lists. Defaults to `false`.
|
|
72
|
+
*/
|
|
73
|
+
compact?: boolean
|
|
74
|
+
/**
|
|
75
|
+
* Optional source name (e.g. `'Reuters'`). Renders as a small caption.
|
|
76
|
+
* Passed as a prop or as the same-named slot — both work.
|
|
77
|
+
*/
|
|
78
|
+
sourceLabel?: VNodeChild
|
|
79
|
+
/** Extra classes to merge onto the root element. */
|
|
80
|
+
className?: string
|
|
81
|
+
/** `data-mol-id` for AI-agent / E2E selectors. */
|
|
82
|
+
dataMolId?: string
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Types
|
|
87
|
+
|
|
88
|
+
#### `ReliabilityTier`
|
|
89
|
+
|
|
90
|
+
Reliability tier — drives the colour + label of the optional dot/chip.
|
|
91
|
+
Mapped from a 0..1 reliability score by `reliabilityToTier`.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
type ReliabilityTier = 'high' | 'medium' | 'low' | 'disputed'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### `BiasBucket`
|
|
98
|
+
|
|
99
|
+
Bias bucket — drives the bias-marker hue and the screen-reader label.
|
|
100
|
+
Derived from a -1..1 bias scalar by `biasToBucket`.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
type BiasBucket = 'far-left' | 'left' | 'center' | 'right' | 'far-right'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Functions
|
|
107
|
+
|
|
108
|
+
#### `clamp(value, min, max)`
|
|
109
|
+
|
|
110
|
+
Clamp a number into the inclusive `[min, max]` range.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
function clamp(value: number, min: number, max: number): number
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `value` — Value to clamp.
|
|
117
|
+
- `min` — Lower bound.
|
|
118
|
+
- `max` — Upper bound.
|
|
119
|
+
|
|
120
|
+
**Returns:** The clamped value.
|
|
121
|
+
|
|
122
|
+
#### `biasToBucket(bias)`
|
|
123
|
+
|
|
124
|
+
Map a `-1..1` bias scalar into a coarse five-bucket label used for
|
|
125
|
+
accessibility and colouring. Boundaries: `<= -0.6` far-left,
|
|
126
|
+
`<= -0.2` left, `< 0.2` center, `< 0.6` right, otherwise far-right.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
function biasToBucket(bias: number): BiasBucket
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- `bias` — Bias scalar (clamped to `[-1, 1]` first).
|
|
133
|
+
|
|
134
|
+
**Returns:** The bias bucket.
|
|
135
|
+
|
|
136
|
+
#### `reliabilityToTier(reliability)`
|
|
137
|
+
|
|
138
|
+
Map a `0..1` reliability score into a four-tier label. Boundaries:
|
|
139
|
+
`>= 0.75` high, `>= 0.5` medium, `>= 0.25` low, otherwise disputed.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
function reliabilityToTier(reliability: number): ReliabilityTier
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
- `reliability` — Reliability scalar (clamped to `[0, 1]` first).
|
|
146
|
+
|
|
147
|
+
**Returns:** The reliability tier.
|
|
148
|
+
|
|
149
|
+
#### `biasToPercent(bias)`
|
|
150
|
+
|
|
151
|
+
Convert a `-1..1` bias value into a `0..100` percent offset for
|
|
152
|
+
absolute positioning along the scale track.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
function biasToPercent(bias: number): number
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- `bias` — Bias scalar (clamped to `[-1, 1]` first).
|
|
159
|
+
|
|
160
|
+
**Returns:** The percent offset from the left edge of the track.
|
|
161
|
+
|
|
162
|
+
#### `bucketColor(bucket)`
|
|
163
|
+
|
|
164
|
+
Resolve the marker colour for a given bias bucket. Uses semantic CSS
|
|
165
|
+
custom properties so swapping themes / styling libraries does not
|
|
166
|
+
require touching this component.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
function bucketColor(bucket: BiasBucket): string
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- `bucket` — Bias bucket.
|
|
173
|
+
|
|
174
|
+
**Returns:** A `var(--…)` CSS color string.
|
|
175
|
+
|
|
176
|
+
#### `tierColor(tier)`
|
|
177
|
+
|
|
178
|
+
Resolve the dot colour for a given reliability tier.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
function tierColor(tier: ReliabilityTier): string
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- `tier` — Reliability tier.
|
|
185
|
+
|
|
186
|
+
**Returns:** A `var(--…)` CSS color string.
|
|
187
|
+
|
|
188
|
+
### Constants
|
|
189
|
+
|
|
190
|
+
#### `BiasIndicator`
|
|
191
|
+
|
|
192
|
+
Political-bias / source-credibility indicator for news article headers.
|
|
193
|
+
Renders a horizontal `-1..+1` scale with a coloured marker at `bias`, plus
|
|
194
|
+
an optional reliability dot/chip below. The compact variant collapses to a
|
|
195
|
+
single coloured dot, suitable for dense article lists.
|
|
196
|
+
|
|
197
|
+
Colours come from semantic CSS custom properties (`--color-info`,
|
|
198
|
+
`--color-warning`, `--color-error`, `--color-success`,
|
|
199
|
+
`--color-foreground-secondary`) so per-app theming flows through without
|
|
200
|
+
code changes.
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const BiasIndicator: DefineComponent<
|
|
204
|
+
ExtractPropTypes<{
|
|
205
|
+
bias: { type: NumberConstructor; required: true }
|
|
206
|
+
reliability: NumberConstructor
|
|
207
|
+
compact: { type: BooleanConstructor; default: boolean }
|
|
208
|
+
sourceLabel: null
|
|
209
|
+
className: StringConstructor
|
|
210
|
+
dataMolId: StringConstructor
|
|
211
|
+
}>,
|
|
212
|
+
() => VNode,
|
|
213
|
+
{},
|
|
214
|
+
{},
|
|
215
|
+
{},
|
|
216
|
+
ComponentOptionsMixin,
|
|
217
|
+
ComponentOptionsMixin,
|
|
218
|
+
{},
|
|
219
|
+
string,
|
|
220
|
+
PublicProps,
|
|
221
|
+
Readonly<
|
|
222
|
+
ExtractPropTypes<{
|
|
223
|
+
bias: { type: NumberConstructor; required: true }
|
|
224
|
+
reliability: NumberConstructor
|
|
225
|
+
compact: { type: BooleanConstructor; default: boolean }
|
|
226
|
+
sourceLabel: null
|
|
227
|
+
className: StringConstructor
|
|
228
|
+
dataMolId: StringConstructor
|
|
229
|
+
}>
|
|
230
|
+
> &
|
|
231
|
+
Readonly<{}>,
|
|
232
|
+
{ compact: boolean },
|
|
233
|
+
{},
|
|
234
|
+
{},
|
|
235
|
+
{},
|
|
236
|
+
string,
|
|
237
|
+
ComponentProvideOptions,
|
|
238
|
+
true,
|
|
239
|
+
{},
|
|
240
|
+
any
|
|
241
|
+
>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
- `props` — Component props (see {@link BiasIndicatorProps}).
|
|
245
|
+
|
|
246
|
+
**Returns:** The indicator component.
|
|
247
|
+
|
|
248
|
+
## Injection Notes
|
|
249
|
+
|
|
250
|
+
### Requirements
|
|
251
|
+
|
|
252
|
+
Peer dependencies:
|
|
253
|
+
|
|
254
|
+
- `@molecule/app-ui` ^1.0.1
|
|
255
|
+
- `@molecule/app-ui-vue` ^1.1.0
|
|
256
|
+
- `@molecule/app-vue` ^3.5.0
|
|
257
|
+
- `vue` ^3.4.0
|
|
258
|
+
|
|
259
|
+
### Runtime Dependencies
|
|
260
|
+
|
|
261
|
+
- `@molecule/app-ui`
|
|
262
|
+
- `@molecule/app-ui-vue`
|
|
263
|
+
- `@molecule/app-vue`
|
|
264
|
+
- `vue`
|
|
265
|
+
|
|
266
|
+
- Requires a bonded ClassMap and an i18n provider (the component reads
|
|
267
|
+
`useTranslation()`), exactly like the React package.
|
|
268
|
+
- Colours come from the per-app semantic CSS custom properties, so themes
|
|
269
|
+
flow through without code changes.
|
|
270
|
+
|
|
271
|
+
## Translations
|
|
272
|
+
|
|
273
|
+
Translation strings are provided by `@molecule/app-locales-bias-indicator`.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue political-bias / source-credibility indicator.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-bias-indicator-react`'s `BiasIndicator` —
|
|
5
|
+
* the same props (React names), the same ClassMap tokens, the same inline
|
|
6
|
+
* styles, and the same DOM for the same input.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type VNode } from 'vue';
|
|
11
|
+
import type { BiasBucket, ReliabilityTier } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Clamp a number into the inclusive `[min, max]` range.
|
|
14
|
+
*
|
|
15
|
+
* @param value - Value to clamp.
|
|
16
|
+
* @param min - Lower bound.
|
|
17
|
+
* @param max - Upper bound.
|
|
18
|
+
* @returns The clamped value.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Map a `-1..1` bias scalar into a coarse five-bucket label used for
|
|
23
|
+
* accessibility and colouring. Boundaries: `<= -0.6` far-left,
|
|
24
|
+
* `<= -0.2` left, `< 0.2` center, `< 0.6` right, otherwise far-right.
|
|
25
|
+
*
|
|
26
|
+
* @param bias - Bias scalar (clamped to `[-1, 1]` first).
|
|
27
|
+
* @returns The bias bucket.
|
|
28
|
+
*/
|
|
29
|
+
export declare function biasToBucket(bias: number): BiasBucket;
|
|
30
|
+
/**
|
|
31
|
+
* Map a `0..1` reliability score into a four-tier label. Boundaries:
|
|
32
|
+
* `>= 0.75` high, `>= 0.5` medium, `>= 0.25` low, otherwise disputed.
|
|
33
|
+
*
|
|
34
|
+
* @param reliability - Reliability scalar (clamped to `[0, 1]` first).
|
|
35
|
+
* @returns The reliability tier.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reliabilityToTier(reliability: number): ReliabilityTier;
|
|
38
|
+
/**
|
|
39
|
+
* Convert a `-1..1` bias value into a `0..100` percent offset for
|
|
40
|
+
* absolute positioning along the scale track.
|
|
41
|
+
*
|
|
42
|
+
* @param bias - Bias scalar (clamped to `[-1, 1]` first).
|
|
43
|
+
* @returns The percent offset from the left edge of the track.
|
|
44
|
+
*/
|
|
45
|
+
export declare function biasToPercent(bias: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the marker colour for a given bias bucket. Uses semantic CSS
|
|
48
|
+
* custom properties so swapping themes / styling libraries does not
|
|
49
|
+
* require touching this component.
|
|
50
|
+
*
|
|
51
|
+
* @param bucket - Bias bucket.
|
|
52
|
+
* @returns A `var(--…)` CSS color string.
|
|
53
|
+
*/
|
|
54
|
+
export declare function bucketColor(bucket: BiasBucket): string;
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the dot colour for a given reliability tier.
|
|
57
|
+
*
|
|
58
|
+
* @param tier - Reliability tier.
|
|
59
|
+
* @returns A `var(--…)` CSS color string.
|
|
60
|
+
*/
|
|
61
|
+
export declare function tierColor(tier: ReliabilityTier): string;
|
|
62
|
+
/**
|
|
63
|
+
* Political-bias / source-credibility indicator for news article headers.
|
|
64
|
+
* Renders a horizontal `-1..+1` scale with a coloured marker at `bias`, plus
|
|
65
|
+
* an optional reliability dot/chip below. The compact variant collapses to a
|
|
66
|
+
* single coloured dot, suitable for dense article lists.
|
|
67
|
+
*
|
|
68
|
+
* Colours come from semantic CSS custom properties (`--color-info`,
|
|
69
|
+
* `--color-warning`, `--color-error`, `--color-success`,
|
|
70
|
+
* `--color-foreground-secondary`) so per-app theming flows through without
|
|
71
|
+
* code changes.
|
|
72
|
+
*
|
|
73
|
+
* @param props - Component props (see {@link BiasIndicatorProps}).
|
|
74
|
+
* @returns The indicator component.
|
|
75
|
+
*/
|
|
76
|
+
export declare const BiasIndicator: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
77
|
+
bias: {
|
|
78
|
+
type: NumberConstructor;
|
|
79
|
+
required: true;
|
|
80
|
+
};
|
|
81
|
+
reliability: NumberConstructor;
|
|
82
|
+
compact: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
default: boolean;
|
|
85
|
+
};
|
|
86
|
+
sourceLabel: null;
|
|
87
|
+
className: StringConstructor;
|
|
88
|
+
dataMolId: StringConstructor;
|
|
89
|
+
}>, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
90
|
+
bias: {
|
|
91
|
+
type: NumberConstructor;
|
|
92
|
+
required: true;
|
|
93
|
+
};
|
|
94
|
+
reliability: NumberConstructor;
|
|
95
|
+
compact: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
sourceLabel: null;
|
|
100
|
+
className: StringConstructor;
|
|
101
|
+
dataMolId: StringConstructor;
|
|
102
|
+
}>> & Readonly<{}>, {
|
|
103
|
+
compact: boolean;
|
|
104
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
105
|
+
//# sourceMappingURL=BiasIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BiasIndicator.d.ts","sourceRoot":"","sources":["../src/BiasIndicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,KAAK,EAAmB,MAAM,KAAK,CAAA;AAKrE,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE7D;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAOrD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAatD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAWvD;AA2CD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;UAiCX,KAAK;;;;;;;;;;;;;;;4EA2HlB,CAAA"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue political-bias / source-credibility indicator.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-bias-indicator-react`'s `BiasIndicator` —
|
|
5
|
+
* the same props (React names), the same ClassMap tokens, the same inline
|
|
6
|
+
* styles, and the same DOM for the same input.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h } from 'vue';
|
|
11
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
12
|
+
import { useTranslation } from '@molecule/app-vue';
|
|
13
|
+
/**
|
|
14
|
+
* Clamp a number into the inclusive `[min, max]` range.
|
|
15
|
+
*
|
|
16
|
+
* @param value - Value to clamp.
|
|
17
|
+
* @param min - Lower bound.
|
|
18
|
+
* @param max - Upper bound.
|
|
19
|
+
* @returns The clamped value.
|
|
20
|
+
*/
|
|
21
|
+
export function clamp(value, min, max) {
|
|
22
|
+
if (Number.isNaN(value))
|
|
23
|
+
return min;
|
|
24
|
+
if (value < min)
|
|
25
|
+
return min;
|
|
26
|
+
if (value > max)
|
|
27
|
+
return max;
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Map a `-1..1` bias scalar into a coarse five-bucket label used for
|
|
32
|
+
* accessibility and colouring. Boundaries: `<= -0.6` far-left,
|
|
33
|
+
* `<= -0.2` left, `< 0.2` center, `< 0.6` right, otherwise far-right.
|
|
34
|
+
*
|
|
35
|
+
* @param bias - Bias scalar (clamped to `[-1, 1]` first).
|
|
36
|
+
* @returns The bias bucket.
|
|
37
|
+
*/
|
|
38
|
+
export function biasToBucket(bias) {
|
|
39
|
+
const b = clamp(bias, -1, 1);
|
|
40
|
+
if (b <= -0.6)
|
|
41
|
+
return 'far-left';
|
|
42
|
+
if (b <= -0.2)
|
|
43
|
+
return 'left';
|
|
44
|
+
if (b < 0.2)
|
|
45
|
+
return 'center';
|
|
46
|
+
if (b < 0.6)
|
|
47
|
+
return 'right';
|
|
48
|
+
return 'far-right';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Map a `0..1` reliability score into a four-tier label. Boundaries:
|
|
52
|
+
* `>= 0.75` high, `>= 0.5` medium, `>= 0.25` low, otherwise disputed.
|
|
53
|
+
*
|
|
54
|
+
* @param reliability - Reliability scalar (clamped to `[0, 1]` first).
|
|
55
|
+
* @returns The reliability tier.
|
|
56
|
+
*/
|
|
57
|
+
export function reliabilityToTier(reliability) {
|
|
58
|
+
const r = clamp(reliability, 0, 1);
|
|
59
|
+
if (r >= 0.75)
|
|
60
|
+
return 'high';
|
|
61
|
+
if (r >= 0.5)
|
|
62
|
+
return 'medium';
|
|
63
|
+
if (r >= 0.25)
|
|
64
|
+
return 'low';
|
|
65
|
+
return 'disputed';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert a `-1..1` bias value into a `0..100` percent offset for
|
|
69
|
+
* absolute positioning along the scale track.
|
|
70
|
+
*
|
|
71
|
+
* @param bias - Bias scalar (clamped to `[-1, 1]` first).
|
|
72
|
+
* @returns The percent offset from the left edge of the track.
|
|
73
|
+
*/
|
|
74
|
+
export function biasToPercent(bias) {
|
|
75
|
+
return ((clamp(bias, -1, 1) + 1) / 2) * 100;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the marker colour for a given bias bucket. Uses semantic CSS
|
|
79
|
+
* custom properties so swapping themes / styling libraries does not
|
|
80
|
+
* require touching this component.
|
|
81
|
+
*
|
|
82
|
+
* @param bucket - Bias bucket.
|
|
83
|
+
* @returns A `var(--…)` CSS color string.
|
|
84
|
+
*/
|
|
85
|
+
export function bucketColor(bucket) {
|
|
86
|
+
switch (bucket) {
|
|
87
|
+
case 'far-left':
|
|
88
|
+
return 'var(--color-info, #2563eb)';
|
|
89
|
+
case 'left':
|
|
90
|
+
return 'var(--color-info-light, #60a5fa)';
|
|
91
|
+
case 'center':
|
|
92
|
+
return 'var(--color-foreground-secondary, #6b7280)';
|
|
93
|
+
case 'right':
|
|
94
|
+
return 'var(--color-warning-light, #fbbf24)';
|
|
95
|
+
case 'far-right':
|
|
96
|
+
return 'var(--color-error, #dc2626)';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Resolve the dot colour for a given reliability tier.
|
|
101
|
+
*
|
|
102
|
+
* @param tier - Reliability tier.
|
|
103
|
+
* @returns A `var(--…)` CSS color string.
|
|
104
|
+
*/
|
|
105
|
+
export function tierColor(tier) {
|
|
106
|
+
switch (tier) {
|
|
107
|
+
case 'high':
|
|
108
|
+
return 'var(--color-success, #16a34a)';
|
|
109
|
+
case 'medium':
|
|
110
|
+
return 'var(--color-info, #2563eb)';
|
|
111
|
+
case 'low':
|
|
112
|
+
return 'var(--color-warning, #d97706)';
|
|
113
|
+
case 'disputed':
|
|
114
|
+
return 'var(--color-error, #dc2626)';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** i18n key per bias bucket. */
|
|
118
|
+
const BIAS_KEY = {
|
|
119
|
+
'far-left': 'biasIndicator.bias.farLeft',
|
|
120
|
+
left: 'biasIndicator.bias.leftLeaning',
|
|
121
|
+
center: 'biasIndicator.bias.center',
|
|
122
|
+
right: 'biasIndicator.bias.rightLeaning',
|
|
123
|
+
'far-right': 'biasIndicator.bias.farRight',
|
|
124
|
+
};
|
|
125
|
+
/** English fallback per bias bucket. */
|
|
126
|
+
const BIAS_FALLBACK = {
|
|
127
|
+
'far-left': 'Far left',
|
|
128
|
+
left: 'Left-leaning',
|
|
129
|
+
center: 'Center',
|
|
130
|
+
right: 'Right-leaning',
|
|
131
|
+
'far-right': 'Far right',
|
|
132
|
+
};
|
|
133
|
+
/** i18n key per reliability tier. */
|
|
134
|
+
const TIER_KEY = {
|
|
135
|
+
high: 'biasIndicator.reliability.high',
|
|
136
|
+
medium: 'biasIndicator.reliability.medium',
|
|
137
|
+
low: 'biasIndicator.reliability.low',
|
|
138
|
+
disputed: 'biasIndicator.reliability.disputed',
|
|
139
|
+
};
|
|
140
|
+
/** English fallback per reliability tier. */
|
|
141
|
+
const TIER_FALLBACK = {
|
|
142
|
+
high: 'Reliability: high',
|
|
143
|
+
medium: 'Reliability: medium',
|
|
144
|
+
low: 'Reliability: low',
|
|
145
|
+
disputed: 'Reliability: disputed',
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The baked-in scale gradient: info → info-light → neutral → warning-light →
|
|
149
|
+
* error, so the track reads left-to-right without any styling library.
|
|
150
|
+
*/
|
|
151
|
+
const SCALE_GRADIENT = 'linear-gradient(to right, var(--color-info, #2563eb) 0%, var(--color-info-light, #60a5fa) 25%, var(--color-foreground-secondary, #9ca3af) 50%, var(--color-warning-light, #fbbf24) 75%, var(--color-error, #dc2626) 100%)';
|
|
152
|
+
/**
|
|
153
|
+
* Political-bias / source-credibility indicator for news article headers.
|
|
154
|
+
* Renders a horizontal `-1..+1` scale with a coloured marker at `bias`, plus
|
|
155
|
+
* an optional reliability dot/chip below. The compact variant collapses to a
|
|
156
|
+
* single coloured dot, suitable for dense article lists.
|
|
157
|
+
*
|
|
158
|
+
* Colours come from semantic CSS custom properties (`--color-info`,
|
|
159
|
+
* `--color-warning`, `--color-error`, `--color-success`,
|
|
160
|
+
* `--color-foreground-secondary`) so per-app theming flows through without
|
|
161
|
+
* code changes.
|
|
162
|
+
*
|
|
163
|
+
* @param props - Component props (see {@link BiasIndicatorProps}).
|
|
164
|
+
* @returns The indicator component.
|
|
165
|
+
*/
|
|
166
|
+
export const BiasIndicator = defineComponent({
|
|
167
|
+
name: 'BiasIndicator',
|
|
168
|
+
props: {
|
|
169
|
+
bias: {
|
|
170
|
+
type: Number,
|
|
171
|
+
required: true,
|
|
172
|
+
},
|
|
173
|
+
reliability: Number,
|
|
174
|
+
compact: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: false,
|
|
177
|
+
},
|
|
178
|
+
sourceLabel: null,
|
|
179
|
+
className: String,
|
|
180
|
+
dataMolId: String,
|
|
181
|
+
},
|
|
182
|
+
setup(props, { slots }) {
|
|
183
|
+
const cm = getClassMap();
|
|
184
|
+
const { t } = useTranslation();
|
|
185
|
+
/**
|
|
186
|
+
* The source caption's children, from the same-named slot or the prop.
|
|
187
|
+
*
|
|
188
|
+
* @returns The caption's children, empty when neither was provided.
|
|
189
|
+
*/
|
|
190
|
+
const sourceChildren = () => {
|
|
191
|
+
const slot = slots.sourceLabel;
|
|
192
|
+
if (slot)
|
|
193
|
+
return slot();
|
|
194
|
+
return props.sourceLabel !== undefined && props.sourceLabel !== null
|
|
195
|
+
? [props.sourceLabel]
|
|
196
|
+
: [];
|
|
197
|
+
};
|
|
198
|
+
return () => {
|
|
199
|
+
const bucket = biasToBucket(props.bias);
|
|
200
|
+
const biasLabel = t(BIAS_KEY[bucket], {}, { defaultValue: BIAS_FALLBACK[bucket] });
|
|
201
|
+
const tier = props.reliability !== undefined ? reliabilityToTier(props.reliability) : null;
|
|
202
|
+
const tierLabel = tier ? t(TIER_KEY[tier], {}, { defaultValue: TIER_FALLBACK[tier] }) : null;
|
|
203
|
+
const color = bucketColor(bucket);
|
|
204
|
+
const dataMolId = props.dataMolId ?? 'bias-indicator';
|
|
205
|
+
const hasSource = slots.sourceLabel !== undefined || props.sourceLabel !== undefined;
|
|
206
|
+
if (props.compact) {
|
|
207
|
+
return h('span', {
|
|
208
|
+
role: 'img',
|
|
209
|
+
'aria-label': tierLabel ? `${biasLabel} — ${tierLabel}` : biasLabel,
|
|
210
|
+
'data-mol-id': dataMolId,
|
|
211
|
+
'data-bias-bucket': bucket,
|
|
212
|
+
'data-reliability-tier': tier ?? undefined,
|
|
213
|
+
class: cm.cn(cm.flex({ align: 'center', gap: 'xs' }), props.className),
|
|
214
|
+
}, [
|
|
215
|
+
h('span', {
|
|
216
|
+
'aria-hidden': true,
|
|
217
|
+
class: cm.cn(cm.w(2), cm.h(2), cm.roundedFull, cm.displayInlineBlock),
|
|
218
|
+
style: { background: color },
|
|
219
|
+
}),
|
|
220
|
+
...(hasSource
|
|
221
|
+
? [h('span', { class: cm.cn(cm.textSize('xs'), cm.textMuted) }, sourceChildren())]
|
|
222
|
+
: []),
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
const percent = biasToPercent(props.bias);
|
|
226
|
+
return h('div', {
|
|
227
|
+
'data-mol-id': dataMolId,
|
|
228
|
+
'data-bias-bucket': bucket,
|
|
229
|
+
'data-reliability-tier': tier ?? undefined,
|
|
230
|
+
class: cm.cn(cm.flex({ direction: 'col', gap: 'xs' }), props.className),
|
|
231
|
+
}, [
|
|
232
|
+
...(hasSource
|
|
233
|
+
? [
|
|
234
|
+
h('span', {
|
|
235
|
+
'data-mol-id': 'bias-indicator-source',
|
|
236
|
+
class: cm.cn(cm.textSize('xs'), cm.fontWeight('semibold')),
|
|
237
|
+
}, sourceChildren()),
|
|
238
|
+
]
|
|
239
|
+
: []),
|
|
240
|
+
h('div', {
|
|
241
|
+
role: 'img',
|
|
242
|
+
'aria-label': biasLabel,
|
|
243
|
+
'data-mol-id': 'bias-indicator-scale',
|
|
244
|
+
class: cm.cn(cm.position('relative'), cm.h(2)),
|
|
245
|
+
style: {
|
|
246
|
+
width: '100%',
|
|
247
|
+
minWidth: '80px',
|
|
248
|
+
borderRadius: '999px',
|
|
249
|
+
background: SCALE_GRADIENT,
|
|
250
|
+
opacity: 0.45,
|
|
251
|
+
},
|
|
252
|
+
}, [
|
|
253
|
+
h('span', {
|
|
254
|
+
'data-mol-id': 'bias-indicator-marker',
|
|
255
|
+
'aria-hidden': true,
|
|
256
|
+
class: cm.cn(cm.position('absolute'), cm.roundedFull),
|
|
257
|
+
style: {
|
|
258
|
+
left: `${percent}%`,
|
|
259
|
+
top: '50%',
|
|
260
|
+
transform: 'translate(-50%, -50%)',
|
|
261
|
+
width: '12px',
|
|
262
|
+
height: '12px',
|
|
263
|
+
background: color,
|
|
264
|
+
border: '2px solid var(--color-surface, #ffffff)',
|
|
265
|
+
boxShadow: '0 0 0 1px var(--color-border, rgba(0,0,0,0.15))',
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
]),
|
|
269
|
+
h('div', { class: cm.cn(cm.flex({ align: 'center', justify: 'between', gap: 'xs' })) }, [
|
|
270
|
+
h('span', {
|
|
271
|
+
'data-mol-id': 'bias-indicator-bias-label',
|
|
272
|
+
class: cm.cn(cm.textSize('xs')),
|
|
273
|
+
}, biasLabel),
|
|
274
|
+
...(tier && tierLabel
|
|
275
|
+
? [
|
|
276
|
+
h('span', {
|
|
277
|
+
'data-mol-id': 'bias-indicator-reliability',
|
|
278
|
+
'data-reliability-tier': tier,
|
|
279
|
+
class: cm.cn(cm.flex({ align: 'center', gap: 'xs' }), cm.textSize('xs')),
|
|
280
|
+
}, [
|
|
281
|
+
h('span', {
|
|
282
|
+
'aria-hidden': true,
|
|
283
|
+
class: cm.cn(cm.w(2), cm.h(2), cm.roundedFull, cm.displayInlineBlock),
|
|
284
|
+
style: { background: tierColor(tier) },
|
|
285
|
+
}),
|
|
286
|
+
h('span', tierLabel),
|
|
287
|
+
]),
|
|
288
|
+
]
|
|
289
|
+
: []),
|
|
290
|
+
]),
|
|
291
|
+
]);
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
//# sourceMappingURL=BiasIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BiasIndicator.js","sourceRoot":"","sources":["../src/BiasIndicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAA+B,MAAM,KAAK,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIlD;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC3D,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAA;IACnC,IAAI,KAAK,GAAG,GAAG;QAAE,OAAO,GAAG,CAAA;IAC3B,IAAI,KAAK,GAAG,GAAG;QAAE,OAAO,GAAG,CAAA;IAC3B,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC5B,IAAI,CAAC,IAAI,CAAC,GAAG;QAAE,OAAO,UAAU,CAAA;IAChC,IAAI,CAAC,IAAI,CAAC,GAAG;QAAE,OAAO,MAAM,CAAA;IAC5B,IAAI,CAAC,GAAG,GAAG;QAAE,OAAO,QAAQ,CAAA;IAC5B,IAAI,CAAC,GAAG,GAAG;QAAE,OAAO,OAAO,CAAA;IAC3B,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAClC,I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,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;qBAChC,EACD,SAAS,CACV;oBACD,GAAG,CAAC,IAAI,IAAI,SAAS;wBACnB,CAAC,CAAC;4BACE,CAAC,CACC,MAAM,EACN;gCACE,aAAa,EAAE,4BAA4B;gCAC3C,uBAAuB,EAAE,IAAI;gCAC7B,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;6BACzE,EACD;gCACE,CAAC,CAAC,MAAM,EAAE;oCACR,aAAa,EAAE,IAAI;oCACnB,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,kBAAkB,CAAC;oCACrE,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE;iCACvC,CAAC;gCACF,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC;6BACrB,CACF;yBACF;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC;aACH,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue political-bias / source-credibility indicator.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<BiasIndicator>` — left/right scale with marker plus optional
|
|
5
|
+
* reliability dot/chip — for news-aggregator article headers and dense
|
|
6
|
+
* article lists (compact variant). It is the Vue counterpart of
|
|
7
|
+
* `@molecule/app-bias-indicator-react`: same props and the same DOM for the
|
|
8
|
+
* same input.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createApp, defineComponent, h } from 'vue'
|
|
13
|
+
* import { BiasIndicator } from '@molecule/app-bias-indicator-vue'
|
|
14
|
+
*
|
|
15
|
+
* const Article = defineComponent({
|
|
16
|
+
* setup() {
|
|
17
|
+
* return () =>
|
|
18
|
+
* h(BiasIndicator, { bias: -0.4, reliability: 0.8, sourceLabel: 'Reuters' })
|
|
19
|
+
* },
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* createApp(Article).mount('#app')
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* - Requires a bonded ClassMap and an i18n provider (the component reads
|
|
27
|
+
* `useTranslation()`), exactly like the React package.
|
|
28
|
+
* - Colours come from the per-app semantic CSS custom properties, so themes
|
|
29
|
+
* flow through without code changes.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
export * from './BiasIndicator.js';
|
|
34
|
+
export * from './types.js';
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue political-bias / source-credibility indicator.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<BiasIndicator>` — left/right scale with marker plus optional
|
|
5
|
+
* reliability dot/chip — for news-aggregator article headers and dense
|
|
6
|
+
* article lists (compact variant). It is the Vue counterpart of
|
|
7
|
+
* `@molecule/app-bias-indicator-react`: same props and the same DOM for the
|
|
8
|
+
* same input.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createApp, defineComponent, h } from 'vue'
|
|
13
|
+
* import { BiasIndicator } from '@molecule/app-bias-indicator-vue'
|
|
14
|
+
*
|
|
15
|
+
* const Article = defineComponent({
|
|
16
|
+
* setup() {
|
|
17
|
+
* return () =>
|
|
18
|
+
* h(BiasIndicator, { bias: -0.4, reliability: 0.8, sourceLabel: 'Reuters' })
|
|
19
|
+
* },
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* createApp(Article).mount('#app')
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* - Requires a bonded ClassMap and an i18n provider (the component reads
|
|
27
|
+
* `useTranslation()`), exactly like the React package.
|
|
28
|
+
* - Colours come from the per-app semantic CSS custom properties, so themes
|
|
29
|
+
* flow through without code changes.
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
export * from './BiasIndicator.js';
|
|
34
|
+
export * from './types.js';
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Vue political-bias / source-credibility indicator.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { VNodeChild } from 'vue';
|
|
7
|
+
/**
|
|
8
|
+
* Reliability tier — drives the colour + label of the optional dot/chip.
|
|
9
|
+
* Mapped from a 0..1 reliability score by `reliabilityToTier`.
|
|
10
|
+
*/
|
|
11
|
+
export type ReliabilityTier = 'high' | 'medium' | 'low' | 'disputed';
|
|
12
|
+
/**
|
|
13
|
+
* Bias bucket — drives the bias-marker hue and the screen-reader label.
|
|
14
|
+
* Derived from a -1..1 bias scalar by `biasToBucket`.
|
|
15
|
+
*/
|
|
16
|
+
export type BiasBucket = 'far-left' | 'left' | 'center' | 'right' | 'far-right';
|
|
17
|
+
/** Props accepted by the {@link BiasIndicator} component. */
|
|
18
|
+
export interface BiasIndicatorProps {
|
|
19
|
+
/**
|
|
20
|
+
* Bias scalar from `-1` (far left) through `0` (center) to `+1`
|
|
21
|
+
* (far right). Values are clamped before rendering.
|
|
22
|
+
*/
|
|
23
|
+
bias: number;
|
|
24
|
+
/**
|
|
25
|
+
* Optional source-credibility / reliability score from `0` (lowest /
|
|
26
|
+
* disputed) to `1` (highest). When omitted, no reliability indicator
|
|
27
|
+
* is rendered.
|
|
28
|
+
*/
|
|
29
|
+
reliability?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Compact variant collapses the scale to a single coloured dot —
|
|
32
|
+
* useful for dense lists. Defaults to `false`.
|
|
33
|
+
*/
|
|
34
|
+
compact?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Optional source name (e.g. `'Reuters'`). Renders as a small caption.
|
|
37
|
+
* Passed as a prop or as the same-named slot — both work.
|
|
38
|
+
*/
|
|
39
|
+
sourceLabel?: VNodeChild;
|
|
40
|
+
/** Extra classes to merge onto the root element. */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** `data-mol-id` for AI-agent / E2E selectors. */
|
|
43
|
+
dataMolId?: string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAA;AAEpE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAA;AAE/E,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-bias-indicator-vue",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Political-bias / source-credibility indicator (left/right scale + reliability tier) for news article headers",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-bias-indicator-vue",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "vue-tsc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"bias",
|
|
28
|
+
"indicator",
|
|
29
|
+
"news",
|
|
30
|
+
"credibility",
|
|
31
|
+
"vue"
|
|
32
|
+
],
|
|
33
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
34
|
+
"license": "Apache-2.0",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
38
|
+
"directory": "packages/app/features/bias-indicator-vue"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
},
|
|
43
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@molecule/app-ui": "^1.0.1",
|
|
49
|
+
"@molecule/app-ui-vue": "^1.1.0",
|
|
50
|
+
"@molecule/app-vue": "^3.5.0",
|
|
51
|
+
"vue": "^3.4.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
55
|
+
"@molecule/app-i18n": "1.2.2",
|
|
56
|
+
"@molecule/app-icons": "1.0.4",
|
|
57
|
+
"@molecule/app-ui": "1.4.0",
|
|
58
|
+
"@molecule/app-ui-vue": "1.1.5",
|
|
59
|
+
"@molecule/app-vue": "3.7.2",
|
|
60
|
+
"@types/node": "26.6.5",
|
|
61
|
+
"jsdom": "30.1.3",
|
|
62
|
+
"typescript": "6.0.3",
|
|
63
|
+
"vite": "8.3.5",
|
|
64
|
+
"vitest": "4.1.12",
|
|
65
|
+
"vue": "3.5.44",
|
|
66
|
+
"vue-tsc": "3.3.13"
|
|
67
|
+
}
|
|
68
|
+
}
|