@bedrock/vue-vc 1.0.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.md +115 -0
- package/README.md +2 -0
- package/components/CredentialBase.vue +156 -0
- package/components/CredentialDetail.vue +50 -0
- package/components/CredentialField.vue +56 -0
- package/components/CredentialSwitch.vue +86 -0
- package/components/DynamicImage.vue +157 -0
- package/components/credentialCommon.js +49 -0
- package/lib/config.js +13 -0
- package/lib/index.js +23 -0
- package/package.json +45 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Bedrock Non-Commercial License v1.0
|
|
2
|
+
===================================
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2011-2022 Digital Bazaar, Inc.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Summary
|
|
8
|
+
=======
|
|
9
|
+
|
|
10
|
+
This license allows the licensee to use Bedrock and its software modules
|
|
11
|
+
for non-commercial purposes such as self-study, research, personal
|
|
12
|
+
projects, or for evaluation purposes. If the licensee uses Bedrock
|
|
13
|
+
directly or indirectly to generate revenue, or to provide products or
|
|
14
|
+
services to more than 500 people (users), the licensee must immediately
|
|
15
|
+
obtain a non-profit or commercial license.
|
|
16
|
+
|
|
17
|
+
Examples
|
|
18
|
+
========
|
|
19
|
+
|
|
20
|
+
These are examples of cases that are allowed by this license:
|
|
21
|
+
|
|
22
|
+
* The licensee is an individual that creates Bedrock-dependent software for
|
|
23
|
+
personal use only.
|
|
24
|
+
* The licensee is an individual or group of students/researchers that uses
|
|
25
|
+
Bedrock to experiment with an idea for a non-commercial project.
|
|
26
|
+
* The licensee is a startup company that prototypes a Bedrock-dependent
|
|
27
|
+
product before they have cash flow and will be testing the prototype
|
|
28
|
+
software with less than 500 users. The service will not generate revenue
|
|
29
|
+
of any kind.
|
|
30
|
+
* The licensee is a for-profit organization that creates a product or
|
|
31
|
+
service that is used by less than 500 users and is built with or
|
|
32
|
+
integrates with Bedrock. The service must be exclusively provided for free
|
|
33
|
+
and no parent, subsidiary, agent, or affiliate organization may profit
|
|
34
|
+
from its use.
|
|
35
|
+
|
|
36
|
+
These cases require a non-profit or commercial license:
|
|
37
|
+
|
|
38
|
+
* The licensee is a non-profit that receives funding to create and/or run a
|
|
39
|
+
Bedrock-dependent service.
|
|
40
|
+
* The licensee is a startup company with Bedrock-dependent software that is
|
|
41
|
+
funded by another organization.
|
|
42
|
+
* The licensee is a startup company that is going into production with
|
|
43
|
+
Bedrock-dependent software.
|
|
44
|
+
* The licensee has more than 500 users using a Bedrock-dependent service
|
|
45
|
+
either directly or indirectly.
|
|
46
|
+
* The licensee is a medium to large organization that builds or integrates a
|
|
47
|
+
commercial product or service with Bedrock.
|
|
48
|
+
|
|
49
|
+
THE LICENSE
|
|
50
|
+
===========
|
|
51
|
+
|
|
52
|
+
This section and all subsequent sections of this document constitute the
|
|
53
|
+
agreement between the licensee and Digital Bazaar, Inc.
|
|
54
|
+
|
|
55
|
+
DEFINITIONS
|
|
56
|
+
===========
|
|
57
|
+
|
|
58
|
+
* Product - The Bedrock software and any modules associated with Bedrock
|
|
59
|
+
where Digital Bazaar, Inc. owns the copyright.
|
|
60
|
+
|
|
61
|
+
CONDITIONS
|
|
62
|
+
==========
|
|
63
|
+
|
|
64
|
+
Redistribution and use in source and binary forms, with or without
|
|
65
|
+
modification, are permitted for NON-COMMERCIAL PURPOSES as long as the
|
|
66
|
+
following conditions are met:
|
|
67
|
+
|
|
68
|
+
1. Any use of the Product must not generate revenue for the licensee or
|
|
69
|
+
any parent, subsidiary, agent, or affiliate of the licensee. Use of
|
|
70
|
+
Product includes, but is not limited to, interacting with any of the
|
|
71
|
+
licensee's Product-dependent products or services over a network.
|
|
72
|
+
|
|
73
|
+
2. The aggregate number of individual people (users) of the licensee's
|
|
74
|
+
products or services that use Product must be less than 500.
|
|
75
|
+
|
|
76
|
+
3. Redistributions of source code must retain the above copyright notice
|
|
77
|
+
intact, this list of conditions and the following disclaimer.
|
|
78
|
+
|
|
79
|
+
4. Redistributions in binary form must reproduce the above copyright
|
|
80
|
+
notice, this license and the following disclaimer in the documentation and
|
|
81
|
+
on a web page available via interactive use and/or other materials
|
|
82
|
+
provided with the distribution.
|
|
83
|
+
|
|
84
|
+
5. Neither the name of the copyright holder, the names of its
|
|
85
|
+
contributors, nor any trademarks held by the copyright holder may be used
|
|
86
|
+
to endorse or promote products or services built using the Product without
|
|
87
|
+
specific prior written permission.
|
|
88
|
+
|
|
89
|
+
6. Any modifications are clearly outlined in release documentation and are
|
|
90
|
+
specifically mentioned as not being a part of an official Product release.
|
|
91
|
+
No additional restrictions to this license may be made when distributing
|
|
92
|
+
modifications.
|
|
93
|
+
|
|
94
|
+
7. For the avoidance of doubt, this license prohibits sublicensing of the
|
|
95
|
+
Product.
|
|
96
|
+
|
|
97
|
+
8. Any breach of this license by licensee must be resolved within 30 days.
|
|
98
|
+
Failure to do so results in the termination of this license.
|
|
99
|
+
|
|
100
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
101
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
102
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
103
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
104
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
105
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
106
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
107
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
108
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
109
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
110
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
111
|
+
|
|
112
|
+
To obtain a non-profit or commercial license for Product, please contact
|
|
113
|
+
Digital Bazaar, Inc. at the following email address:
|
|
114
|
+
|
|
115
|
+
Digital Bazaar <support@digitalbazaar.com>
|
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="column justify-evenly">
|
|
3
|
+
<div
|
|
4
|
+
:class="dense ? 'q-py-none' : 'q-py-xs'"
|
|
5
|
+
class="cb-content col row justify-between items-center">
|
|
6
|
+
<slot name="description">
|
|
7
|
+
<credential-field
|
|
8
|
+
class="col"
|
|
9
|
+
:title="nameOverride.length > 0 ? nameOverride : credentialName"
|
|
10
|
+
title-class="text-left text-subtitle1"
|
|
11
|
+
:value="descriptionOverride.length > 0 ?
|
|
12
|
+
descriptionOverride : description"
|
|
13
|
+
value-class="text-left text-body2 text-grey-7" />
|
|
14
|
+
</slot>
|
|
15
|
+
<slot name="image">
|
|
16
|
+
<dynamic-image
|
|
17
|
+
:src="imageOverride.length > 0 ? imageOverride : credentialImage"
|
|
18
|
+
:size="dense ? 'sm' : 'md'" />
|
|
19
|
+
</slot>
|
|
20
|
+
</div>
|
|
21
|
+
<q-separator
|
|
22
|
+
v-if="(clickable || expandable) && separator"
|
|
23
|
+
class="cb-separator" />
|
|
24
|
+
<div
|
|
25
|
+
:class="dense ? 'q-py-none' : 'q-py-xs'"
|
|
26
|
+
class="col">
|
|
27
|
+
<div
|
|
28
|
+
v-if="clickable"
|
|
29
|
+
class="cb-clickable cursor-pointer
|
|
30
|
+
row items-center justify-center text-grey-7"
|
|
31
|
+
@click="toggleDetails">
|
|
32
|
+
<span class="cb-details-text q-mr-sm">{{detailsText}}</span>
|
|
33
|
+
<q-icon :name="detailsIcon" />
|
|
34
|
+
<q-dialog v-model="state.details">
|
|
35
|
+
<slot name="modal">
|
|
36
|
+
<q-card>
|
|
37
|
+
<slot name="modalHeader" />
|
|
38
|
+
<slot name="modalContent">
|
|
39
|
+
<credential-switch
|
|
40
|
+
v-bind="$attrs"
|
|
41
|
+
mode="details"
|
|
42
|
+
:credential="credential" />
|
|
43
|
+
</slot>
|
|
44
|
+
<slot name="modalFooter" />
|
|
45
|
+
</q-card>
|
|
46
|
+
</slot>
|
|
47
|
+
</q-dialog>
|
|
48
|
+
</div>
|
|
49
|
+
<div
|
|
50
|
+
v-else-if="expandable"
|
|
51
|
+
class="cb-expandable row justify-start text-grey-7 full-width">
|
|
52
|
+
<q-expansion-item
|
|
53
|
+
:label="detailsText"
|
|
54
|
+
class="full-width"
|
|
55
|
+
dense
|
|
56
|
+
dense-toggle
|
|
57
|
+
switch-toggle-side>
|
|
58
|
+
<slot name="expansion">
|
|
59
|
+
<slot name="expansionHeader" />
|
|
60
|
+
<slot name="expansionContent">
|
|
61
|
+
<credential-switch
|
|
62
|
+
v-bind="$attrs"
|
|
63
|
+
mode="details"
|
|
64
|
+
:credential="credential" />
|
|
65
|
+
</slot>
|
|
66
|
+
<slot name="expansionFooter" />
|
|
67
|
+
</slot>
|
|
68
|
+
</q-expansion-item>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script setup>
|
|
75
|
+
/*!
|
|
76
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
77
|
+
*/
|
|
78
|
+
import {computed, defineProps, reactive, toRef, unref} from 'vue';
|
|
79
|
+
import CredentialField from './CredentialField.vue';
|
|
80
|
+
import CredentialSwitch from './CredentialSwitch.vue';
|
|
81
|
+
import DynamicImage from './DynamicImage.vue';
|
|
82
|
+
import {useCredentialCommon} from './credentialCommon.js';
|
|
83
|
+
|
|
84
|
+
const props = defineProps({
|
|
85
|
+
credential: {
|
|
86
|
+
type: Object,
|
|
87
|
+
required: true
|
|
88
|
+
},
|
|
89
|
+
dense: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false
|
|
92
|
+
},
|
|
93
|
+
separator: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: true
|
|
96
|
+
},
|
|
97
|
+
clickable: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false
|
|
100
|
+
},
|
|
101
|
+
expandable: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: false
|
|
104
|
+
},
|
|
105
|
+
detailsText: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: 'Show Details'
|
|
108
|
+
},
|
|
109
|
+
detailsIcon: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: 'far fa-window-restore'
|
|
112
|
+
},
|
|
113
|
+
imageOverride: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: ''
|
|
116
|
+
},
|
|
117
|
+
nameOverride: {
|
|
118
|
+
type: String,
|
|
119
|
+
default: ''
|
|
120
|
+
},
|
|
121
|
+
descriptionOverride: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: ''
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const state = reactive({
|
|
128
|
+
details: false
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const {
|
|
132
|
+
credentialDescription, credentialName,
|
|
133
|
+
credentialImage
|
|
134
|
+
} = useCredentialCommon({
|
|
135
|
+
credential: toRef(props, 'credential')
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const description = computed(() => {
|
|
139
|
+
const _cd = unref(credentialDescription);
|
|
140
|
+
if(_cd.length === 0) {
|
|
141
|
+
return 'No description available.';
|
|
142
|
+
}
|
|
143
|
+
return _cd;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
function toggleDetails() {
|
|
147
|
+
console.log(state.details);
|
|
148
|
+
state.details = !state.details;
|
|
149
|
+
}
|
|
150
|
+
</script>
|
|
151
|
+
|
|
152
|
+
<style lang="scss" scoped>
|
|
153
|
+
.cb-expandable :deep(.q-item__section--avatar) {
|
|
154
|
+
min-width: unset;
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="column justify-evenly">
|
|
3
|
+
<div
|
|
4
|
+
class="cd-content col column items-center justify-start q-pb-md">
|
|
5
|
+
<credential-field
|
|
6
|
+
title="Issued by"
|
|
7
|
+
:value="issuerName" />
|
|
8
|
+
<dynamic-image
|
|
9
|
+
:src="credentialImage"
|
|
10
|
+
size="lg" />
|
|
11
|
+
<credential-field
|
|
12
|
+
class="col text-center"
|
|
13
|
+
:title="credentialName"
|
|
14
|
+
title-class="text-subtitle1"
|
|
15
|
+
:value="credentialDescription"
|
|
16
|
+
value-class="text-body2 text-grey-7" />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
/*!
|
|
23
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
24
|
+
*/
|
|
25
|
+
import {defineProps, toRef} from 'vue';
|
|
26
|
+
import CredentialField from './CredentialField.vue';
|
|
27
|
+
import DynamicImage from './DynamicImage.vue';
|
|
28
|
+
import {useCredentialCommon} from './credentialCommon.js';
|
|
29
|
+
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
credential: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: null
|
|
34
|
+
},
|
|
35
|
+
dense: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
credentialName, credentialImage,
|
|
43
|
+
issuerName, credentialDescription
|
|
44
|
+
} = useCredentialCommon({
|
|
45
|
+
credential: toRef(props, 'credential')
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="scss" scoped>
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="show">
|
|
3
|
+
<q-item class="col q-py-none">
|
|
4
|
+
<q-item-section>
|
|
5
|
+
<q-item-label
|
|
6
|
+
v-if="title"
|
|
7
|
+
class="cf-title"
|
|
8
|
+
:class="titleClass"
|
|
9
|
+
:lines="lines">
|
|
10
|
+
{{title}}
|
|
11
|
+
</q-item-label>
|
|
12
|
+
<q-item-label
|
|
13
|
+
class="cf-value"
|
|
14
|
+
:class="valueClass"
|
|
15
|
+
:lines="lines">
|
|
16
|
+
{{value}}
|
|
17
|
+
</q-item-label>
|
|
18
|
+
</q-item-section>
|
|
19
|
+
</q-item>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup>
|
|
24
|
+
/*!
|
|
25
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
26
|
+
*/
|
|
27
|
+
import {computed, defineProps} from 'vue';
|
|
28
|
+
|
|
29
|
+
const props = defineProps({
|
|
30
|
+
title: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ''
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
titleClass: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'text-caption text-center text-grey-7'
|
|
41
|
+
},
|
|
42
|
+
valueClass: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: 'text-body2 text-center'
|
|
45
|
+
},
|
|
46
|
+
lines: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: '2'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const show = computed(() => props.value.length > 0);
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<style lang="scss" scoped>
|
|
56
|
+
</style>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="selection"
|
|
4
|
+
v-bind="{...$props, ...$attrs}">
|
|
5
|
+
<template
|
|
6
|
+
v-for="(_, slot) in $slots"
|
|
7
|
+
#[slot]="scope">
|
|
8
|
+
<slot
|
|
9
|
+
:name="slot"
|
|
10
|
+
v-bind="scope || {}" />
|
|
11
|
+
</template>
|
|
12
|
+
</component>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
/*!
|
|
17
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
18
|
+
*/
|
|
19
|
+
import {computed, defineProps, unref} from 'vue';
|
|
20
|
+
import {config, extend} from '@bedrock/web';
|
|
21
|
+
import CredentialBase from './CredentialBase.vue';
|
|
22
|
+
import CredentialDetail from './CredentialDetail.vue';
|
|
23
|
+
|
|
24
|
+
const componentDefaults = {
|
|
25
|
+
list: CredentialBase,
|
|
26
|
+
details: CredentialDetail
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const props = defineProps({
|
|
30
|
+
mode: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: 'list'
|
|
33
|
+
},
|
|
34
|
+
credential: {
|
|
35
|
+
type: Object,
|
|
36
|
+
required: true
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const selection = computed(() => {
|
|
41
|
+
const {credentialDisplay: {registration: registrations}} = config;
|
|
42
|
+
const map = new Map();
|
|
43
|
+
for(const registration of registrations) {
|
|
44
|
+
const {acceptableTypes, components} = registration;
|
|
45
|
+
// loop through types so that map will consist of an object
|
|
46
|
+
// containing all registered types
|
|
47
|
+
for(const type of acceptableTypes) {
|
|
48
|
+
// if the type already exists in the map, merge it with the
|
|
49
|
+
// new information
|
|
50
|
+
const existing = map.get(type);
|
|
51
|
+
if(existing) {
|
|
52
|
+
const combined = extend({
|
|
53
|
+
target: {}, source: [existing, components], deep: true
|
|
54
|
+
});
|
|
55
|
+
map.set(type, combined);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
map.set(type, components);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const {mode, credential} = props;
|
|
62
|
+
const {type = ''} = unref(credential);
|
|
63
|
+
// work backwards to lookup type in mapping
|
|
64
|
+
// use defaults if not found in mapping
|
|
65
|
+
let options;
|
|
66
|
+
let index = type.length - 1;
|
|
67
|
+
while(!options) {
|
|
68
|
+
if(index === -1) {
|
|
69
|
+
return componentDefaults[mode];
|
|
70
|
+
}
|
|
71
|
+
const granularType = type[index];
|
|
72
|
+
options = map.get(granularType)?.[mode];
|
|
73
|
+
index--;
|
|
74
|
+
}
|
|
75
|
+
// TODO: Determine if there is a way to check which components are
|
|
76
|
+
// globally registered. This would allow for the component
|
|
77
|
+
// selection to walk through the options and select the first
|
|
78
|
+
// available component for the type.
|
|
79
|
+
const {component} = options[0];
|
|
80
|
+
return component;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="scss" scoped>
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="row justify-center"
|
|
4
|
+
:class="credentialImageClass">
|
|
5
|
+
<q-icon
|
|
6
|
+
v-if="showDefault || hasImageError"
|
|
7
|
+
:name="defaultImage" />
|
|
8
|
+
<img
|
|
9
|
+
v-else
|
|
10
|
+
:src="src"
|
|
11
|
+
@error="imageError">
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
/*!
|
|
17
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
18
|
+
*/
|
|
19
|
+
import {computed, defineProps, ref} from 'vue';
|
|
20
|
+
import {useQuasar} from 'quasar';
|
|
21
|
+
|
|
22
|
+
const DEFAULT_ICONS = {
|
|
23
|
+
fontawesome: {
|
|
24
|
+
defaultImage: 'fas fa-check-square'
|
|
25
|
+
},
|
|
26
|
+
'material-icons': {
|
|
27
|
+
defaultImage: 'check_box'
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const $q = useQuasar();
|
|
31
|
+
|
|
32
|
+
// set default icons
|
|
33
|
+
const defaultIcons = DEFAULT_ICONS[$q.iconSet.name] ||
|
|
34
|
+
DEFAULT_ICONS.fontawesome;
|
|
35
|
+
// if the iconSet is missing credentialCard add it
|
|
36
|
+
if(!$q.iconSet.credentialCard) {
|
|
37
|
+
$q.iconSet.credentialCard = {};
|
|
38
|
+
}
|
|
39
|
+
// add all the defaultIcons to credentialCard
|
|
40
|
+
for(const name in defaultIcons) {
|
|
41
|
+
if(!$q.iconSet.credentialCard[name]) {
|
|
42
|
+
$q.iconSet.credentialCard[name] = defaultIcons[name];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const hasImageError = ref(false);
|
|
47
|
+
const props = defineProps({
|
|
48
|
+
src: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: true,
|
|
51
|
+
default: ''
|
|
52
|
+
},
|
|
53
|
+
size: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: true,
|
|
56
|
+
default: 'md'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const showDefault = computed(() => !props.src);
|
|
61
|
+
const defaultImage = computed(() => $q.iconSet.credentialCard.defaultImage);
|
|
62
|
+
const credentialImageClass = computed(
|
|
63
|
+
() => [`credential-card-image-${props.size}`]);
|
|
64
|
+
|
|
65
|
+
function imageError() {
|
|
66
|
+
hasImageError.value = true;
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<style lang="scss" scoped>
|
|
71
|
+
$xs: 25px;
|
|
72
|
+
$sm: 50px;
|
|
73
|
+
$md: 75px;
|
|
74
|
+
$lg: 125px;
|
|
75
|
+
$xl: 150px;
|
|
76
|
+
|
|
77
|
+
.credential-card-image-xs {
|
|
78
|
+
svg {
|
|
79
|
+
width: $xs;
|
|
80
|
+
height: $xs;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.q-icon {
|
|
84
|
+
font-size: $xs;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
img {
|
|
88
|
+
width: $xs;
|
|
89
|
+
height: $xs;
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
.credential-card-image-sm {
|
|
94
|
+
svg {
|
|
95
|
+
width: $sm;
|
|
96
|
+
height: $sm;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.q-icon {
|
|
100
|
+
font-size: $sm;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
img {
|
|
104
|
+
width: $sm;
|
|
105
|
+
height: $sm;
|
|
106
|
+
border-radius: 4px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
.credential-card-image-md {
|
|
110
|
+
svg {
|
|
111
|
+
width: $md;
|
|
112
|
+
height: $md;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.q-icon {
|
|
116
|
+
font-size: $md;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
img {
|
|
120
|
+
width: $md;
|
|
121
|
+
height: $md;
|
|
122
|
+
border-radius: 4px;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
.credential-card-image-lg {
|
|
126
|
+
svg {
|
|
127
|
+
width: $lg;
|
|
128
|
+
height: $lg;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.q-icon {
|
|
132
|
+
font-size: $lg;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
img {
|
|
136
|
+
width: $lg;
|
|
137
|
+
height: $lg;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
.credential-card-image-xl {
|
|
142
|
+
svg {
|
|
143
|
+
width: $xl;
|
|
144
|
+
height: $xl;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.q-icon {
|
|
148
|
+
font-size: $xl;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
img {
|
|
152
|
+
width: $xl;
|
|
153
|
+
height: $xl;
|
|
154
|
+
border-radius: 4px;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import {computed, unref} from 'vue';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Common utilities for credential components.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} options - The options to use.
|
|
10
|
+
* @param {*} options.credential - A vue ref to the credential.
|
|
11
|
+
* @returns {object} An object containing common credential utilities.
|
|
12
|
+
*/
|
|
13
|
+
export function useCredentialCommon({credential}) {
|
|
14
|
+
const credentialName = computed(() => {
|
|
15
|
+
const {name = '', type = ['Verifiable Credential']} = unref(credential);
|
|
16
|
+
if(name.length > 0) {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
const granularType = type[type.length - 1];
|
|
20
|
+
// Replace any uppercase letter `[A-Z]` or any sequence of digits `\d+`
|
|
21
|
+
// with a space plus what was just matched ` $1`. Skip the first
|
|
22
|
+
// letter so that no space will be added at the beginning of the
|
|
23
|
+
// resulting string by adding a negative lookahead on the start of the
|
|
24
|
+
// string (?!^). 'SomeTestCredential300' -> 'Some Test Credential 300'
|
|
25
|
+
return granularType.replace(/(?!^)([A-Z]|\d+)/g, ' $1');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const credentialImage = computed(() => {
|
|
29
|
+
const {image = null, issuer} = unref(credential);
|
|
30
|
+
return image ?? issuer?.image ?? issuer?.logo ?? '';
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const issuerName = computed(() => {
|
|
34
|
+
const {issuer} = unref(credential);
|
|
35
|
+
return issuer?.name ?? '';
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const credentialDescription = computed(() => {
|
|
39
|
+
const {description = ''} = unref(credential);
|
|
40
|
+
return description;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
credentialName,
|
|
45
|
+
credentialImage,
|
|
46
|
+
credentialDescription,
|
|
47
|
+
issuerName
|
|
48
|
+
};
|
|
49
|
+
}
|
package/lib/config.js
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './config.js';
|
|
5
|
+
|
|
6
|
+
export {default as CredentialBase} from '../components/CredentialBase.vue';
|
|
7
|
+
export {default as CredentialField} from '../components/CredentialField.vue';
|
|
8
|
+
export {default as CredentialSwitch} from '../components/CredentialSwitch.vue';
|
|
9
|
+
export {default as DynamicImage} from '../components/DynamicImage.vue';
|
|
10
|
+
export {useCredentialCommon} from '../components/credentialCommon.js';
|
|
11
|
+
|
|
12
|
+
export const registerComponent = async ({app, component, name = ''}) => {
|
|
13
|
+
app.component(name, component);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const registerComponents = async ({app, components}) => {
|
|
17
|
+
for(const component of components) {
|
|
18
|
+
await registerComponent({
|
|
19
|
+
app, component: component.value,
|
|
20
|
+
name: component.name
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bedrock/vue-vc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vue.js credential components for Bedrock Web Apps",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint --ext .cjs,.js,.vue ."
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"lib/**/*.js",
|
|
12
|
+
"components/**/*.js",
|
|
13
|
+
"components/**/*.vue"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/digitalbazaar/bedrock-vue-vc"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"bedrock"
|
|
21
|
+
],
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Digital Bazaar, Inc.",
|
|
24
|
+
"email": "support@digitalbazaar.com",
|
|
25
|
+
"url": "https://digitalbazaar.com"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/digitalbazaar/bedrock-vue-vc/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/digitalbazaar/bedrock-vue-vc",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@bedrock/quasar": "^8.0.1",
|
|
33
|
+
"@bedrock/web": "^2.0.1",
|
|
34
|
+
"vue": "^3.2.37"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"eslint": "^8.20.0",
|
|
38
|
+
"eslint-config-digitalbazaar": "^4.1.0",
|
|
39
|
+
"eslint-plugin-jsdoc": "^39.3.3",
|
|
40
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
41
|
+
"eslint-plugin-vue": "^9.2.0",
|
|
42
|
+
"jsdoc": "^3.6.11",
|
|
43
|
+
"jsdoc-to-markdown": "^7.1.1"
|
|
44
|
+
}
|
|
45
|
+
}
|