@dxtmisha/wiki 0.24.3 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/classes/WikiStorybook.ts +92 -1
- package/src/classes/WikiStorybookItem.ts +79 -5
- package/src/classes/WikiStorybookProp.ts +109 -0
- package/src/library.ts +1 -0
- package/src/media/descriptions/wikiDescriptions.ts +32 -0
- package/src/media/descriptions/wikiDescriptionsAccordion.ts +204 -0
- package/src/media/descriptions/wikiDescriptionsActionSheet.ts +264 -0
- package/src/media/descriptions/wikiDescriptionsActions.ts +189 -0
- package/src/media/descriptions/wikiDescriptionsAnchor.ts +78 -0
- package/src/media/descriptions/wikiDescriptionsArrow.ts +214 -0
- package/src/media/descriptions/wikiDescriptionsBadge.ts +43 -0
- package/src/media/descriptions/wikiDescriptionsBars.ts +33 -0
- package/src/media/descriptions/wikiDescriptionsBlock.ts +159 -0
- package/src/media/descriptions/wikiDescriptionsButton.ts +32 -1
- package/src/media/descriptions/wikiDescriptionsCell.ts +26 -1
- package/src/media/descriptions/wikiDescriptionsChip.ts +42 -0
- package/src/media/descriptions/wikiDescriptionsChipGroup.ts +199 -0
- package/src/media/descriptions/wikiDescriptionsDialog.ts +226 -0
- package/src/media/descriptions/wikiDescriptionsField.ts +57 -2
- package/src/media/descriptions/wikiDescriptionsFieldCounter.ts +32 -0
- package/src/media/descriptions/wikiDescriptionsFieldLabel.ts +22 -0
- package/src/media/descriptions/wikiDescriptionsFieldMessage.ts +25 -0
- package/src/media/descriptions/wikiDescriptionsIcon.ts +46 -8
- package/src/media/descriptions/wikiDescriptionsImage.ts +91 -7
- package/src/media/descriptions/wikiDescriptionsInput.ts +313 -0
- package/src/media/descriptions/wikiDescriptionsList.ts +31 -0
- package/src/media/descriptions/wikiDescriptionsListGroup.ts +57 -0
- package/src/media/descriptions/wikiDescriptionsListItem.ts +42 -0
- package/src/media/descriptions/wikiDescriptionsListMenu.ts +41 -0
- package/src/media/descriptions/wikiDescriptionsMask.ts +42 -0
- package/src/media/descriptions/wikiDescriptionsMenu.ts +179 -0
- package/src/media/descriptions/wikiDescriptionsModal.ts +200 -0
- package/src/media/descriptions/wikiDescriptionsMotionTransform.ts +59 -6
- package/src/media/descriptions/wikiDescriptionsPage.ts +155 -0
- package/src/media/descriptions/wikiDescriptionsProgress.ts +39 -0
- package/src/media/descriptions/wikiDescriptionsRipple.ts +42 -3
- package/src/media/descriptions/wikiDescriptionsScrollbar.ts +48 -0
- package/src/media/descriptions/wikiDescriptionsSection.ts +152 -0
- package/src/media/descriptions/wikiDescriptionsSelect.ts +253 -0
- package/src/media/descriptions/wikiDescriptionsSelectValue.ts +107 -0
- package/src/media/descriptions/wikiDescriptionsSkeleton.ts +42 -1
- package/src/media/descriptions/wikiDescriptionsTextareaAutosize.ts +80 -0
- package/src/media/descriptions/wikiDescriptionsTooltip.ts +136 -0
- package/src/media/descriptions/wikiDescriptionsWindow.ts +60 -0
- package/src/media/functional/en/conversions.mdx +67 -0
- package/src/media/functional/en/dataUtils.mdx +25 -0
- package/src/media/functional/en/datetimeRef.mdx +1 -1
- package/src/media/functional/en/eventRef.mdx +1 -1
- package/src/media/functional/en/executionUtils.mdx +58 -0
- package/src/media/functional/en/geoFlagRef.mdx +1 -1
- package/src/media/functional/en/geoIntlRef.mdx +1 -1
- package/src/media/functional/en/geoRef.mdx +2 -2
- package/src/media/functional/en/meta.mdx +1206 -0
- package/src/media/functional/en/metaManager.mdx +376 -0
- package/src/media/functional/en/metaOg.mdx +694 -0
- package/src/media/functional/en/metaTwitter.mdx +853 -0
- package/src/media/functional/en/reactive.mdx +40 -0
- package/src/media/functional/en/refTypes.mdx +1 -1
- package/src/media/functional/en/useApiRef.mdx +5 -5
- package/src/media/functional/en/useMeta.mdx +431 -0
- package/src/media/functional/en/validationUtils.mdx +11 -0
- package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.en.mdx +25 -0
- package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.ru.mdx +25 -0
- package/src/media/functional/functional-basic/functions/getCurrentDate/getCurrentDate.vi.mdx +25 -0
- package/src/media/functional/functional-basic/functions/isEnter/isEnter.en.mdx +30 -0
- package/src/media/functional/functional-basic/functions/isEnter/isEnter.ru.mdx +30 -0
- package/src/media/functional/functional-basic/functions/isEnter/isEnter.vi.mdx +30 -0
- package/src/media/functional/ru/conversions.mdx +67 -0
- package/src/media/functional/ru/dataUtils.mdx +25 -0
- package/src/media/functional/ru/datetimeRef.mdx +2 -2
- package/src/media/functional/ru/eventRef.mdx +1 -1
- package/src/media/functional/ru/executionUtils.mdx +58 -0
- package/src/media/functional/ru/geoFlagRef.mdx +1 -1
- package/src/media/functional/ru/geoIntl.mdx +2 -2
- package/src/media/functional/ru/geoIntlRef.mdx +1 -1
- package/src/media/functional/ru/geoRef.mdx +2 -2
- package/src/media/functional/ru/listTypes.mdx +1 -1
- package/src/media/functional/ru/meta.mdx +1330 -0
- package/src/media/functional/ru/metaManager.mdx +376 -0
- package/src/media/functional/ru/metaOg.mdx +694 -0
- package/src/media/functional/ru/metaTwitter.mdx +853 -0
- package/src/media/functional/ru/reactive.mdx +40 -0
- package/src/media/functional/ru/refTypes.mdx +2 -2
- package/src/media/functional/ru/useApiRef.mdx +5 -5
- package/src/media/functional/ru/useMeta.mdx +431 -0
- package/src/media/functional/ru/validationUtils.mdx +11 -0
- package/src/media/mdx/Accordion/accordion.en.mdx +59 -0
- package/src/media/mdx/Accordion/accordion.ru.mdx +59 -0
- package/src/media/mdx/Accordion/slots.en.mdx +6 -0
- package/src/media/mdx/Accordion/slots.ru.mdx +6 -0
- package/src/media/mdx/Accordion/wikiMdxAccordion.ts +25 -0
- package/src/media/mdx/ActionSheet/actionSheet.en.mdx +61 -0
- package/src/media/mdx/ActionSheet/actionSheet.ru.mdx +61 -0
- package/src/media/mdx/ActionSheet/touchClose.en.mdx +21 -0
- package/src/media/mdx/ActionSheet/touchClose.ru.mdx +21 -0
- package/src/media/mdx/ActionSheet/wikiMdxActionSheet.ts +25 -0
- package/src/media/mdx/Actions/actions.en.mdx +48 -0
- package/src/media/mdx/Actions/actions.ru.mdx +48 -0
- package/src/media/mdx/Actions/flexible.en.mdx +19 -0
- package/src/media/mdx/Actions/flexible.ru.mdx +19 -0
- package/src/media/mdx/Actions/list.en.mdx +50 -0
- package/src/media/mdx/Actions/list.ru.mdx +50 -0
- package/src/media/mdx/Actions/wikiMdxActions.ts +31 -0
- package/src/media/mdx/Anchor/anchor.en.mdx +34 -0
- package/src/media/mdx/Anchor/anchor.ru.mdx +34 -0
- package/src/media/mdx/Anchor/expose.go.en.mdx +6 -0
- package/src/media/mdx/Anchor/expose.go.ru.mdx +6 -0
- package/src/media/mdx/Anchor/hide.en.mdx +28 -0
- package/src/media/mdx/Anchor/hide.ru.mdx +28 -0
- package/src/media/mdx/Anchor/isCopy.en.mdx +23 -0
- package/src/media/mdx/Anchor/isCopy.ru.mdx +23 -0
- package/src/media/mdx/Anchor/scroll.en.mdx +34 -0
- package/src/media/mdx/Anchor/scroll.ru.mdx +35 -0
- package/src/media/mdx/Anchor/wikiMdxAnchor.ts +43 -0
- package/src/media/mdx/Arrow/arrow.en.mdx +33 -0
- package/src/media/mdx/Arrow/arrow.ru.mdx +33 -0
- package/src/media/mdx/Arrow/wikiMdxArrow.ts +19 -0
- package/src/media/mdx/Block/block.en.mdx +42 -0
- package/src/media/mdx/Block/block.ru.mdx +42 -0
- package/src/media/mdx/Block/wikiMdxBlock.ts +19 -0
- package/src/media/mdx/ChipGroup/chipGroup.en.mdx +51 -0
- package/src/media/mdx/ChipGroup/chipGroup.ru.mdx +51 -0
- package/src/media/mdx/ChipGroup/selected.en.mdx +50 -0
- package/src/media/mdx/ChipGroup/selected.ru.mdx +50 -0
- package/src/media/mdx/ChipGroup/wikiMdxChipGroup.ts +25 -0
- package/src/media/mdx/Dialog/buttons.en.mdx +45 -0
- package/src/media/mdx/Dialog/buttons.ru.mdx +45 -0
- package/src/media/mdx/Dialog/dialog.en.mdx +66 -0
- package/src/media/mdx/Dialog/dialog.ru.mdx +65 -0
- package/src/media/mdx/Dialog/events.en.mdx +63 -0
- package/src/media/mdx/Dialog/events.ru.mdx +63 -0
- package/src/media/mdx/Dialog/states.en.mdx +58 -0
- package/src/media/mdx/Dialog/states.ru.mdx +57 -0
- package/src/media/mdx/Dialog/wikiMdxDialog.ts +37 -0
- package/src/media/mdx/Field/arrows.en.mdx +22 -6
- package/src/media/mdx/Field/arrows.ru.mdx +22 -6
- package/src/media/mdx/Field/slots.en.mdx +0 -13
- package/src/media/mdx/Field/slots.ru.mdx +0 -13
- package/src/media/mdx/Image/flag.en.mdx +23 -0
- package/src/media/mdx/Image/flag.ru.mdx +23 -0
- package/src/media/mdx/Image/image.en.mdx +26 -21
- package/src/media/mdx/Image/image.ru.mdx +26 -22
- package/src/media/mdx/Image/img-tag.en.mdx +105 -0
- package/src/media/mdx/Image/img-tag.ru.mdx +105 -0
- package/src/media/mdx/Image/wikiMdxImage.ts +12 -0
- package/src/media/mdx/Input/currency.en.mdx +38 -0
- package/src/media/mdx/Input/currency.ru.mdx +38 -0
- package/src/media/mdx/Input/date.en.mdx +53 -0
- package/src/media/mdx/Input/date.ru.mdx +53 -0
- package/src/media/mdx/Input/input.en.mdx +143 -0
- package/src/media/mdx/Input/input.ru.mdx +71 -0
- package/src/media/mdx/Input/mask.en.mdx +30 -0
- package/src/media/mdx/Input/mask.ru.mdx +30 -0
- package/src/media/mdx/Input/number.en.mdx +41 -0
- package/src/media/mdx/Input/number.ru.mdx +41 -0
- package/src/media/mdx/Input/type.en.mdx +26 -0
- package/src/media/mdx/Input/type.ru.mdx +26 -0
- package/src/media/mdx/Input/wikiMdxInput.ts +49 -0
- package/src/media/mdx/Menu/event.updateValue.en.mdx +29 -0
- package/src/media/mdx/Menu/event.updateValue.ru.mdx +30 -0
- package/src/media/mdx/Menu/expose.navigation.en.mdx +12 -0
- package/src/media/mdx/Menu/expose.navigation.ru.mdx +12 -0
- package/src/media/mdx/Menu/navigation.en.mdx +56 -0
- package/src/media/mdx/Menu/navigation.ru.mdx +56 -0
- package/src/media/mdx/Menu/slots.control.en.mdx +65 -0
- package/src/media/mdx/Menu/slots.control.ru.mdx +65 -0
- package/src/media/mdx/Menu/slots.en.mdx +2 -24
- package/src/media/mdx/Menu/slots.ru.mdx +2 -24
- package/src/media/mdx/Menu/wikiMdxMenu.ts +27 -3
- package/src/media/mdx/Modal/differences.en.mdx +130 -0
- package/src/media/mdx/Modal/differences.ru.mdx +65 -0
- package/src/media/mdx/Modal/modal.en.mdx +63 -0
- package/src/media/mdx/Modal/modal.ru.mdx +63 -0
- package/src/media/mdx/Modal/wikiMdxModal.ts +25 -0
- package/src/media/mdx/MotionTransform/expose.motionTransformElement.en.mdx +13 -0
- package/src/media/mdx/MotionTransform/expose.motionTransformElement.ru.mdx +14 -0
- package/src/media/mdx/MotionTransform/wikiMdxMotionTransform.ts +6 -0
- package/src/media/mdx/Page/page.en.mdx +38 -0
- package/src/media/mdx/Page/page.ru.mdx +38 -0
- package/src/media/mdx/Page/wikiMdxPage.ts +19 -0
- package/src/media/mdx/Section/section.en.mdx +38 -0
- package/src/media/mdx/Section/section.ru.mdx +38 -0
- package/src/media/mdx/Section/wikiMdxSection.ts +19 -0
- package/src/media/mdx/Select/select.en.mdx +69 -0
- package/src/media/mdx/Select/select.ru.mdx +69 -0
- package/src/media/mdx/Select/wikiMdxSelect.ts +19 -0
- package/src/media/mdx/SelectValue/selectValue.en.mdx +64 -0
- package/src/media/mdx/SelectValue/selectValue.ru.mdx +64 -0
- package/src/media/mdx/SelectValue/wikiMdxSelectValue.ts +19 -0
- package/src/media/mdx/TextareaAutosize/textarea-autosize.en.mdx +65 -0
- package/src/media/mdx/TextareaAutosize/textarea-autosize.ru.mdx +65 -0
- package/src/media/mdx/TextareaAutosize/wikiMdxTextareaAutosize.ts +19 -0
- package/src/media/mdx/Tooltip/event.tooltip.en.mdx +7 -0
- package/src/media/mdx/Tooltip/event.tooltip.ru.mdx +8 -0
- package/src/media/mdx/Tooltip/slot.control.en.mdx +14 -0
- package/src/media/mdx/Tooltip/slot.control.ru.mdx +14 -0
- package/src/media/mdx/Tooltip/tooltip.en.mdx +34 -0
- package/src/media/mdx/Tooltip/tooltip.ru.mdx +34 -0
- package/src/media/mdx/Tooltip/wikiMdxTooltip.ts +31 -0
- package/src/media/mdx/Window/classes.ru.mdx +1 -1
- package/src/media/mdx/event/events.actions.en.mdx +44 -0
- package/src/media/mdx/event/events.actions.ru.mdx +44 -0
- package/src/media/mdx/event/events.inputStandard.en.mdx +6 -0
- package/src/media/mdx/event/events.inputStandard.ru.mdx +6 -0
- package/src/media/mdx/event/wikiMdxEvent.ts +20 -8
- package/src/media/mdx/expose/expose.clear.en.mdx +1 -1
- package/src/media/mdx/expose/expose.descriptionId.en.mdx +6 -0
- package/src/media/mdx/expose/expose.descriptionId.ru.mdx +6 -0
- package/src/media/mdx/expose/expose.id.en.mdx +6 -0
- package/src/media/mdx/expose/expose.id.ru.mdx +6 -0
- package/src/media/mdx/expose/expose.labelId.en.mdx +6 -0
- package/src/media/mdx/expose/expose.labelId.ru.mdx +6 -0
- package/src/media/mdx/expose/wikiMdxExpose.ts +18 -0
- package/src/media/mdx/slot/body.en.mdx +6 -0
- package/src/media/mdx/slot/body.ru.mdx +6 -0
- package/src/media/mdx/slot/headline.en.mdx +7 -0
- package/src/media/mdx/slot/headline.ru.mdx +6 -0
- package/src/media/mdx/slot/leading.en.mdx +7 -0
- package/src/media/mdx/slot/leading.ru.mdx +7 -0
- package/src/media/mdx/slot/secondary.en.mdx +5 -0
- package/src/media/mdx/slot/secondary.ru.mdx +5 -0
- package/src/media/mdx/slot/trailing.en.mdx +7 -0
- package/src/media/mdx/slot/trailing.ru.mdx +7 -0
- package/src/media/mdx/slot/wikiMdxSlot.ts +30 -0
- package/src/media/mdx/style/isSkeleton.en.mdx +2 -2
- package/src/media/mdx/style/isSkeleton.ru.mdx +2 -2
- package/src/media/mdx/value/v-model-selected.en.mdx +28 -0
- package/src/media/mdx/value/v-model-selected.ru.mdx +28 -0
- package/src/media/mdx/value/v-model.en.mdx +26 -0
- package/src/media/mdx/value/v-model.ru.mdx +26 -0
- package/src/media/mdx/value/wikiMdxValue.ts +24 -3
- package/src/media/mdx/wikiMdx.ts +33 -1
- package/src/media/props/wiki.ts +44 -0
- package/src/media/props/wikiActions.ts +43 -0
- package/src/media/props/wikiActionsInclude.ts +62 -0
- package/src/media/props/wikiAnchor.ts +85 -0
- package/src/media/props/wikiAria.ts +123 -0
- package/src/media/props/wikiArrow.ts +24 -0
- package/src/media/props/wikiArrowInclude.ts +45 -0
- package/src/media/props/wikiAttributes.ts +143 -0
- package/src/media/props/wikiBadge.ts +7 -4
- package/src/media/props/wikiBars.ts +7 -6
- package/src/media/props/wikiBarsInclude.ts +82 -0
- package/src/media/props/wikiButton.ts +8 -4
- package/src/media/props/wikiChip.ts +4 -2
- package/src/media/props/wikiChipGroup.ts +39 -0
- package/src/media/props/wikiDialog.ts +33 -0
- package/src/media/props/wikiField.ts +18 -31
- package/src/media/props/wikiFieldCounterInclude.ts +87 -0
- package/src/media/props/wikiForm.ts +267 -0
- package/src/media/props/wikiHook.ts +20 -0
- package/src/media/props/wikiIcon.ts +19 -6
- package/src/media/props/wikiIconInclude.ts +322 -0
- package/src/media/props/wikiImage.ts +97 -20
- package/src/media/props/wikiInformation.ts +164 -0
- package/src/media/props/wikiInput.ts +34 -0
- package/src/media/props/wikiList.ts +10 -4
- package/src/media/props/wikiListItem.ts +23 -2
- package/src/media/props/wikiMask.ts +2 -12
- package/src/media/props/wikiMaskInclude.ts +54 -0
- package/src/media/props/wikiMenu.ts +1 -11
- package/src/media/props/wikiMotionTransform.ts +7 -13
- package/src/media/props/wikiOption.ts +356 -0
- package/src/media/props/wikiProgress.ts +8 -5
- package/src/media/props/wikiScrollbar.ts +6 -6
- package/src/media/props/wikiSelect.ts +68 -0
- package/src/media/props/wikiSelectValue.ts +30 -0
- package/src/media/props/wikiStatus.ts +34 -57
- package/src/media/props/wikiStyle.ts +85 -406
- package/src/media/props/wikiTechnical.ts +141 -1
- package/src/media/props/wikiText.ts +167 -0
- package/src/media/props/wikiTooltip.ts +53 -0
- package/src/media/props/wikiValue.ts +22 -276
- package/src/media/props/wikiWindow.ts +24 -45
- package/src/shims-mdx.d.ts +5 -0
- package/src/styles/storybookStyle.scss +3 -1
- package/src/types/storybookTypes.ts +48 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/functional/en/Reactive'/>
|
|
4
|
+
|
|
5
|
+
# Reactive Utilities
|
|
6
|
+
|
|
7
|
+
A set of functions for working with Vue.js reactivity.
|
|
8
|
+
|
|
9
|
+
## `computedAsync`
|
|
10
|
+
|
|
11
|
+
Creates a Vue computed property that can handle asynchronous getters.
|
|
12
|
+
|
|
13
|
+
**Parameters:**
|
|
14
|
+
- `getter: (() => Promise<R>) | (() => R) | R` — asynchronous function, synchronous function, or direct value to compute the result
|
|
15
|
+
- `debugOptions?: DebuggerOptions` — debug options for reactive computations (supported by Vue.js library)
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { computedAsync } from '@dxtmisha/functional'
|
|
19
|
+
|
|
20
|
+
// With asynchronous function
|
|
21
|
+
const userData = computedAsync(async () => {
|
|
22
|
+
const response = await fetch('/api/user')
|
|
23
|
+
return response.json()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// With synchronous function
|
|
27
|
+
const doubled = computedAsync(() => value.value * 2)
|
|
28
|
+
|
|
29
|
+
// With direct value
|
|
30
|
+
const staticValue = computedAsync('Hello World')
|
|
31
|
+
|
|
32
|
+
// With debug options
|
|
33
|
+
const debugged = computedAsync(
|
|
34
|
+
async () => await fetchData(),
|
|
35
|
+
{
|
|
36
|
+
onTrack: (e) => console.log('tracked:', e),
|
|
37
|
+
onTrigger: (e) => console.log('triggered:', e)
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
```
|
|
@@ -35,7 +35,7 @@ const { data, loading, isStarting, reading } = useApiRef('/api/users')
|
|
|
35
35
|
|
|
36
36
|
### Component Usage
|
|
37
37
|
|
|
38
|
-
```
|
|
38
|
+
```html
|
|
39
39
|
<script setup>
|
|
40
40
|
import { useApiRef } from '@dxtmisha/functional'
|
|
41
41
|
|
|
@@ -248,7 +248,7 @@ await reset()
|
|
|
248
248
|
|
|
249
249
|
### List with Filters
|
|
250
250
|
|
|
251
|
-
```
|
|
251
|
+
```html
|
|
252
252
|
<script setup>
|
|
253
253
|
import { ref, computed } from 'vue'
|
|
254
254
|
import { useApiRef } from '@dxtmisha/functional'
|
|
@@ -289,7 +289,7 @@ const handleSearch = (query) => {
|
|
|
289
289
|
|
|
290
290
|
### Conditional Loading
|
|
291
291
|
|
|
292
|
-
```
|
|
292
|
+
```html
|
|
293
293
|
<script setup>
|
|
294
294
|
import { ref } from 'vue'
|
|
295
295
|
import { useApiRef } from '@dxtmisha/functional'
|
|
@@ -324,7 +324,7 @@ const toggleDetails = () => {
|
|
|
324
324
|
|
|
325
325
|
### POST Request with Transformation
|
|
326
326
|
|
|
327
|
-
```
|
|
327
|
+
```html
|
|
328
328
|
<script setup>
|
|
329
329
|
import { ref } from 'vue'
|
|
330
330
|
import { useApiRef } from '@dxtmisha/functional'
|
|
@@ -376,7 +376,7 @@ const handleSubmit = async () => {
|
|
|
376
376
|
|
|
377
377
|
### Multiple Requests
|
|
378
378
|
|
|
379
|
-
```
|
|
379
|
+
```html
|
|
380
380
|
<script setup>
|
|
381
381
|
import { useApiRef } from '@dxtmisha/functional'
|
|
382
382
|
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/functional/en/Composables/useMeta'/>
|
|
4
|
+
|
|
5
|
+
# Composable useMeta
|
|
6
|
+
|
|
7
|
+
Composable for managing page meta tags in Vue 3 applications. Provides reactive interface for working with SEO tags, Open Graph, and Twitter Card with automatic DOM synchronization. Uses singleton pattern — all components share the same meta tags state.
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **Reactive meta tag management** — automatic DOM updates when values change
|
|
12
|
+
- **Singleton pattern** — unified meta tags state for the entire application
|
|
13
|
+
- **SEO support** — manage title, description, keywords, canonical, robots, author
|
|
14
|
+
- **Open Graph** — full Open Graph protocol support for social networks
|
|
15
|
+
- **Twitter Card** — Twitter Card integration for optimal Twitter display
|
|
16
|
+
- **SSR support** — HTML string generation for server-side rendering
|
|
17
|
+
- **TypeScript support** — full typing of all properties and methods
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
### Simple Meta Tags Management
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
25
|
+
|
|
26
|
+
// Get reactive refs for managing meta tags
|
|
27
|
+
const { title, description, keyword } = useMeta()
|
|
28
|
+
|
|
29
|
+
// Set values
|
|
30
|
+
title.value = 'Home Page'
|
|
31
|
+
description.value = 'Homepage description of the website'
|
|
32
|
+
keyword.value = 'keywords, of, the, website'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Component Usage
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<script setup>
|
|
39
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
40
|
+
import { onMounted } from 'vue'
|
|
41
|
+
|
|
42
|
+
const { title, description, image, canonical } = useMeta()
|
|
43
|
+
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
title.value = 'About Us'
|
|
46
|
+
description.value = 'Learn more about our company'
|
|
47
|
+
image.value = 'https://example.com/about-image.jpg'
|
|
48
|
+
canonical.value = 'https://example.com/about'
|
|
49
|
+
})
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<div>
|
|
54
|
+
<h1>About Us</h1>
|
|
55
|
+
<p>Page content...</p>
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Return Values
|
|
61
|
+
|
|
62
|
+
### `meta`
|
|
63
|
+
|
|
64
|
+
Instance of Meta class for advanced operations.
|
|
65
|
+
|
|
66
|
+
**Type:** `Meta`
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
const { meta } = useMeta()
|
|
70
|
+
|
|
71
|
+
// Access to advanced methods
|
|
72
|
+
meta.setLocale('en_US')
|
|
73
|
+
meta.setSuffix('My Site')
|
|
74
|
+
|
|
75
|
+
// Get child classes for detailed configuration
|
|
76
|
+
const og = meta.getOg()
|
|
77
|
+
const twitter = meta.getTwitter()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `title`
|
|
81
|
+
|
|
82
|
+
Reactive page title (without suffix).
|
|
83
|
+
|
|
84
|
+
**Type:** `Ref<string>`
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
const { title } = useMeta()
|
|
88
|
+
|
|
89
|
+
title.value = 'New Title'
|
|
90
|
+
// Automatically updates:
|
|
91
|
+
// - document.title (with suffix if set)
|
|
92
|
+
// - Open Graph og:title
|
|
93
|
+
// - Twitter Card twitter:title
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### `keyword`
|
|
97
|
+
|
|
98
|
+
Reactive keywords meta tag.
|
|
99
|
+
|
|
100
|
+
**Type:** `Ref<string>`
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
const { keyword } = useMeta()
|
|
104
|
+
|
|
105
|
+
keyword.value = 'vue, composable, meta tags, seo'
|
|
106
|
+
// Updates <meta name="keywords" content="...">
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `description`
|
|
110
|
+
|
|
111
|
+
Reactive description meta tag.
|
|
112
|
+
|
|
113
|
+
**Type:** `Ref<string>`
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
const { description } = useMeta()
|
|
117
|
+
|
|
118
|
+
description.value = 'Complete page description for search engines'
|
|
119
|
+
// Updates <meta name="description" content="...">
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `image`
|
|
123
|
+
|
|
124
|
+
Reactive image URL for Open Graph and Twitter Card.
|
|
125
|
+
|
|
126
|
+
**Type:** `Ref<string>`
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
const { image } = useMeta()
|
|
130
|
+
|
|
131
|
+
image.value = 'https://example.com/preview.jpg'
|
|
132
|
+
// Automatically updates:
|
|
133
|
+
// - Open Graph og:image
|
|
134
|
+
// - Twitter Card twitter:image
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### `canonical`
|
|
138
|
+
|
|
139
|
+
Reactive canonical URL.
|
|
140
|
+
|
|
141
|
+
**Type:** `Ref<string>`
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
const { canonical } = useMeta()
|
|
145
|
+
|
|
146
|
+
canonical.value = 'https://example.com/page'
|
|
147
|
+
// Automatically updates:
|
|
148
|
+
// - <link rel="canonical" href="...">
|
|
149
|
+
// - Open Graph og:url
|
|
150
|
+
// - Twitter Card twitter:url
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `robots`
|
|
154
|
+
|
|
155
|
+
Reactive robots meta tag directive.
|
|
156
|
+
|
|
157
|
+
**Type:** `Ref<MetaRobots>`
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
const { robots } = useMeta()
|
|
161
|
+
|
|
162
|
+
robots.value = 'index, follow'
|
|
163
|
+
// Other options: 'noindex', 'nofollow', 'noindex, nofollow'
|
|
164
|
+
// Updates <meta name="robots" content="...">
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `author`
|
|
168
|
+
|
|
169
|
+
Reactive author meta tag.
|
|
170
|
+
|
|
171
|
+
**Type:** `Ref<string>`
|
|
172
|
+
|
|
173
|
+
```javascript
|
|
174
|
+
const { author } = useMeta()
|
|
175
|
+
|
|
176
|
+
author.value = 'John Doe'
|
|
177
|
+
// Updates <meta name="author" content="...">
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `siteName`
|
|
181
|
+
|
|
182
|
+
Reactive site name for Open Graph and Twitter Card.
|
|
183
|
+
|
|
184
|
+
**Type:** `Ref<string>`
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
const { siteName } = useMeta()
|
|
188
|
+
|
|
189
|
+
siteName.value = 'My Site'
|
|
190
|
+
// Automatically updates:
|
|
191
|
+
// - Open Graph og:site_name
|
|
192
|
+
// - Twitter Card twitter:site
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### `getHtmlMeta`
|
|
196
|
+
|
|
197
|
+
Function to generate HTML string with all meta tags (for SSR).
|
|
198
|
+
|
|
199
|
+
**Type:** `() => string`
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
const { getHtmlMeta } = useMeta()
|
|
203
|
+
|
|
204
|
+
// Generates HTML string with all meta tags
|
|
205
|
+
const metaHtml = getHtmlMeta()
|
|
206
|
+
// Returns: '<meta name="description" content="..."><meta property="og:title" content="...">...'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Usage Examples
|
|
210
|
+
|
|
211
|
+
### Dynamic Meta Tags Based on Data
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<script setup>
|
|
215
|
+
import { ref, watch } from 'vue'
|
|
216
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
217
|
+
import { useApiRef } from '@dxtmisha/functional'
|
|
218
|
+
|
|
219
|
+
const articleId = ref(1)
|
|
220
|
+
const { data: article } = useApiRef(
|
|
221
|
+
computed(() => `/api/articles/${articleId.value}`)
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
const { title, description, image, author, canonical } = useMeta()
|
|
225
|
+
|
|
226
|
+
watch(article, (newArticle) => {
|
|
227
|
+
if (newArticle) {
|
|
228
|
+
title.value = newArticle.title
|
|
229
|
+
description.value = newArticle.excerpt
|
|
230
|
+
image.value = newArticle.coverImage
|
|
231
|
+
author.value = newArticle.authorName
|
|
232
|
+
canonical.value = `https://example.com/articles/${newArticle.slug}`
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
</script>
|
|
236
|
+
|
|
237
|
+
<template>
|
|
238
|
+
<article v-if="article">
|
|
239
|
+
<h1>{{ article.title }}</h1>
|
|
240
|
+
<p>{{ article.content }}</p>
|
|
241
|
+
</article>
|
|
242
|
+
</template>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Configure Meta Tags for Different Pages
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<script setup>
|
|
249
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
250
|
+
import { useRoute } from 'vue-router'
|
|
251
|
+
import { watch } from 'vue'
|
|
252
|
+
|
|
253
|
+
const route = useRoute()
|
|
254
|
+
const { title, description, robots } = useMeta()
|
|
255
|
+
|
|
256
|
+
const pageMetadata = {
|
|
257
|
+
home: {
|
|
258
|
+
title: 'Home Page',
|
|
259
|
+
description: 'Welcome to our website',
|
|
260
|
+
robots: 'index, follow'
|
|
261
|
+
},
|
|
262
|
+
about: {
|
|
263
|
+
title: 'About Us',
|
|
264
|
+
description: 'Learn more about our company',
|
|
265
|
+
robots: 'index, follow'
|
|
266
|
+
},
|
|
267
|
+
admin: {
|
|
268
|
+
title: 'Admin Panel',
|
|
269
|
+
description: 'Administrator panel',
|
|
270
|
+
robots: 'noindex, nofollow'
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
watch(
|
|
275
|
+
() => route.name,
|
|
276
|
+
(routeName) => {
|
|
277
|
+
const meta = pageMetadata[routeName] || pageMetadata.home
|
|
278
|
+
title.value = meta.title
|
|
279
|
+
description.value = meta.description
|
|
280
|
+
robots.value = meta.robots
|
|
281
|
+
},
|
|
282
|
+
{ immediate: true }
|
|
283
|
+
)
|
|
284
|
+
</script>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Advanced Configuration with Open Graph and Twitter Card
|
|
288
|
+
|
|
289
|
+
```html
|
|
290
|
+
<script setup>
|
|
291
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
292
|
+
import { onMounted } from 'vue'
|
|
293
|
+
|
|
294
|
+
const { meta, title, description, image, siteName } = useMeta()
|
|
295
|
+
|
|
296
|
+
onMounted(() => {
|
|
297
|
+
// Basic meta tags
|
|
298
|
+
title.value = 'Article Title'
|
|
299
|
+
description.value = 'Brief article description'
|
|
300
|
+
image.value = 'https://example.com/article-image.jpg'
|
|
301
|
+
siteName.value = 'My Blog'
|
|
302
|
+
|
|
303
|
+
// Advanced settings
|
|
304
|
+
meta.setSuffix('My Blog')
|
|
305
|
+
meta.setLocale('en_US')
|
|
306
|
+
|
|
307
|
+
// Detailed Open Graph configuration
|
|
308
|
+
const og = meta.getOg()
|
|
309
|
+
og.setType('article')
|
|
310
|
+
|
|
311
|
+
// Detailed Twitter Card configuration
|
|
312
|
+
const twitter = meta.getTwitter()
|
|
313
|
+
twitter.setCard('summary_large_image')
|
|
314
|
+
})
|
|
315
|
+
</script>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### SSR: Generate Meta Tags on Server
|
|
319
|
+
|
|
320
|
+
```javascript
|
|
321
|
+
// server.js
|
|
322
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
323
|
+
|
|
324
|
+
export function renderMetaTags(pageData) {
|
|
325
|
+
const { title, description, image, canonical, getHtmlMeta } = useMeta()
|
|
326
|
+
|
|
327
|
+
// Set values
|
|
328
|
+
title.value = pageData.title
|
|
329
|
+
description.value = pageData.description
|
|
330
|
+
image.value = pageData.image
|
|
331
|
+
canonical.value = pageData.url
|
|
332
|
+
|
|
333
|
+
// Generate HTML string
|
|
334
|
+
const metaHtml = getHtmlMeta()
|
|
335
|
+
|
|
336
|
+
return `
|
|
337
|
+
<!DOCTYPE html>
|
|
338
|
+
<html>
|
|
339
|
+
<head>
|
|
340
|
+
<title>${pageData.title}</title>
|
|
341
|
+
${metaHtml}
|
|
342
|
+
</head>
|
|
343
|
+
<body>
|
|
344
|
+
<!-- content -->
|
|
345
|
+
</body>
|
|
346
|
+
</html>
|
|
347
|
+
`
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Manage Indexing for Different Environments
|
|
352
|
+
|
|
353
|
+
```html
|
|
354
|
+
<script setup>
|
|
355
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
356
|
+
import { onMounted } from 'vue'
|
|
357
|
+
|
|
358
|
+
const { robots } = useMeta()
|
|
359
|
+
|
|
360
|
+
onMounted(() => {
|
|
361
|
+
// Disable indexing on dev/staging environments
|
|
362
|
+
const isProduction = import.meta.env.PROD
|
|
363
|
+
robots.value = isProduction ? 'index, follow' : 'noindex, nofollow'
|
|
364
|
+
})
|
|
365
|
+
</script>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Integration with Internationalization
|
|
369
|
+
|
|
370
|
+
```html
|
|
371
|
+
<script setup>
|
|
372
|
+
import { useMeta } from '@dxtmisha/functional'
|
|
373
|
+
import { useI18n } from 'vue-i18n'
|
|
374
|
+
import { watch } from 'vue'
|
|
375
|
+
|
|
376
|
+
const { locale } = useI18n()
|
|
377
|
+
const { meta, title, description } = useMeta()
|
|
378
|
+
|
|
379
|
+
watch(locale, (newLocale) => {
|
|
380
|
+
// Update locale for Open Graph
|
|
381
|
+
const localeMap = {
|
|
382
|
+
'ru': 'ru_RU',
|
|
383
|
+
'en': 'en_US',
|
|
384
|
+
'de': 'de_DE'
|
|
385
|
+
}
|
|
386
|
+
meta.setLocale(localeMap[newLocale] || 'en_US')
|
|
387
|
+
|
|
388
|
+
// Update meta tag content
|
|
389
|
+
title.value = t('meta.title')
|
|
390
|
+
description.value = t('meta.description')
|
|
391
|
+
}, { immediate: true })
|
|
392
|
+
</script>
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Important Notes
|
|
396
|
+
|
|
397
|
+
### Singleton Pattern
|
|
398
|
+
|
|
399
|
+
The `useMeta` composable uses a singleton pattern, which means all components share a single meta tags instance. This is useful for:
|
|
400
|
+
|
|
401
|
+
- **Consistency** — changes in one component are reflected everywhere
|
|
402
|
+
- **Performance** — no instance duplication
|
|
403
|
+
- **Simplicity** — no need to pass state between components
|
|
404
|
+
|
|
405
|
+
```javascript
|
|
406
|
+
// In any application component
|
|
407
|
+
const { title } = useMeta()
|
|
408
|
+
title.value = 'New Title'
|
|
409
|
+
|
|
410
|
+
// In another component, you'll get the same value
|
|
411
|
+
const { title: sameTitle } = useMeta()
|
|
412
|
+
console.log(sameTitle.value) // 'New Title'
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Automatic Synchronization
|
|
416
|
+
|
|
417
|
+
All reactive property changes are automatically synchronized with the DOM. No need to call additional methods:
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
const { title, description } = useMeta()
|
|
421
|
+
|
|
422
|
+
// These changes are immediately applied to the DOM
|
|
423
|
+
title.value = 'New Title'
|
|
424
|
+
description.value = 'New Description'
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Open Graph and Twitter Card
|
|
428
|
+
|
|
429
|
+
When changing `title`, `image`, and `canonical`, the corresponding Open Graph and Twitter Card tags are automatically updated. For detailed configuration, use `meta.getOg()` and `meta.getTwitter()` methods.
|
|
430
|
+
|
|
431
|
+
|
|
@@ -69,6 +69,17 @@ isDifferent('hello', 'hello') // false
|
|
|
69
69
|
isDifferent({a: 1}, {a: 1}) // true (different references)
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
## `isDomData`
|
|
73
|
+
|
|
74
|
+
Checks if the current environment is a data URL.
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
import { isDomData } from '@dxtmisha/functional'
|
|
78
|
+
|
|
79
|
+
isDomData() // true if location.href starts with 'data:', otherwise false
|
|
80
|
+
// Useful for detecting if code is running in iframe with data URL
|
|
81
|
+
```
|
|
82
|
+
|
|
72
83
|
## `isDomRuntime`
|
|
73
84
|
|
|
74
85
|
Checks if code is running in browser environment (DOM exists).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/en/functional-basic/Functions/getCurrentDate - Get current date'/>
|
|
4
|
+
|
|
5
|
+
# `getCurrentDate`
|
|
6
|
+
|
|
7
|
+
Returns the current date in the specified format. The function is a wrapper around the `Datetime` class and allows you to quickly get a formatted string of the current time.
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
- `format: GeoDate` — type of date format for output (default `'datetime'`). Supports values: `'date'`, `'time'`, `'datetime'`, `'full'`, and others.
|
|
11
|
+
|
|
12
|
+
**Returns:**
|
|
13
|
+
Current date as a string.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getCurrentDate } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
// Standard format (datetime)
|
|
19
|
+
const now = getCurrentDate()
|
|
20
|
+
// Result: "2024-03-15 14:30"
|
|
21
|
+
|
|
22
|
+
// Date only
|
|
23
|
+
const date = getCurrentDate('date')
|
|
24
|
+
// Result: "2024-03-15"
|
|
25
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/ru/functional-basic/Functions/getCurrentDate - Получение текущей даты'/>
|
|
4
|
+
|
|
5
|
+
# `getCurrentDate`
|
|
6
|
+
|
|
7
|
+
Возвращает текущую дату в указанном формате. Функция является оберткой над классом `Datetime` и позволяет быстро получить отформатированную строку текущего времени.
|
|
8
|
+
|
|
9
|
+
**Параметры:**
|
|
10
|
+
- `format: GeoDate` — тип формата даты вывода (по умолчанию `'datetime'`). Поддерживает значения: `'date'`, `'time'`, `'datetime'`, `'full'` и другие.
|
|
11
|
+
|
|
12
|
+
**Возвращает:**
|
|
13
|
+
Текущая дата в виде строки.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getCurrentDate } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
// Стандартный формат (datetime)
|
|
19
|
+
const now = getCurrentDate()
|
|
20
|
+
// Результат: "2024-03-15 14:30"
|
|
21
|
+
|
|
22
|
+
// Только дата
|
|
23
|
+
const date = getCurrentDate('date')
|
|
24
|
+
// Результат: "2024-03-15"
|
|
25
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/vi/functional-basic/Functions/getCurrentDate - Lấy ngày hiện tại'/>
|
|
4
|
+
|
|
5
|
+
# `getCurrentDate`
|
|
6
|
+
|
|
7
|
+
Trả về ngày hiện tại theo định dạng được chỉ định. Hàm này là một wrapper bao quanh lớp `Datetime` và cho phép bạn nhanh chóng lấy chuỗi thời gian hiện tại đã được định dạng.
|
|
8
|
+
|
|
9
|
+
**Tham số:**
|
|
10
|
+
- `format: GeoDate` — loại định dạng ngày đầu ra (mặc định là `'datetime'`). Hỗ trợ các giá trị: `'date'`, `'time'`, `'datetime'`, `'full'` và các giá trị khác.
|
|
11
|
+
|
|
12
|
+
**Trả về:**
|
|
13
|
+
Ngày hiện tại dưới dạng chuỗi.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getCurrentDate } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
// Định dạng chuẩn (datetime)
|
|
19
|
+
const now = getCurrentDate()
|
|
20
|
+
// Kết quả: "2024-03-15 14:30"
|
|
21
|
+
|
|
22
|
+
// Chỉ ngày
|
|
23
|
+
const date = getCurrentDate('date')
|
|
24
|
+
// Kết quả: "2024-03-15"
|
|
25
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/en/functional-basic/Functions/isEnter - Check for Enter or Space key press'/>
|
|
4
|
+
|
|
5
|
+
# `isEnter`
|
|
6
|
+
|
|
7
|
+
Checks if the pressed key is `Enter` or `Space`. This function is useful for handling keyboard events when you need to react to action confirmation or element activation, while supporting accessibility (a11y) and older browsers.
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
- `event: KeyboardEvent` — the keyboard event object.
|
|
11
|
+
|
|
12
|
+
**Returns:**
|
|
13
|
+
`boolean` — `true` if the `Enter` or `Space` key is pressed, otherwise `false`.
|
|
14
|
+
|
|
15
|
+
**Supported event properties:**
|
|
16
|
+
The function checks the following event properties for maximum compatibility:
|
|
17
|
+
- `code`: `'Enter'`, `'Space'`
|
|
18
|
+
- `key`: `'Enter'`, `' '`, `'Spacebar'`
|
|
19
|
+
- `keyCode`: `13`, `32`
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { isEnter } from '@dxtmisha/functional-basic'
|
|
23
|
+
|
|
24
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
25
|
+
if (isEnter(event)) {
|
|
26
|
+
console.log('Enter or Space pressed')
|
|
27
|
+
// Perform action
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {Meta} from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/ru/functional-basic/Functions/isEnter - Проверка нажатия Enter или Space'/>
|
|
4
|
+
|
|
5
|
+
# `isEnter`
|
|
6
|
+
|
|
7
|
+
Проверяет, является ли нажатая клавиша `Enter` или `Space`. Функция полезна для обработки событий клавиатуры, когда необходимо реагировать на подтверждение действия или активацию элемента, поддерживая при этом доступность (a11y) и старые браузеры.
|
|
8
|
+
|
|
9
|
+
**Параметры:**
|
|
10
|
+
- `event: KeyboardEvent` — объект события клавиатуры.
|
|
11
|
+
|
|
12
|
+
**Возвращает:**
|
|
13
|
+
`boolean` — `true`, если нажата клавиша `Enter` или `Space`, иначе `false`.
|
|
14
|
+
|
|
15
|
+
**Поддерживаемые свойства события:**
|
|
16
|
+
Функция проверяет следующие свойства события для максимальной совместимости:
|
|
17
|
+
- `code`: `'Enter'`, `'Space'`
|
|
18
|
+
- `key`: `'Enter'`, `' '`, `'Spacebar'`
|
|
19
|
+
- `keyCode`: `13`, `32`
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { isEnter } from '@dxtmisha/functional-basic'
|
|
23
|
+
|
|
24
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
25
|
+
if (isEnter(event)) {
|
|
26
|
+
console.log('Нажат Enter или Space')
|
|
27
|
+
// Выполнить действие
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|