@cardstack/core-types
v0.14.38-patch.0
Published
The default blueprint for ember-cli addons.
Downloads
985
Readme
@cardstack/core-types
The core-types package describes the field types available to Cardstack models. Example usage is:
factory.addResource('fields', 'my-field').withAttributes({
fieldType: '@cardstack/core-types::<field-type>',
...
})
where <field-type>
is one of:
string
(ex."sandwich", "Dave"
)string-array
(ex.["red", "green", "blue"]
)case-insensitive
case insensitive string, used for email addresses, among other things (ex."[email protected]"
)integer
(ex.37
)boolean
(ex.true
)date
(ex."2018-07-22"
)object
(ex.{ flower: 'rose' }
)any
any data type, useful for external data sourcesbelongs-to
belongs to relationship to another content-type (ex."author"
)has-many
has many relationship to another content-type (ex."pets"
)
Field Editors
When using the Cardstack Tools for editing, it will use the appropriate field editor for that type. For example, if your fieldType
is @cardstack/core-types::string
, the field-editors/string-editor
(which is essentially just a bound <input type="text">
) will be used. The core-types package contains several built-in field editors (string
, integer
, date
, etc), but you can specify your own custom field editor by specifying editorComponent
. This is particularly useful for relationship field types, for which there may not be a "standard" UI:
factory.addResource('fields', 'author').withAttributes({
fieldType: '@cardstack/core-types::belongs-to',
editorComponent: 'field-editors/author-picker'
})
Additionally, you can pass options to field editors using editorOptions
:
factory.addResource('fields', 'is-admin-user').withAttributes({
fieldType: '@cardstack/core-types::boolean',
editorOptions: { style: 'switch' }
})
Installation
git clone <repository-url>
this repositorycd @cardstack/core-types
npm install
bower install
Running
ember serve
- Visit your app at http://localhost:4200.
Running Tests
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
Building
ember build
For more information on using ember-cli, visit https://ember-cli.com/.