-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from lifeart/ember-modal-dialog-setup
ember-modal-dialog
- Loading branch information
Showing
14 changed files
with
317 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export { | ||
className, | ||
attribute, | ||
classNames, | ||
classNameBindings, | ||
attributeBindings, | ||
tagName, | ||
} from '@ember-decorators/component'; | ||
|
||
// noop | ||
export const layout = () => (target) => { | ||
return target; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
export function dropImportSync(addons: string[]) { | ||
return function dropImportSyncPlugin(babel) { | ||
const { types: t } = babel; | ||
let cnt = 0; | ||
function keyValue() { | ||
return `_$key${cnt++}`; | ||
} | ||
const shouldContinue = (state) => { | ||
const fName = state.file.opts.filename; | ||
return ( | ||
fName.includes('node_modules') && | ||
addons.some((el) => fName.includes(`/${el}/`)) | ||
); | ||
}; | ||
|
||
return { | ||
name: 'drop-import-sync', // not required | ||
visitor: { | ||
Program: { | ||
exit(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if (state.importsToAppend) { | ||
state.importsToAppend.forEach((el) => { | ||
path.node.body.unshift(el); | ||
}); | ||
path.node.body.push( | ||
t.functionDeclaration( | ||
t.identifier('_$importSync'), | ||
[t.identifier('_$a')], | ||
t.blockStatement([t.returnStatement(t.identifier('_$a'))]) | ||
) | ||
); | ||
} | ||
}, | ||
}, | ||
ImportDeclaration(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if (path.node.source.value === '@embroider/macros') { | ||
path.node.specifiers = path.node.specifiers.filter((el) => { | ||
return el.imported.name !== 'importSync'; | ||
}); | ||
if (path.node.specifiers.length === 0) { | ||
path.remove(); | ||
} | ||
} | ||
}, | ||
CallExpression(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if (path.node.callee && path.node.callee.name === 'importSync') { | ||
path.node.callee.name = '_$importSync'; | ||
state.importsToAppend = state.importsToAppend || []; | ||
const literalName = keyValue(); | ||
state.importsToAppend.push( | ||
t.importDeclaration( | ||
[t.importNamespaceSpecifier(t.identifier(literalName))], | ||
t.stringLiteral(path.node.arguments[0].value) | ||
) | ||
); | ||
path.node.arguments[0] = t.identifier(literalName); | ||
} | ||
}, | ||
}, | ||
}; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
export function removeLegacyLayout(addons: string[]) { | ||
return function removeLegacyLayoutPlugin (babel) { | ||
const shouldContinue = (state) => { | ||
const fName = state.file.opts.filename; | ||
return ( | ||
fName.includes('node_modules') && | ||
addons.some((el) => fName.includes(`/${el}/`)) | ||
); | ||
}; | ||
const { types: t } = babel; | ||
return { | ||
name: 'remove-layout', | ||
visitor: { | ||
Program: { | ||
exit(path, state) { | ||
if (state.shouldAppendLayout) { | ||
path.node.body.push( | ||
t.variableDeclaration('var', [ | ||
t.variableDeclarator( | ||
t.identifier('layout'), | ||
t.stringLiteral('') | ||
), | ||
]) | ||
); | ||
} | ||
}, | ||
}, | ||
ImportDeclaration(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if (path.node.source.value.endsWith('/config/environment')) { | ||
path.node.source.value = '@/config/env'; | ||
} | ||
if (path.node.source.value === '@ember-decorators/component') { | ||
// path.node.specifiers = path.node.specifiers.filter((el) => { | ||
// return el.imported.name !== 'layout'; | ||
// }); | ||
// if (!path.node.specifiers.length) { | ||
// path.remove(); | ||
// } | ||
path.node.source.value = 'compat-ember-decorators/component'; | ||
} else if (path.node.source.value.includes('/templates/')) { | ||
path.remove(); | ||
// add `layout` variable to programm | ||
state.shouldAppendLayout = true; | ||
} | ||
}, | ||
ObjectProperty(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if ( | ||
path.node.value.name === 'layout' && | ||
path.node.key.name === 'layout' | ||
) { | ||
path.remove(); | ||
} | ||
}, | ||
ClassProperty(path, state) { | ||
if (!shouldContinue(state)) { | ||
return; | ||
} | ||
if ( | ||
path.node.value && | ||
path.node.value.name === 'layout' && | ||
path.node.key && | ||
path.node.key.name === 'layout' | ||
) { | ||
path.remove(); | ||
} | ||
}, | ||
// Decorator(path, state) { | ||
// if (!shouldContinue(state)) { | ||
// return; | ||
// } | ||
// if (path.node.expression && path.node.expression.callee) { | ||
// if ( | ||
// path.node.expression.callee.name === 'templateLayout' || | ||
// path.node.expression.callee.name === 'layout' | ||
// ) { | ||
// path.remove(); | ||
// } else { | ||
// console.log(path.node.expression.callee.name); | ||
// } | ||
// } | ||
// }, | ||
}, | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { setComponentTemplate } from '@glimmer/manager'; | ||
import ModalDialogComponent from 'ember-modal-dialog/components/modal-dialog.js'; | ||
import ModalDialogTemplate from 'ember-modal-dialog/templates/components/modal-dialog.hbs'; | ||
import ModalDialogService from 'ember-modal-dialog/app/services/modal-dialog.js'; | ||
|
||
import ModalDialogBasicDialogComponent from 'ember-modal-dialog/components/basic-dialog.js'; | ||
import ModalDialogBasicDialogTemplate from 'ember-modal-dialog/templates/components/basic-dialog.hbs'; | ||
|
||
import EmberWormholeComponent from 'ember-wormhole/addon/components/ember-wormhole.js'; | ||
import EmberWormholeTemplate from 'ember-wormhole/addon/templates/components/ember-wormhole.hbs'; | ||
|
||
import IgnoreChildren from 'ember-modal-dialog/helpers/ignore-children.js'; | ||
|
||
import PositionedContainerComponent from 'ember-modal-dialog/components/positioned-container.js'; | ||
|
||
import 'ember-modal-dialog/app/styles/ember-modal-dialog/ember-modal-appearance.css'; | ||
import 'ember-modal-dialog/app/styles/ember-modal-dialog/ember-modal-structure.css'; | ||
|
||
setComponentTemplate( | ||
ModalDialogBasicDialogTemplate, | ||
ModalDialogBasicDialogComponent | ||
); | ||
|
||
const registry = { | ||
'component:modal-dialog': setComponentTemplate( | ||
ModalDialogTemplate, | ||
ModalDialogComponent | ||
), | ||
'component:ember-wormhole': setComponentTemplate( | ||
EmberWormholeTemplate, | ||
EmberWormholeComponent | ||
), | ||
'component:ember-modal-dialog-positioned-container': | ||
PositionedContainerComponent, | ||
'service:modal-dialog': ModalDialogService, | ||
'helper:ignore-children': IgnoreChildren, | ||
}; | ||
|
||
export default registry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import initialize from 'ember-modal-dialog/instance-initializers/add-modals-container.js'; | ||
import type ApplicationInstance from '@ember/application/instance'; | ||
|
||
export default { | ||
name: 'add-modals-container', | ||
initialize: function (application: ApplicationInstance) { | ||
console.log('instance initializer init'); | ||
initialize(application); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.