comand-component-library 4.1.78 → 4.1.79
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/dist/comand-component-library.js +604 -581
- package/package.json +2 -2
- package/src/ComponentLibrary.vue +6 -1
- package/src/components/CmdForm.vue +2 -2
- package/src/mixins/I18n.js +62 -62
- package/src/utils/date.js +29 -0
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "comand-component-library",
         | 
| 3 | 
            -
              "version": "4.1. | 
| 3 | 
            +
              "version": "4.1.79",
         | 
| 4 4 | 
             
              "license": "GPL-3.0-only",
         | 
| 5 5 | 
             
              "author": "CoManD-UI",
         | 
| 6 6 | 
             
              "private": false,
         | 
| @@ -26,7 +26,7 @@ | |
| 26 26 | 
             
              "dependencies": {
         | 
| 27 27 | 
             
                "clickout-event": "^1.1.2",
         | 
| 28 28 | 
             
                "comand-component-library": "^4.1.63",
         | 
| 29 | 
            -
                "comand-frontend-framework": "^4.1. | 
| 29 | 
            +
                "comand-frontend-framework": "^4.1.27",
         | 
| 30 30 | 
             
                "comand-ui-iconfonts": "^1.0.14",
         | 
| 31 31 | 
             
                "core-js": "^3.20.1",
         | 
| 32 32 | 
             
                "prismjs": "^1.27.0",
         | 
    
        package/src/ComponentLibrary.vue
    CHANGED
    
    | @@ -1974,6 +1974,10 @@ | |
| 1974 1974 | 
             
                                <a href="#" class="button small icon-cog" title="Open Component Settings"
         | 
| 1975 1975 | 
             
                                   @click.prevent="openSettingsSidebar('CmdThumbnailScroller')"></a>
         | 
| 1976 1976 | 
             
                            </h2>
         | 
| 1977 | 
            +
                            <p> date (YMD/default): {{formatDate('2025-01-28', "", "-")}}</p>
         | 
| 1978 | 
            +
                            <p> date (DMY): {{formatDate('2025-01-28', "dmy")}}</p>
         | 
| 1979 | 
            +
                            <p> date (MDY): {{formatDate('2025-01-28', "mdy", "/")}}</p>
         | 
| 1980 | 
            +
                            <p> date (invalid)): {{formatDate('invalid')}}</p>
         | 
| 1977 1981 | 
             
                            <div class="inline-size">
         | 
| 1978 1982 | 
             
                                <CmdThumbnailScroller
         | 
| 1979 1983 | 
             
                                    ref="CmdThumbnailScroller"
         | 
| @@ -2072,7 +2076,6 @@ | |
| 2072 2076 | 
             
                        <CmdWidthLimitationWrapper>
         | 
| 2073 2077 | 
             
                            <h1 class="headline-demopage">Page Overview</h1>
         | 
| 2074 2078 | 
             
                        </CmdWidthLimitationWrapper>
         | 
| 2075 | 
            -
             | 
| 2076 2079 | 
             
                        <!-- begin page-overview -->
         | 
| 2077 2080 | 
             
                        <PageOverview/>
         | 
| 2078 2081 | 
             
                        <!-- end page-overview -->
         | 
| @@ -2175,6 +2178,7 @@ import listOfComponents from "@/assets/data/listOfComponents.json" | |
| 2175 2178 | 
             
            import PageOverview from "@/pages/PageOverview.vue"
         | 
| 2176 2179 |  | 
| 2177 2180 | 
             
            // import external functions
         | 
| 2181 | 
            +
            import {formatDate} from "@/utils/date.js"
         | 
| 2178 2182 | 
             
            import * as functions from "@/mixins/FieldValidation.js"
         | 
| 2179 2183 | 
             
            import {openFancyBox} from "@/components/CmdFancyBox.vue"
         | 
| 2180 2184 | 
             
            import {localizedTime} from "./components/CmdOpeningHours.vue"
         | 
| @@ -2383,6 +2387,7 @@ export default { | |
| 2383 2387 | 
             
                    }
         | 
| 2384 2388 | 
             
                },
         | 
