Skip to content

Commit

Permalink
Merge branch 'hotfix/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Jan 10, 2022
2 parents ab3d447 + 2173a10 commit 06c0524
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 346 deletions.
494 changes: 179 additions & 315 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui-workspace",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"workspaces": [
"packages/*"
Expand All @@ -27,6 +27,7 @@
"eslint": "^7.32.0",
"eslint-plugin-jest": "^24.5.0",
"prettier": "^2.4.1",
"typescript": "^4.4.3"
"typescript": "^4.4.3",
"vue": "^2.6.14"
}
}
2 changes: 1 addition & 1 deletion packages/tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui-tests",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Accordion extends Base {
*/
static config = {
name: 'Accordion',
emits: ['open', 'close'],
options: {
autoclose: Boolean,
item: {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/Accordion/AccordionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class AccordionItem extends Base {
static config = {
name: 'AccordionItem',
refs: ['btn', 'content', 'container'],
emits: ['open', 'close'],
options: {
isOpen: Boolean,
styles: {
Expand Down
54 changes: 29 additions & 25 deletions packages/ui/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class Modal extends Base {
static config = {
name: 'Modal',
refs: ['close', 'container', 'content', 'modal', 'open', 'overlay'],
emits: ['open', 'close'],
options: {
move: String,
autofocus: { type: String, default: '[autofocus]' },
Expand Down Expand Up @@ -108,32 +109,37 @@ export default class Modal extends Base {

if (this.$options.move) {
const target = document.querySelector(this.$options.move) || document.body;
const refsBackup = this.$refs;

this.refModalPlaceholder = document.createComment('');
this.refModalParentBackup = this.$refs.modal.parentElement || this.$el;
this.refModalParentBackup.insertBefore(this.refModalPlaceholder, this.$refs.modal);
this.__refsBackup = this.$refs;
this.__refModalPlaceholder = document.createComment('');
this.__refModalParentBackup = this.$refs.modal.parentElement || this.$el;
this.__refModalParentBackup.insertBefore(this.__refModalPlaceholder, this.$refs.modal);

this.refModalUnbindGetRefFilter = this.$on(
'get:refs',
/**
* @param {ModalRefs} refs
*/
// @ts-ignore
(refs) => {
Object.entries(refsBackup).forEach(([key, ref]) => {
if (!refs[key]) {
refs[key] = ref;
}
});
}
);
target.appendChild(this.$refs.modal);
}

return this;
}

/**
* Add the moved refs to `this.$refs` when using the `move` options.
*
* @this {ModalInterface}
*/
get $refs() {
const $refs = super.$refs;

if (this.$options.move && this.__refsBackup) {
Object.entries(this.__refsBackup).forEach(([key, ref]) => {
if (!$refs[key]) {
$refs[key] = ref;
}
});
}

return $refs;
}

/**
* Unbind all events on destroy.
*
Expand All @@ -143,13 +149,11 @@ export default class Modal extends Base {
destroyed() {
this.close();

if (this.$options.move && this.refModalParentBackup) {
this.refModalParentBackup.insertBefore(this.$refs.modal, this.refModalPlaceholder);
this.refModalUnbindGetRefFilter();
this.refModalPlaceholder.remove();
delete this.refModalPlaceholder;
delete this.refModalParentBackup;
delete this.refModalUnbindGetRefFilter;
if (this.$options.move && this.__refModalParentBackup) {
this.__refModalParentBackup.insertBefore(this.$refs.modal, this.__refModalPlaceholder);
this.__refModalPlaceholder.remove();
delete this.__refModalPlaceholder;
delete this.__refModalParentBackup;
}

return this;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class Tabs extends Base {
static config = {
name: 'Tabs',
refs: ['btn[]', 'content[]'],
emits: ['enable', 'disable'],
options: {
styles: {
type: Object,
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studiometa/ui",
"version": "0.1.0",
"version": "0.1.1",
"description": "A set of opiniated, unstyled and accessible components",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -29,8 +29,8 @@
},
"homepage": "https://github.com/studiometa/ui#readme",
"dependencies": {
"@studiometa/js-toolkit": "^2.0.0-alpha.8",
"@studiometa/js-toolkit": "^2.0.0-beta.8",
"deepmerge": "^4.2.2",
"motion": "^10.2.1"
"motion": "^10.5.0"
}
}

0 comments on commit 06c0524

Please sign in to comment.