Usage
Signature:
interface CCardViewElement<K extends string | number,D>
Typescript Import Format
//To typecheck the element APIs, import as below.
import { CCardViewElement } from "oj-c/card-view";
//For the transpiled javascript to load the element's module, import as below
import "oj-c/card-view";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
itemTemplate
-
The
itemTemplateslot is used to specify the template for rendering each item in the CardView. The slot content must be a <template> element.When the template is executed for each item, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current item.
Properties of $current:
Name Type Argument Description dataD The data of the item. Note this is made available primarily to ease migration. Applications should get the data from the item property instead. isTabbableboolean <optional>
A boolean indicating whether the item is in tabbable mode or not. Template elements should not be tab-stops when the item is not in tabbable mode, this context can be used to implement conditional behavior for all tabbable child elements. itemItem.<K, D> Contains the data and metadata of the item. -
noData
-
The
noDataslot is used to specify the content to display when the CardView is empty. The slot content must be a <template> element. If not specified then a default no data message will be displayed. -
skeletonTemplate
-
The
skeletonTemplateslot is used to specify the template for rendering each skeleton while waiting for data during initial load as well as load more on scroll. The slot content must be a <template> element. If not specified then the default skeleton will display.When the template is executed for each skeleton, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current skeleton.
Properties of $current:
Name Type Argument Description loadingStatus 'initial' | 'loadMore' Whether the skeletons are rendered for initial load of data or for load more data in CardView height Size optional when the loadingStatus is ‘loadMore’ this will be the height of the actual card size, when loadingStatus is 'initial' this vale is undefined. width Size optional when the loadingStatus is ‘loadMore’ this will be the width of the actual card size, when loadingStatus is 'initial' this vale is undefined. Example of skeletonTemplate slot usage.
<oj-c-card-view id="cardview" class="demo-card-view" aria-label="cardview with custom skeleton" data=[[dataProvider]]> <template slot="skeletonTemplate" data-oj-as="context"> <div class="oj-panel oj-sm-padding-0 :style="[[context.loadingStatus === 'initial' ? { width: '300px', height: '240px' } : { width: context.width, height: context.height } ]]"> <oj-c-skeleton height ="100%"> </oj-c-skeleton> </div> </template> <template data-oj-as="item" slot="itemTemplate"> <div class="oj-panel"> <demo-profile-card-layout name="[[item.data.name]]" initials="[[item.data.initials]]" > </demo-profile-card-layout> </div> </template> </oj-c-card-view>
Attributes
-
columns :"auto"
-
Specifies the exact number of columns to render. By default, CardView will determine the number of columns based on width of the CardView and the width of the cards.
- Default Value:
auto
Supported Values:
Value Description autoCardView will determine the number of columns based on width of the CardView and the width of the cards Names
Item Name Property columnsProperty change event columnsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-columns-changed -
(readonly) current-item :K
-
The item that currently has keyboard focus
- Supports writeback:
true
Names
Item Name Property currentItemProperty change event currentItemChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-current-item-changed -
data :(DataProvider.<K, D>|null)
-
The data source for CardView. Must be of type DataProvider.
- Default Value:
null
Names
Item Name Property dataProperty change event dataChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-data-changed -
focus-behavior :"content"|"card"
-
Specifies which focus behavior CardView should use for an item that has single focusable element during keyboard navigation. When the focusBehavior is 'card', the focus will be on the root of CardView and it will do logical focus on the card. When the focusBehavior is 'content', the first focusable element within the card will get focus. Note that when set to 'content', there should only be one focusable element within the card. If that's not the case, a warning will be logged and the focus behavior will be reset to 'card'.
- Default Value:
"card"
Names
Item Name Property focusBehaviorProperty change event focusBehaviorChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-focus-behavior-changed -
gutter-size :"xs"|"sm"|"md"|"lg"|"xl"
-
Specifies size of the gutter between columns and rows. Possible values are: 'xs', 'sm', 'md', 'lg' and 'xl'. The default value is 'sm'.
- Default Value:
"sm"
Names
Item Name Property gutterSizeProperty change event gutterSizeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-gutter-size-changed -
initial-animation :"slideUp"|"slideDown"
-
Specify animation when cards are initially rendered. Possible values are: 'slideUp' and 'slideDown
- Default Value:
"slideUp"
Names
Item Name Property initialAnimationProperty change event initialAnimationChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-initial-animation-changed -
reorderable :{ items?: 'enabled' | 'disabled' }
-
The reorder option contains a subset of options for reordering items.
The following options are supported:
- items: Enable or disable reordering the items within the same CardView using drag and drop or keyboard. Specify 'enabled' to enable reordering. Setting the value to
"disabled"or setting the"reorderable"property tonull(or omitting it), disables reordering support.
Names
Item Name Property reorderableProperty change event reorderableChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-reorderable-changed - items: Enable or disable reordering the items within the same CardView using drag and drop or keyboard. Specify 'enabled' to enable reordering. Setting the value to
-
reorderable.items :"disabled"|"enabled"
-
- Default Value:
"disabled"
Names
Item Name Property reorderable.items -
scroll-policy-options :{ fetchSize?: number; scroller?: string }
-
scrollPolicy options.
The following options are supported:
- fetchSize: The number of items fetched each time when scroll to the end.
- scroller: The css selector that locates the element in which CardView uses to determine the scroll position as well as the maximum scroll position where scroll to the end will trigger a fetch. If not specified then the oj-c-card-view element is used.
Names
Item Name Property scrollPolicyOptionsProperty change event scrollPolicyOptionsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-scroll-policy-options-changed -
scroll-policy-options.fetch-size :number
-
- Default Value:
25
Names
Item Name Property scrollPolicyOptions.fetchSize -
scroll-policy-options.scroller :string
-
Names
Item Name Property scrollPolicyOptions.scroller -
selected :ImmutableKeySet.<K>
-
The current selected items in the CardView. An empty KeySet indicates nothing is selected. In addition, AllKeySetImpl set can be used to represent select all state.
- Supports writeback:
true
Names
Item Name Property selectedProperty change event selectedChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-selected-changed -
selection-mode :"multiple"|"none"|"single"|"singleRequired"
-
The type of selection behavior that is enabled on the CardView. This attribute controls the number of selections that can be made via selection gestures at any given time.
If
singleormultipleis specified, selection gestures will be enabled, and the CardView's selection styling will be applied to all items specified by the selected attribute. IfsingleRequiredis specified, then the behavior is the same as single except that CardView will ensure there is an item selected at all times. Specifically, the user will not be able to de-selected a selected item. And if selection is initially empty, CardView will select the first item. Ifnoneis specified, selection gestures will be disabled, and the CardView's selection styling will not be applied to any items specified by the selected attribute.Changing the value of this attribute will not affect the value of the selected attribute.
- Default Value:
"none"
Supported Values:
Value Description multipleMultiple items can be selected at the same time. noneSelection is disabled. singleOnly a single item can be selected at a time. singleRequiredOnly a single item can be selected at a time. In addition, CardView will also ensure that an item is selected at all time. Names
Item Name Property selectionModeProperty change event selectionModeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-selection-mode-changed
Events
-
ojReorder
-
Triggered after items are reordered within CardView via drag and drop or keyboard.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description itemKeysArray<K> An array of keys of the items that are moved referenceKeyK | null The key of the item where the moved items will be dropped after. If the moved items were dropped at the very beginning, the referenceKey will be null. reorderedKeysArray<K> An array of keys matching the new order of items
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description propertyThe property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesAn object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description propertyThe property name to set. Supports dot notation for subproperty access. valueThe new value to set the property to. Returns:
- Type
- void