| 2385 2389 | 
             
                methods: {
         | 
| 2390 | 
            +
                    formatDate,
         | 
| 2386 2391 | 
             
                    updateLanguage(event) {
         | 
| 2387 2392 | 
             
                        this.selectedLanguage = event.iso2
         | 
| 2388 2393 | 
             
                    },
         | 
| @@ -40,7 +40,7 @@ | |
| 40 40 | 
             
                            <!-- begin submit-button (inside fieldset) -->
         | 
| 41 41 | 
             
                            <button
         | 
| 42 42 | 
             
                                v-if="submitButtonOptions && (submitButtonOptions.position === 'insideFieldset' || submitButtonOptions.position === null) "
         | 
| 43 | 
            -
                                :class="['button stretch-on-small-devices', {primary: submitButtonOptions.primary}]"
         | 
| 43 | 
            +
                                :class="['button stretch-on-small-devices', {primary: submitButtonOptions.primary}, {disabled: submitButtonOptions.disabled}]"
         | 
| 44 44 | 
             
                                :type="submitButtonOptions.type"
         | 
| 45 45 | 
             
                            >
         | 
| 46 46 | 
             
                                <span v-if="submitButtonOptions.iconClass" :class="submitButtonOptions.iconClass"></span>
         | 
| @@ -51,7 +51,7 @@ | |
| 51 51 |  | 
| 52 52 | 
             
                        <div v-if="submitButtonOptions && submitButtonOptions.position === 'belowFieldset'" class="button-wrapper">
         | 
| 53 53 | 
             
                            <!-- begin submit-button (below fieldset) -->
         | 
| 54 | 
            -
                            <button :class="['button stretch-on-small-devices', {primary: submitButtonOptions.primary}]"
         | 
| 54 | 
            +
                            <button :class="['button stretch-on-small-devices', {primary: submitButtonOptions.primary}, {disabled: submitButtonOptions.disabled}]"
         | 
| 55 55 | 
             
                                    :type="submitButtonOptions.type || 'submit'">
         | 
| 56 56 | 
             
                                <span v-if="submitButtonOptions.iconClass" :class="submitButtonOptions.iconClass"></span>
         | 
| 57 57 | 
             
                                <span v-if="submitButtonOptions.text">{{ submitButtonOptions.text }}</span>
         | 
    
        package/src/mixins/I18n.js
    CHANGED
    
    | @@ -1,67 +1,67 @@ | |
| 1 1 | 
             
            export default {
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
                }
         | 
| 30 | 
            -
              },
         | 
