0.5.22 • Published 10 months ago

@onereach/regular-expressions v0.5.22

Weekly downloads
-
License
UNLICENSED
Repository
gitlab
Last release
10 months ago

@onereach/regular-expressions

🔍 OneReach Regular Expressions ecosystem. Components and helpers.

Live demo

📣 NOTE: @onereach/regular-expressions requires environment with globally available or-ui.

🚀 Usage example

Just import stuff you need from npm package

import { RegexBuilder,  getRegexBodyFlags } from '@onereach/regular-expressions'

Package exports:

🧱 Components:

RegexBuilder

Input for writing RegExp with detailed tokens explanation.

RegexBuilder

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: ''
  },
  readonly: {
    type: Boolean,
    default: false
  },
  label: {
    type: String,
    default: 'Find'
  },
  error: {
    type: String,
    default: ''
  },
  regexDetailsVisibility: {
    type: Boolean,
    default: false
  },
  docsVisibility: {
    type: Boolean,
    default: false
  },
  mergeFields: {
    type: Array,
    default: () => []
  },
  noMergeFields: {
    type: Boolean,
    default: false
  }
}
EventPayloadDescription
update:regexregexStringEmitted when regex changed
focusEmitted when input field is focused
blurEmitted when input field is unfocused

RegexMatcher

Input for testing RegExp for matches.

RegexMatcher

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: ''
  },
  stringToTest: {
    type: String, 
    default: ''
  },
  readonly: {
    type: Boolean,
    default: false
  },
  label: {
    type: String,
    default: 'Test'
  },
  matchDetailsVisibility: {
    type: Boolean,
    default: false
  }
}
EventPayloadDescription
matchFoundarrayOfMatchesEmitted when got match in stringToTest
update:stringToTeststringToTestEmitted when stringToTest is changed

PlainTextBuilder

Input for creating RegExp, but body is plain text.

PlainTextBuilder

props: {
  // RegExp as string in format '/\\d{2}/gi'
  regex: {
    type: String,
    default: '//i'
  },
  label: {
    type: String,
    default: 'Find'
  },
  readonly: {
    type: Boolean,
    default: false
  },
  error: {
    type: String,
    default: ''
  }
}
EventPayloadDescription
update:regexregexStringEmitted when regex changed

RegexDocs

List of available RegExp tokens. Used inside RegexBuilder as modal.

RegexDocs

props: {
  // is 'Add' button hidden
  readonly: {
    type: Boolean,
    default: false
  }
}
EventPayloadDescription
addToRegextokenObjectEmitted when 'Add' button clicked

RegexesStorage

Modal with list of Favorites and Library RegExps.

RegexesStorage

Requires this.$flow to be available. Favorites (items in KeyValueStorage of your account) can be edited via FavoritesAPI.js service (import { FavoritesAPI } from @onereach/regular-expressions) Library (items in KeyValueStorage of Provides account) can be edited via API (https://devdocs-staging.onereach.ai/providers/index.html#/regular%20expressions) or UI flow in Provides account (https://studio.staging.onereach.ai/flows/4289e44f-c771-4abd-b933-696258d987db/bbef6ab4-6f04-4aa3-93b9-78813426ea1c)

Usage:

<template>
  <div>
    <RegexesStorage
      ref="regexesStorage"
      @select="addItem"
    />
  </div>
</template>

<script>
  import { RegexesStorage } from '@onereach/regular-expressions'

  {
    components: {
      RegexesStorage
    },

    methods: {
      openRegexesStorageModal () {
        this.$refs.regexesStorage.open();
      },
      addItem (regexObject) {
        console.log('selected item', regexObject)
      }
    }
  }
</script>
EventPayloadDescription
selectregexObjectEmitted when 'Select' button clicked
favoritesWasChangedfavoritesArrayEmitted when list of favorites was changed (some item was edited or deleted)

🛠 Helpers:

getRegexBodyFlags

Parse regexString body and flags to use it as new RegExp(body, flags).

'/\d{2}/gi' => { body: '\d{2}', flags: 'gi' }

FavoritesAPI

Class for CRUD operations with Favorites RegExps.

Usage:

import { FavoritesAPI } from '@onereach/regular-expressions'

const favoritesAPI = new FavoritesAPI({
  $flowApiKeyValueSdkApiUrl: this.$flow.api.keyValue.sdkApiUrl,
  $flowToken: this.$flow.token
})

await favoritesAPI.getItems()
await favoritesAPI.setItem(id, { id, name, description, categories, regex })
await favoritesAPI.deleteItem(id)

Some exports, methods and event are non documented, because used in edge case scenarios. But feel free checking out source code on GitLab 😉

📣 NOTE: this project uses changelog-ci. Don't forget to include changelog with merge request.

0.5.21

10 months ago

0.5.22

10 months ago

0.5.11

2 years ago

0.5.18

2 years ago

0.5.19

2 years ago

0.5.16

2 years ago

0.5.17

2 years ago

0.5.14

2 years ago

0.5.15

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

0.5.10

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.9

2 years ago

0.5.6

2 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.17

3 years ago

0.5.3

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.1

3 years ago

0.5.2

3 years ago

0.4.3

3 years ago

0.5.1

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.1

3 years ago