svelte-common
v6.19.45
Published
common components and utils used in svelte apps
Maintainers
Readme
svelte-common common components utils used in svelte apps# usageCheck out the code in the example folder,
or the live example.
API### Table of Contents* AttributeDefinition
* [Properties](#properties)- tokens
- setAttribute
- getAttribute
- getAttributeAndOperator
- filter
- Pagination
- initializeServiceWorker
- toggleOrderBy
- sortable
- sorter
- keyPrefixStore
- Parameters## AttributeDefinitionType: Object### Properties*
typestring
- Parameters## AttributeDefinitionType: Object### Properties*
writablebooleanprivateboolean? should the value be showndependsstring? name of an attribute we depend onadditionalAttributesArray<string> extra attributes that are present in case our attribute is setdescriptionstringdefaultany? the default valuesetFunction? set the valuegetFunction? get the value can be used to calculate default valuesenv(Array<string> | string)? environment variable use to provide the value## tokensSplit property path into tokens### Parameters*stringstring ## setAttributeSet Object attribute. The name may be a property path like 'a.b.c'.### Parameters*objectObjectnamestringvalueany ## getAttributeDeliver attribute value. The name may be a property path like 'a.b.c'.### Parameters*objectObjectnamestring Returns any value associated with the given property name## getAttributeAndOperatorDeliver attribute value and operator. The name may be a property path like 'a.b.c <='.### Parameters*objectObjectexpressionstringgetters(optional, default{})Returns [any, string] value associated with the given property name## filterGenerate filter function.### Parameters*filterByObject?gettersObject? Returns Function ## PaginationPagination support store. Pages go from 1 ... numberOfPages### Parameters*dataitemsPerPage(optional, default20)### pageSet current page#### Parameters*nnumber ### pageReturns number current page### itemsMeta* deprecated: This is deprecated.### pageNavigationElement* See: @link https://getbootstrap.com/docs/4.0/components/pagination- See: @link https://a11y-style-guide.com/style-guide/section-navigation.html#kssref-navigation-pagination## initializeServiceWorkerCreate a store holding a service worker### Parameters*
scriptstring The URL of the service worker script optionsObject An object containing registration optionsReturns Object store holding the service worker## toggleOrderByDeliver next value in the order by cycle. SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...### Parameters*orderBystring Returns string new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING## sortableAdd sortable toggle button to a th node. Synchronizes store value with the nodes "aria-sort" attribute.### Parameters*thElement the header nodestoreWritableStore keep in sync with sorting properties## sorterGenerate a sort function for a given sort-by set.### Parameters*sortBy(Object | undefined)?gettersObject? Returns (Function | undefined) sorter## keyPrefixStoreCreate a derived store where all the object keys are prefixed. { a: 1, b: 2 } -> { foo_a: 1 foo_b: 2 } // prefix: foo_### Parameters*storeWriteableStore we derive fromprefixstring for each keyReturns WriteableStore # installWith npm do:shell npm install svelte-commonor with yarn```shell yarn add svelte-common