| 31 | 
            -
              methods: {
         | 
| 32 | 
            -
                getMessage(key, ...params) {
         | 
| 33 | 
            -
                  if (!key) {
         | 
| 34 | 
            -
                    return ""
         | 
| 35 | 
            -
                  }
         | 
| 36 | 
            -
                  let messages = this.i18n
         | 
| 37 | 
            -
                  if (typeof this.i18n === "function") {
         | 
| 38 | 
            -
                    messages = this.i18n.call(this, key, params)
         | 
| 39 | 
            -
                    if (typeof messages !== "object") {
         | 
| 40 | 
            -
                      return messages
         | 
| 2 | 
            +
                props: {
         | 
| 3 | 
            +
                    /**
         | 
| 4 | 
            +
                     * Message properties for internationalization.
         | 
| 5 | 
            +
                     *
         | 
| 6 | 
            +
                     * You can either specify an object with key-value-pairs or a function which
         | 
| 7 | 
            +
                     * takes at least one input parameter (the key) and returns the according
         | 
| 8 | 
            +
                     * message.
         | 
| 9 | 
            +
                     *
         | 
| 10 | 
            +
                     * If key-value-pairs are provided, the value can be either a string or a
         | 
| 11 | 
            +
                     * function. If it is a function, then it is called with an array of
         | 
| 12 | 
            +
                     * replacements for placeholders in the message.
         | 
| 13 | 
            +
                     *
         | 
| 14 | 
            +
                     * If a function is provided, it is called with two parameters. The first
         | 
| 15 | 
            +
                     * parameter is the message key and the second parameter is an array of
         | 
| 16 | 
            +
                     * replacements for placeholders in the message.
         | 
| 17 | 
            +
                     *
         | 
| 18 | 
            +
                     * Example:
         | 
| 19 | 
            +
                     * <pre>
         | 
| 20 | 
            +
                     * {
         | 
| 21 | 
            +
                     *   "my.message1": "My {0} test message with {1} placeholders",
         | 
| 22 | 
            +
                     *   "my.message2": params => "My {0} message".replace("{0}", params[0])
         | 
| 23 | 
            +
                     * }
         | 
| 24 | 
            +
                     * </pre>
         | 
| 25 | 
            +
                     */
         | 
| 26 | 
            +
                    i18n: {
         | 
| 27 | 
            +
                        type: [Object, Function],
         | 
| 28 | 
            +
                        default: () => ({})
         | 
| 41 29 | 
             
                    }
         | 
| 42 | 
            -
                  }
         | 
| 43 | 
            -
                  let message =
         | 
| 44 | 
            -
                    messages[key] ||
         | 
| 45 | 
            -
                    this.getDefaultMessageProperty(key) ||
         | 
| 46 | 
            -
                    key
         | 
| 47 | 
            -
                  if (typeof message === "function") {
         | 
| 48 | 
            -
                    return message.call(this, params || []);
         | 
| 49 | 
            -
                  }
         | 
| 50 | 
            -
                  if (Array.isArray(params) && params.length) {
         | 
| 51 | 
            -
                    params.forEach((param, index) => (message = message.replace("{" + index + "}", param)))
         | 
| 52 | 
            -
                  }
         | 
| 53 | 
            -
                  return message
         | 
| 54 30 | 
             
                },
         | 
| 55 | 
            -
                 | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 31 | 
            +
                methods: {
         | 
| 32 | 
            +
                    getMessage(key, ...params) {
         | 
| 33 | 
            +
                        if (!key) {
         | 
| 34 | 
            +
                            return ""
         | 
| 35 | 
            +
                        }
         | 
| 36 | 
            +
                        let messages = this.i18n
         | 
| 37 | 
            +
                        if (typeof this.i18n === "function") {
         | 
| 38 | 
            +
                            messages = this.i18n.call(this, key, params)
         | 
| 39 | 
            +
                            if (typeof messages !== "object") {
         | 
| 40 | 
            +
                                return messages
         | 
| 41 | 
            +
                            }
         | 
| 42 | 
            +
                        }
         | 
| 43 | 
            +
                        let message =
         | 
| 44 | 
            +
                            messages[key] ||
         | 
| 45 | 
            +
                            this.getDefaultMessageProperty(key) ||
         | 
| 46 | 
            +
                            key
         | 
| 47 | 
            +
                        if (typeof message === "function") {
         | 
| 48 | 
            +
                            return message.call(this, params || []);
         | 
| 49 | 
            +
                        }
         | 
| 50 | 
            +
                        if (Array.isArray(params) && params.length) {
         | 
| 51 | 
            +
                            params.forEach((param, index) => (message = message.replace("{" + index + "}", param)))
         | 
| 52 | 
            +
                        }
         | 
| 53 | 
            +
                        return message
         | 
| 54 | 
            +
                    },
         | 
| 55 | 
            +
                    getDefaultMessageProperty(key) {
         | 
| 56 | 
            +
                        if (Object.hasOwn(this, "defaultMessageProperties") && this.defaultMessageProperties && this.defaultMessageProperties[key]) {
         | 
| 57 | 
            +
                            return this.defaultMessageProperties[key]
         | 
| 58 | 
            +
                        }
         | 
| 59 | 
            +
                        //const propertyKey = Object.keys(this).find(p => p.slice(-24) === "DefaultMessageProperties")
         | 
| 60 | 
            +
                        const propertyKey = Object.hasOwn(this, "fieldValidationDefaultMessageProperties") ? "fieldValidationDefaultMessageProperties" : null
         | 
| 61 | 
            +
                        if (propertyKey && this[propertyKey]?.[key]) {
         | 
| 62 | 
            +
                            return this[propertyKey][key]
         | 
| 63 | 
            +
                        }
         | 
| 64 | 
            +
                        return null
         | 
| 65 | 
            +
                    }
         | 
| 65 66 | 
             
                }
         | 
| 66 | 
            -
              }
         | 
| 67 67 | 
             
            }
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            function formatDate(inputDate, format = "dmy", separator=".") {
         | 
| 2 | 
            +
                // Ensure the input is a valid date object or string
         | 
| 3 | 
            +
                const date = new Date(inputDate);
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                if (isNaN(date)) {
         | 
| 6 | 
            +
                    console.error("function formatDate received an invalid date as parameter. Provide date in format YYYY-MM-DD");
         | 
| 7 | 
            +
                }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                const year = date.getFullYear();
         | 
| 10 | 
            +
                const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
         | 
| 11 | 
            +
                const day = String(date.getDate()).padStart(2, '0');
         | 
| 12 | 
            +
                let dateFormated = ""
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                switch (format) {
         | 
| 15 | 
            +
                    case 'dmy':
         | 
| 16 | 
            +
                        dateFormated = `${day}${separator}${month}${separator}${year}` // DD-MM-YYYY
         | 
| 17 | 
            +
                        break
         | 
| 18 | 
            +
                    case 'mdy':
         | 
| 19 | 
            +
                        dateFormated = `${month}${separator}${day}${separator}${year}` // MM-DD-YYYY
         | 
| 20 | 
            +
                        break
         | 
| 21 | 
            +
                    default:
         | 
| 22 | 
            +
                        dateFormated = `${year}${separator}${month}${separator}${day}` // YYYY-MM-DD
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                return dateFormated
         | 
| 27 | 
            +
            }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            export {formatDate}
         |